From patchwork Wed Jul 1 15:34:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Numan Siddique X-Patchwork-Id: 1320641 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ovn.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49xldr59L2z9sPF for ; Thu, 2 Jul 2020 01:34:40 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 8258E8AC0F; Wed, 1 Jul 2020 15:34:36 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id y2beJeWitOdH; Wed, 1 Jul 2020 15:34:35 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id CFF808ABCE; Wed, 1 Jul 2020 15:34:35 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id B2D2EC0890; Wed, 1 Jul 2020 15:34:35 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 933E7C0733 for ; Wed, 1 Jul 2020 15:34:34 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 8C7CA893B8 for ; Wed, 1 Jul 2020 15:34:34 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zKvEaermSNhe for ; Wed, 1 Jul 2020 15:34:33 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 2F425893B6 for ; Wed, 1 Jul 2020 15:34:33 +0000 (UTC) X-Originating-IP: 115.99.176.12 Received: from nusiddiq.home.org.com (unknown [115.99.176.12]) (Authenticated sender: numans@ovn.org) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 3E0D940005; Wed, 1 Jul 2020 15:34:28 +0000 (UTC) From: numans@ovn.org To: dev@openvswitch.org Date: Wed, 1 Jul 2020 21:04:22 +0530 Message-Id: <20200701153422.267380-1-numans@ovn.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Subject: [ovs-dev] [PATCH ovn v2] ovn-controller: Configure hwaddr for the integration bridge X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Numan Siddique 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 Acked-by: Mark Michelson --- v1 -> v2 ----- * Added the comments in the code as suggested by Mark. controller/ovn-controller.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index b0ee60a1a..e355007b8 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -277,10 +277,33 @@ 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"); + + /* 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. + * + * We can avoid the disconnection by setting the 'other_config:hwaddr' for + * the integration bridge. ovs-vswitchd uses this hwaddr to calculate the + * datapath-id and it doesn't recalculate the datapath-id later when the + * first non-local port is added. + * + * So generate a random mac and set the 'hwaddr' option in the + * other_config. + * */ + 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);