From patchwork Wed Sep 23 17:10:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Numan Siddique X-Patchwork-Id: 1369973 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.137; helo=fraxinus.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 fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BxPp244CHz9sS8 for ; Thu, 24 Sep 2020 03:10:50 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 2FCCB85533; Wed, 23 Sep 2020 17:10:49 +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 puV-CiepBEax; Wed, 23 Sep 2020 17:10:48 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id 7CE6B85F74; Wed, 23 Sep 2020 17:10:48 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 65A56C0859; Wed, 23 Sep 2020 17:10:48 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 7AAFEC0859 for ; Wed, 23 Sep 2020 17:10:47 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 7586920488 for ; Wed, 23 Sep 2020 17:10:47 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dqXDuvQdV83F for ; Wed, 23 Sep 2020 17:10:46 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by silver.osuosl.org (Postfix) with ESMTPS id C3A802045D for ; Wed, 23 Sep 2020 17:10:45 +0000 (UTC) X-Originating-IP: 27.7.147.223 Received: from nusiddiq.home.org.com (unknown [27.7.147.223]) (Authenticated sender: numans@ovn.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 04CDF1C0009; Wed, 23 Sep 2020 17:10:40 +0000 (UTC) From: numans@ovn.org To: dev@openvswitch.org Date: Wed, 23 Sep 2020 22:40:32 +0530 Message-Id: <20200923171032.1354591-1-numans@ovn.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-GND-Spam-Score: 400 X-GND-Status: SPAM Cc: Han Zhou Subject: [ovs-dev] [PATCH ovn] controller: binding: Ignore changes to OVS interfaces which doesn't belong to int 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 Consider the below commands. ovn-nbctl ls-add sw0 ovn-nbctl lsp-add sw0 sw0-p1 ovs-vsctl add-br br-temp ovs-vsctl add port br-temp t1 -- set interface t1 external_ids:iface-id=sw0-p1 When ovn-controller handles the OVS db changes incrementally, it binds the lport sw0-p1, which is wrong as t1 is not in the integration bridge - br-int. If a recompute is triggered, ovn-controller releases the lport sw0-p1. This patch fixes this issue. Fixes: 354bdba51abf ("ovn-controller: I-P for SB port binding and OVS interface in runtime_data.") CC: Han Zhou Signed-off-by: Numan Siddique Acked-by: Han Zhou --- controller/binding.c | 21 +++++++++++++++++++++ tests/ovn.at | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/controller/binding.c b/controller/binding.c index 99e9fae301..bf4aa70c5d 100644 --- a/controller/binding.c +++ b/controller/binding.c @@ -1799,6 +1799,21 @@ is_iface_vif(const struct ovsrec_interface *iface_rec) return true; } +static bool +is_iface_in_int_bridge(const struct ovsrec_interface *iface, + const struct ovsrec_bridge *br_int) +{ + for (size_t i = 0; i < br_int->n_ports; i++) { + const struct ovsrec_port *p = br_int->ports[i]; + for (size_t j = 0; j < p->n_interfaces; j++) { + if (!strcmp(iface->name, p->interfaces[j]->name)) { + return true; + } + } + } + return false; +} + /* Returns true if the ovs interface changes were handled successfully, * false otherwise. */ @@ -1904,6 +1919,12 @@ binding_handle_ovs_interface_changes(struct binding_ctx_in *b_ctx_in, continue; } + /* If the changed interface doesn't belong to the integration bridge, + * ignore it. */ + if (!is_iface_in_int_bridge(iface_rec, b_ctx_in->br_int)) { + continue; + } + const char *iface_id = smap_get(&iface_rec->external_ids, "iface-id"); int64_t ofport = iface_rec->n_ofport ? *iface_rec->ofport : 0; if (iface_id && ofport > 0) { diff --git a/tests/ovn.at b/tests/ovn.at index 59e59f43f8..b6c8622ba4 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -22256,3 +22256,46 @@ grep conjunction | wc -l`]) OVN_CLEANUP([hv1]) AT_CLEANUP + +AT_SETUP([ovn -- I-P of OVS interface changes which belong to non integration bridge]) +ovn_start + +net_add n1 +sim_add hv1 +as hv1 +ovs-vsctl add-br br-phys +ovn_attach n1 br-phys 192.168.0.10 + +ovn-nbctl ls-add sw0 +ovn-nbctl lsp-add sw0 sw0-p1 +ovn-nbctl lsp-add sw0 sw0-p2 + +as hv1 ovs-vsctl \ + -- add-port br-int vif1 \ + -- set Interface vif1 external_ids:iface-id=sw0-p1 + +# Wait for port to be bound. +OVS_WAIT_UNTIL([test $(ovn-sbctl --columns _uuid --bare list chassis hv1 | wc -l) -eq 1]) +ch=$(ovn-sbctl --columns _uuid --bare list chassis hv1) +OVS_WAIT_UNTIL([test $(ovn-sbctl --columns chassis --bare list port_binding sw0-p1 | grep $ch -c) -eq 1]) + +as hv1 ovs-vsctl add-br br-temp +as hv1 ovs-vsctl \ + -- add-port br-temp t1 \ + -- set Interface t1 external_ids:iface-id=sw0-p2 + +ovn-nbctl --wait=hv sync + +# hv1 ovn-controller should not bind sw0-p2. +AT_CHECK([test $(ovn-sbctl --columns chassis --bare list port_binding sw0-p2 | grep $ch -c) -eq 0]) + +# Trigger recompute and sw0-p2 should not be claimed. +as hv1 ovn-appctl -t ovn-controller recompute +ovn-nbctl --wait=hv sync + +AT_CHECK([test $(ovn-sbctl --columns chassis --bare list port_binding sw0-p2 | grep $ch -c) -eq 0]) + +ovn-sbctl --columns chassis --bare list port_binding sw0-p2 + +OVN_CLEANUP([hv1]) +AT_CLEANUP