From patchwork Thu Sep 24 01:44:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Numan Siddique X-Patchwork-Id: 1370215 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 4BxdCK0V1yz9sSt for ; Thu, 24 Sep 2020 11:45:00 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 894C087458; Thu, 24 Sep 2020 01:44:58 +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 IZHLilrZddn5; Thu, 24 Sep 2020 01:44:54 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id 90D84873D8; Thu, 24 Sep 2020 01:44:54 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 75762C0889; Thu, 24 Sep 2020 01:44:54 +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 87A37C0051 for ; Thu, 24 Sep 2020 01:44:52 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 77CC520367 for ; Thu, 24 Sep 2020 01:44:52 +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 WZO6gZK5TNes for ; Thu, 24 Sep 2020 01:44:51 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by silver.osuosl.org (Postfix) with ESMTPS id 1C7BF1FD43 for ; Thu, 24 Sep 2020 01:44:49 +0000 (UTC) X-Originating-IP: 60.243.224.208 Received: from nusiddiq.home.org.com (unknown [60.243.224.208]) (Authenticated sender: numans@ovn.org) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id AB9B5FF802; Thu, 24 Sep 2020 01:44:45 +0000 (UTC) From: numans@ovn.org To: dev@openvswitch.org Date: Thu, 24 Sep 2020 07:14:35 +0530 Message-Id: <20200924014435.1503008-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 v2] 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 Acked-by: Han Zhou Signed-off-by: Numan Siddique --- v1 -> v2 ------ * Moved the code to call is_iface_in_int_bridge() only if the iface has iface_id set and ofport > 0. controller/binding.c | 18 +++++++++++++++++- tests/ovn.at | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/controller/binding.c b/controller/binding.c index 99e9fae301..36fd350091 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. */ @@ -1906,7 +1921,8 @@ binding_handle_ovs_interface_changes(struct binding_ctx_in *b_ctx_in, 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) { + if (iface_id && ofport > 0 && + is_iface_in_int_bridge(iface_rec, b_ctx_in->br_int)) { handled = consider_iface_claim(iface_rec, iface_id, b_ctx_in, b_ctx_out, qos_map_ptr); if (!handled) { 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