From patchwork Wed Sep 18 20:19:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Numan Siddique X-Patchwork-Id: 1986975 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X89436CBWz1y20 for ; Thu, 19 Sep 2024 06:19:47 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 2507A41262; Wed, 18 Sep 2024 20:19:46 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id NAUOBBjyXv4d; Wed, 18 Sep 2024 20:19:44 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.9.56; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 9008D40096 Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id 9008D40096; Wed, 18 Sep 2024 20:19:44 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 3FE46C0012; Wed, 18 Sep 2024 20:19:44 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0133EC0011 for ; Wed, 18 Sep 2024 20:19:42 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id E8CAC427AD for ; Wed, 18 Sep 2024 20:19:42 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id dyrNzdSEdr7U for ; Wed, 18 Sep 2024 20:19:41 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2001:4b98:dc4:8::223; helo=relay3-d.mail.gandi.net; envelope-from=numans@ovn.org; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp4.osuosl.org 3EA3E40172 Authentication-Results: smtp4.osuosl.org; dmarc=none (p=none dis=none) header.from=ovn.org DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 3EA3E40172 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::223]) by smtp4.osuosl.org (Postfix) with ESMTPS id 3EA3E40172 for ; Wed, 18 Sep 2024 20:19:40 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id AD88060002; Wed, 18 Sep 2024 20:19:37 +0000 (UTC) From: numans@ovn.org To: dev@openvswitch.org Date: Wed, 18 Sep 2024 16:19:30 -0400 Message-ID: <20240918201930.926336-1-numans@ovn.org> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 X-GND-Sasl: numans@ovn.org Subject: [ovs-dev] [PATCH ovn] tests: Add a test case for patch ports not created by OVN. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.30 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 ovn-controller creates patch ports for ovn-bridge-mappings, it sets external_ids:ovn-localnet-port= in the OVS Port. This indicates that OVN owns and manages these patch ports. It's possible that CMS may create patch ports externally connecting br-int to CMS managed OVS bridges. This patch adds a test case to ensure that ovn-controller doesn't modify or delete these patch ports in anyway. Reported-at: https://issues.redhat.com/browse/FDP-734 Signed-off-by: Numan Siddique Acked-by: Mark Michelson --- tests/ovn.at | 114 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) diff --git a/tests/ovn.at b/tests/ovn.at index 4b6e8132f0..e6c8421539 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -38926,3 +38926,117 @@ OVN_CHECK_PACKETS([hv/vif1-tx.pcap], [expected-vif1]) AT_CLEANUP ]) + +AT_SETUP([Patch ports not owned by OVN]) + +AT_KEYWORDS([ovn]) +ovn_start + +net_add n1 +sim_add hv1 +ovs-vsctl add-br br-eth0 +ovs-vsctl add-br br-eth1 +ovs-vsctl add-br br-phys +ovn_attach n1 br-phys 192.168.0.20 + +ovs-vsctl set Open_vSwitch . external_ids:ovn-bridge-mappings=physnet1:br-eth0,physnet2:br-eth1 + +check ovn-nbctl ls-add sw0 +check ovn-nbctl lsp-add sw0 sw0p1 + +check ovn-nbctl --wait=hv sync + +check ovn-appctl -t ovn-controller debug/ignore-startup-delay + +# Waits until the OVS database contains exactly the specified patch ports. +# Each argument should be of the form BRIDGE PORT PEER. +check_patch_ports () { + # Generate code to check that the set of patch ports is exactly as + # specified. + echo 'ovs-vsctl -f csv -d bare --no-headings --columns=name find Interface type=patch | sort' > query + for patch + do + echo $patch + done | cut -d' ' -f 2 | sort > expout + + # Generate code to verify that the configuration of each patch + # port is correct. + for patch + do + set $patch; bridge=$1 port=$2 peer=$3 + echo >>query "ovs-vsctl iface-to-br $port -- get Interface $port type options" + echo >>expout "$bridge +patch +{peer=$peer}" + done + + # Run the query until we get the expected result (or until a timeout). + # + # (We use sed to drop all "s from output because ovs-vsctl quotes some + # of the port names but not others.) + AT_CAPTURE_FILE([query]) + AT_CAPTURE_FILE([expout]) + AT_CAPTURE_FILE([stdout]) + OVS_WAIT_UNTIL([. ./query | sed 's/"//g' > stdout #" + diff -u stdout expout >/dev/null]) +} + +# Initially there should be no patch ports. +check_patch_ports + +check ovn-nbctl lsp-add sw0 ln-sw0 +check ovn-nbctl lsp-set-type ln-sw0 localnet +check ovn-nbctl lsp-set-addresses ln-sw0 unknown +check ovn-nbctl --wait=hv lsp-set-options ln-sw0 network_name=physnet1 + +# There should still be no patch ports. +check_patch_ports + +as hv1 +check ovs-vsctl \ + -- add-port br-int vif1 \ + -- set Interface vif1 external_ids:iface-id=sw0p1 + +# ovn-controller should bind the interface. +wait_for_ports_up + +AS_BOX([Checking for patch ports to be created by OVN for ln-sw0]) +check_patch_ports \ + 'br-int patch-br-int-to-ln-sw0 patch-ln-sw0-to-br-int' \ + 'br-eth0 patch-ln-sw0-to-br-int patch-br-int-to-ln-sw0' + + +check ovs-vsctl add-port br-int patch-br-int-to-br-eth0 \ + -- set interface patch-br-int-to-br-eth0 options:peer=patch-br-eth0-to-br-int \ + -- set interface patch-br-int-to-br-eth0 type=patch \ + -- add-port br-eth0 patch-br-eth0-to-br-int \ + -- set interface patch-br-eth0-to-br-int options:peer=patch-br-int-to-br-eth0 \ + -- set interface patch-br-eth0-to-br-int type=patch \ + +AS_BOX([Checking for patch ports after creating manual patch ports]) + +check_patch_ports \ + 'br-int patch-br-int-to-ln-sw0 patch-ln-sw0-to-br-int' \ + 'br-eth0 patch-ln-sw0-to-br-int patch-br-int-to-ln-sw0' \ + 'br-int patch-br-int-to-br-eth0 patch-br-eth0-to-br-int' \ + 'br-eth0 patch-br-eth0-to-br-int patch-br-int-to-br-eth0' + +# Delete the localnet port. ovn-controller should not +# delete the manually created ones. +check ovn-nbctl --wait=hv lsp-del ln-sw0 + +check_patch_ports \ + 'br-int patch-br-int-to-br-eth0 patch-br-eth0-to-br-int' \ + 'br-eth0 patch-br-eth0-to-br-int patch-br-int-to-br-eth0' + +# Set external_ids:ovn-localnet-port to the manually created patch port. +# ovn-controller should delete the patch ports now as we are setting +# OVN as its owner. +check ovs-vsctl set port patch-br-int-to-br-eth0 external_ids:ovn-localnet-port=foo +ovn-nbctl --wait=hv sync + +AS_BOX([Checking for patch ports after setting external_ids:ovn-localnet-port to the manually created patch port]) +check_patch_ports + +OVN_CLEANUP([hv1]) +AT_CLEANUP