Message ID | 20200430081000.751498-1-numans@ovn.org |
---|---|
State | Accepted |
Headers | show |
Series | [ovs-dev,ovn] ovn-controller: Configure hwaddr for the integration bridge | expand |
Hi Numan, I approve of this change, but you should add a comment to the code about why we're setting a random hwaddr to the bridge. It is completely non-obvious why we are doing it just from reading the code. On 4/30/20 4:10 AM, numans@ovn.org wrote: > From: Numan Siddique <numans@ovn.org> > > When a first non-local port is added to the integration bridge, it results > in the recalculation of datapath-id by ovs-vswitchd forcing all > active connections to the controllers to reconnect. > > This patch avoids these reconnections between ovs-vswitchd and ovn-controller > by setting the hwaddr for the integration bridge when ovn-controller creates the > integration bridge. ovs-vswitchd uses the bridge:hwaddr if set to generate the > datapath-id. > > Signed-off-by: Numan Siddique <numans@ovn.org> > --- > controller/ovn-controller.c | 15 +++++++++++++-- > 1 file changed, 13 insertions(+), 2 deletions(-) > > diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c > index 6ff897325..299e1e544 100644 > --- a/controller/ovn-controller.c > +++ b/controller/ovn-controller.c > @@ -277,10 +277,21 @@ create_br_int(struct ovsdb_idl_txn *ovs_idl_txn, > bridge = ovsrec_bridge_insert(ovs_idl_txn); > ovsrec_bridge_set_name(bridge, bridge_name); > ovsrec_bridge_set_fail_mode(bridge, "secure"); > - const struct smap oc = SMAP_CONST1(&oc, "disable-in-band", "true"); > - ovsrec_bridge_set_other_config(bridge, &oc); > ovsrec_bridge_set_ports(bridge, &port, 1); > > + struct smap oc = SMAP_INITIALIZER(&oc); > + smap_add(&oc, "disable-in-band", "true"); > + > + struct eth_addr br_hwaddr; > + eth_addr_random(&br_hwaddr); > + char ea_s[ETH_ADDR_STRLEN + 1]; > + snprintf(ea_s, sizeof ea_s, ETH_ADDR_FMT, > + ETH_ADDR_ARGS(br_hwaddr)); > + smap_add(&oc, "hwaddr", ea_s); > + > + ovsrec_bridge_set_other_config(bridge, &oc); > + smap_destroy(&oc); > + > struct ovsrec_bridge **bridges; > size_t bytes = sizeof *bridges * cfg->n_bridges; > bridges = xmalloc(bytes + sizeof *bridges); >
On Wed, Jul 1, 2020 at 8:14 PM Mark Michelson <mmichels@redhat.com> wrote: > Hi Numan, > > I approve of this change, but you should add a comment to the code about > why we're setting a random hwaddr to the bridge. It is completely > non-obvious why we are doing it just from reading the code. > > Thanks Mark. I agree. It's not obvious why it is required. I added the comment and submitted v2. Request to take a look. Thanks Numan > On 4/30/20 4:10 AM, numans@ovn.org wrote: > > From: Numan Siddique <numans@ovn.org> > > > > When a first non-local port is added to the integration bridge, it > results > > in the recalculation of datapath-id by ovs-vswitchd forcing all > > active connections to the controllers to reconnect. > > > > This patch avoids these reconnections between ovs-vswitchd and > ovn-controller > > by setting the hwaddr for the integration bridge when ovn-controller > creates the > > integration bridge. ovs-vswitchd uses the bridge:hwaddr if set to > generate the > > datapath-id. > > > > Signed-off-by: Numan Siddique <numans@ovn.org> > > --- > > controller/ovn-controller.c | 15 +++++++++++++-- > > 1 file changed, 13 insertions(+), 2 deletions(-) > > > > diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c > > index 6ff897325..299e1e544 100644 > > --- a/controller/ovn-controller.c > > +++ b/controller/ovn-controller.c > > @@ -277,10 +277,21 @@ create_br_int(struct ovsdb_idl_txn *ovs_idl_txn, > > bridge = ovsrec_bridge_insert(ovs_idl_txn); > > ovsrec_bridge_set_name(bridge, bridge_name); > > ovsrec_bridge_set_fail_mode(bridge, "secure"); > > - const struct smap oc = SMAP_CONST1(&oc, "disable-in-band", "true"); > > - ovsrec_bridge_set_other_config(bridge, &oc); > > ovsrec_bridge_set_ports(bridge, &port, 1); > > > > + struct smap oc = SMAP_INITIALIZER(&oc); > > + smap_add(&oc, "disable-in-band", "true"); > > + > > + struct eth_addr br_hwaddr; > > + eth_addr_random(&br_hwaddr); > > + char ea_s[ETH_ADDR_STRLEN + 1]; > > + snprintf(ea_s, sizeof ea_s, ETH_ADDR_FMT, > > + ETH_ADDR_ARGS(br_hwaddr)); > > + smap_add(&oc, "hwaddr", ea_s); > > + > > + ovsrec_bridge_set_other_config(bridge, &oc); > > + smap_destroy(&oc); > > + > > struct ovsrec_bridge **bridges; > > size_t bytes = sizeof *bridges * cfg->n_bridges; > > bridges = xmalloc(bytes + sizeof *bridges); > > > > _______________________________________________ > dev mailing list > dev@openvswitch.org > https://mail.openvswitch.org/mailman/listinfo/ovs-dev > >
diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index 6ff897325..299e1e544 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -277,10 +277,21 @@ create_br_int(struct ovsdb_idl_txn *ovs_idl_txn, bridge = ovsrec_bridge_insert(ovs_idl_txn); ovsrec_bridge_set_name(bridge, bridge_name); ovsrec_bridge_set_fail_mode(bridge, "secure"); - const struct smap oc = SMAP_CONST1(&oc, "disable-in-band", "true"); - ovsrec_bridge_set_other_config(bridge, &oc); ovsrec_bridge_set_ports(bridge, &port, 1); + struct smap oc = SMAP_INITIALIZER(&oc); + smap_add(&oc, "disable-in-band", "true"); + + struct eth_addr br_hwaddr; + eth_addr_random(&br_hwaddr); + char ea_s[ETH_ADDR_STRLEN + 1]; + snprintf(ea_s, sizeof ea_s, ETH_ADDR_FMT, + ETH_ADDR_ARGS(br_hwaddr)); + smap_add(&oc, "hwaddr", ea_s); + + ovsrec_bridge_set_other_config(bridge, &oc); + smap_destroy(&oc); + struct ovsrec_bridge **bridges; size_t bytes = sizeof *bridges * cfg->n_bridges; bridges = xmalloc(bytes + sizeof *bridges);