From patchwork Thu Sep 8 21:29:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Flaviof X-Patchwork-Id: 667804 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (archives.nicira.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 3sVYPV5rlqz9s3T for ; Fri, 9 Sep 2016 07:29:18 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id F33F5102C4; Thu, 8 Sep 2016 14:29:16 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx3v3.cudamail.com (mx3.cudamail.com [64.34.241.5]) by archives.nicira.com (Postfix) with ESMTPS id 40CA1102A7 for ; Thu, 8 Sep 2016 14:29:16 -0700 (PDT) Received: from bar6.cudamail.com (localhost [127.0.0.1]) by mx3v3.cudamail.com (Postfix) with ESMTPS id C15B216152E for ; Thu, 8 Sep 2016 15:29:14 -0600 (MDT) X-ASG-Debug-ID: 1473370152-0b32374f8134670001-byXFYA Received: from mx3-pf1.cudamail.com ([192.168.14.2]) by bar6.cudamail.com with ESMTP id 8spqbzc0uZ5uneYa (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 08 Sep 2016 15:29:12 -0600 (MDT) X-Barracuda-Envelope-From: guteusa@gmail.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.2 Received: from unknown (HELO mail-wm0-f67.google.com) (74.125.82.67) by mx3-pf1.cudamail.com with ESMTPS (AES128-SHA encrypted); 8 Sep 2016 21:29:11 -0000 Received-SPF: pass (mx3-pf1.cudamail.com: SPF record at _netblocks.google.com designates 74.125.82.67 as permitted sender) X-Barracuda-Apparent-Source-IP: 74.125.82.67 X-Barracuda-RBL-IP: 74.125.82.67 Received: by mail-wm0-f67.google.com with SMTP id l65so22862wmf.3 for ; Thu, 08 Sep 2016 14:29:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id :senderwebaddress; bh=P9QWSHtBgKWnaiHwZNQEAGjaJU2R8NAE1byG7n+tzjQ=; b=fsadeXzTtvx+rkLKnFqm94lfG7Euixl/KlskTC2oayCtM/sVY4R5shajSszei+IcUu rLjY4qBo8w+cVi2NfPz2DMrXLJuG7dYNqBclVsdIn+iZWuOZBJrAiNwSYyW/l2t4m4S7 U3V2GZgeqj5jZfWO+Xs1G/hNKvVtzFdJDt1VfPY9WrHEVNQyvDw7xNBRZoGF7eVooIPb nsFFB1gwUvl4TApYr3bWSJzUJTc1DL/qqGkvQmgSNYIIHXdU2N1hw+8wwn952aecnKUc 8SeU93CuXi5PBHlfn2bcX1n1SzpN7PPWb/fDVNzfodRrRP9PFlhV0UURb5cpTy/VwCE2 M27Q== X-Gm-Message-State: AE9vXwPITYB8jd/G6oorKeGbzkW6drrd41qSq3A0u2MV5oQ5g9ZdlTmRYw1eTlUF0DpRGQ== X-Received: by 10.28.230.19 with SMTP id d19mr1996326wmh.111.1473370150247; Thu, 08 Sep 2016 14:29:10 -0700 (PDT) Received: from cp-ff02.ibm.com (38.cd.089f.ip4.static.sl-reverse.com. [159.8.205.56]) by smtp.gmail.com with ESMTPSA id bw9sm49822wjc.33.2016.09.08.14.29.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 08 Sep 2016 14:29:09 -0700 (PDT) X-CudaMail-Envelope-Sender: guteusa@gmail.com From: Flavio Fernandes To: dev@openvswitch.org X-CudaMail-MID: CM-V1-907052116 X-CudaMail-DTE: 090816 X-CudaMail-Originating-IP: 74.125.82.67 Date: Thu, 8 Sep 2016 16:29:02 -0500 X-ASG-Orig-Subj: [##CM-V1-907052116##][PATCH v3] ovn: ensure datapath removal is proper Message-Id: <1473370142-22124-1-git-send-email-flavio@flaviof.com> X-Mailer: git-send-email 2.7.4 SenderWebAddress: http://flaviof.com/ X-GBUdb-Analysis: 0, 74.125.82.67, Ugly c=0.165853 p=-0.2 Source Normal X-MessageSniffer-Rules: 0-0-0-8399-c X-Barracuda-Connect: UNKNOWN[192.168.14.2] X-Barracuda-Start-Time: 1473370152 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.60 X-Barracuda-Spam-Status: No, SCORE=0.60 using global scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=4.0 tests=BSF_SC5_MJ1963, RDNS_NONE X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.32741 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.10 RDNS_NONE Delivered to trusted network by a host with no rDNS 0.50 BSF_SC5_MJ1963 Custom Rule MJ1963 Subject: [ovs-dev] [PATCH v3] ovn: ensure datapath removal is proper X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" Adding a unit test in ovn.at, to exercise the cleanup of OF rules related to a logical datapath, when a logical switch is removed. Reported-by: Guru Shetty Reported-at: http://openvswitch.org/pipermail/discuss/2016-August/022478.html Signed-off-by: Flavio Fernandes --- v1->v2: rebase and ensure this is no longer an issue v2->v3: avoid potential race when doing check after ls removal. Thanks Russell! tests/ovn.at | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/tests/ovn.at b/tests/ovn.at index a23b422..88520f9 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -4319,6 +4319,73 @@ OVN_CLEANUP([hv1]) AT_CLEANUP +# 1 hypervisor, 1 port +# make sure that the OF rules created to support a datapath are added/cleared +# when logical switch is created and removed. +AT_SETUP([ovn -- datapath rules added/removed]) +AT_KEYWORDS([ovn datapath cleanup]) +ovn_start + +net_add n1 +sim_add hv1 +as hv1 ovs-vsctl add-br br-phys +as hv1 ovn_attach n1 br-phys 192.168.0.1 + +# This shell function checks if OF rules in br-int have clauses +# related to OVN datapaths. The caller determines if it should find +# a match in the output, or not. +# +# EXPECT_DATAPATH param determines whether flows that refer to +# datapath to should be present or not. 0 means +# they should not be. +# STAGE_INFO param is a simple string to help identify the stage +# in the test when this function was invoked. +test_datapath_in_of_rules() { + local expect_datapath=$1 stage_info=$2 + echo "------ ovn-nbctl show ${stage_info} ------" + ovn-nbctl show + echo "------ ovn-sbctl show ${stage_info} ------" + ovn-sbctl show + echo "------ OF rules ${stage_info} ------" + AT_CHECK([ovs-ofctl dump-flows br-int], [0], [stdout]) + # if there is a datapath mentioned in the output, check for the + # magic keyword that represents one, based on the exit status of + # a quiet grep + if test $expect_datapath != 0; then + AT_CHECK([grep --quiet -i 'metadata=' stdout], [0], [ignore-nolog]) + else + AT_CHECK([grep --quiet -i 'metadata=' stdout], [1], [ignore-nolog]) + fi +} + +test_datapath_in_of_rules 0 "before ls+port create" + +ovn-nbctl ls-add ls1 +ovn-nbctl lsp-add ls1 lp1 +ovn-nbctl lsp-set-addresses lp1 unknown + +as hv1 ovs-vsctl add-port br-int vif1 -- set Interface vif1 external-ids:iface-id=lp1 +OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up lp1` = xup]) + +test_datapath_in_of_rules 1 "after port is bound" + +as hv1 ovs-vsctl del-port br-int vif1 +OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up lp1` = xdown]) + +ovn-nbctl lsp-set-addresses lp1 +ovn-nbctl lsp-del lp1 +ovn-nbctl ls-del ls1 + +# wait for earlier changes to take effect +AT_CHECK([ovn-nbctl --timeout=3 --wait=sb sync], [0], [ignore]) + +# ensure OF rules are no longer present. There used to be a bug here. +test_datapath_in_of_rules 0 "after lport+ls removal" + +OVN_CLEANUP([hv1]) + +AT_CLEANUP + AT_SETUP([ovn -- nd_na ]) AT_KEYWORDS([ovn-nd_na]) AT_SKIP_IF([test $HAVE_PYTHON = no])