[ovs-dev] [PATCH] ovn-controller: Provide the option to set the datapath-type of br-int

Mark Michelson mmichels at redhat.com
Mon Feb 18 21:02:18 UTC 2019


Looks good to me.

Acked-by: Mark Michelson <mmichels at redhat.com>

Out of curiosity, can you think of any other bridge configuration items 
that might need the same treatment?

On 2/17/19 11:42 PM, nusiddiq at redhat.com wrote:
> From: Numan Siddique <nusiddiq at redhat.com>
> 
> If the integration bridge is deleted, ovn-controller recreates it
> but the previous datapath-type value is lost if it was set. This
> patch adds the code in ovn-controller to set the datapath-type
> if it is configured by the user in the 'external_ids:ovn-bridge-datapath-type'
> column of OpenvSwitch table.
> 
> Signed-off-by: Numan Siddique <nusiddiq at redhat.com>
> ---
>   ovn/controller/ovn-controller.8.xml |  8 ++++++++
>   ovn/controller/ovn-controller.c     | 11 ++++++++++-
>   tests/ovn-controller.at             | 14 ++++++++++++++
>   3 files changed, 32 insertions(+), 1 deletion(-)
> 
> diff --git a/ovn/controller/ovn-controller.8.xml b/ovn/controller/ovn-controller.8.xml
> index 8035638b3..fd2e10a7a 100644
> --- a/ovn/controller/ovn-controller.8.xml
> +++ b/ovn/controller/ovn-controller.8.xml
> @@ -81,6 +81,14 @@
>           default configuration suggested in <code>ovn-architecture</code>(7).
>         </dd>
>   
> +      <dt><code>external_ids:ovn-bridge-datapath-type</code></dt>
> +      <dd>
> +        This configuration is optional. If set, then the datapath type of
> +        the integration bridge will be set to the configured value. If this
> +        option is not set, then <code>ovn-controller</code> will not modify
> +        the existing <code>datapath-type</code> of the integration bridge.
> +      </dd>
> +
>         <dt><code>external_ids:ovn-remote</code></dt>
>         <dd>
>           <p>
> diff --git a/ovn/controller/ovn-controller.c b/ovn/controller/ovn-controller.c
> index 2098f280c..882cc195f 100644
> --- a/ovn/controller/ovn-controller.c
> +++ b/ovn/controller/ovn-controller.c
> @@ -253,7 +253,16 @@ get_br_int(struct ovsdb_idl_txn *ovs_idl_txn,
>   
>       const struct ovsrec_bridge *br = get_bridge(bridge_table, br_int_name);
>       if (!br) {
> -        return create_br_int(ovs_idl_txn, cfg, br_int_name);
> +        br = create_br_int(ovs_idl_txn, cfg, br_int_name);
> +    }
> +    if (br && ovs_idl_txn) {
> +        const char *datapath_type = smap_get(&cfg->external_ids,
> +                                             "ovn-bridge-datapath-type");
> +        /* Check for the datapath_type and set it only if it is defined in
> +         * cfg. */
> +        if (datapath_type && strcmp(br->datapath_type, datapath_type)) {
> +            ovsrec_bridge_set_datapath_type(br, datapath_type);
> +        }
>       }
>       return br;
>   }
> diff --git a/tests/ovn-controller.at b/tests/ovn-controller.at
> index 13e88a0cc..4ed4ca083 100644
> --- a/tests/ovn-controller.at
> +++ b/tests/ovn-controller.at
> @@ -158,6 +158,20 @@ OVS_WAIT_UNTIL([check_datapath_type bar])
>   ovs-vsctl set Bridge br-int datapath-type=\"\"
>   OVS_WAIT_UNTIL([check_datapath_type ""])
>   
> +# Set the datapath_type in external_ids:ovn-bridge-datapath-type.
> +ovs-vsctl set Open_vSwitch . external_ids:ovn-bridge-datapath-type=foo
> +OVS_WAIT_UNTIL([check_datapath_type foo])
> +
> +# Change the br-int's datapath type to bar.
> +# It should be reset to foo since ovn-bridge-datapath-type is configured.
> +ovs-vsctl set Bridge br-int datapath-type=bar
> +OVS_WAIT_UNTIL([test foo=`ovs-vsctl get Bridge br-int datapath-type`])
> +OVS_WAIT_UNTIL([check_datapath_type foo])
> +
> +ovs-vsctl set Open_vSwitch . external_ids:ovn-bridge-datapath-type=foobar
> +OVS_WAIT_UNTIL([test foobar=`ovs-vsctl get Bridge br-int datapath-type`])
> +OVS_WAIT_UNTIL([check_datapath_type foobar])
> +
>   expected_iface_types=$(ovs-vsctl get Open_vSwitch . iface_types | tr -d '[[]] ""')
>   echo "expected_iface_types = ${expected_iface_types}"
>   chassis_iface_types=$(ovn-sbctl get Chassis ${sysid} external_ids:iface-types | sed -e 's/\"//g')
> 



More information about the dev mailing list