[ovs-dev] [PATCH ovn] tests: Fix frequent failure of "4 HV, 1 LS, 1 LR, packet test with HA distributed router gateway port:".

2021-04-17 Thread numans
From: Numan Siddique 

This test is failing quite often due to timing issues.  The failures are
mainly due to the packet not received by the other side of the tunnel.
The test case resets the pcap file and then injects the packet.  And
this packet gets lost sometimes if the pcap files are not reset yet.
To fix this issue the test now ensures that ovs-vswitchd resets the
pcap file before injecting the packet.  The test also now adds
some waits to make sure flows related to tunnels are programmed
when the chassisresident port moves from one gw chassis to other.

Signed-off-by: Numan Siddique 
---
 tests/ovn-macros.at | 18 ++
 tests/ovn.at| 31 +++
 2 files changed, 37 insertions(+), 12 deletions(-)

diff --git a/tests/ovn-macros.at b/tests/ovn-macros.at
index 25f3dbe348..9a05359ba5 100644
--- a/tests/ovn-macros.at
+++ b/tests/ovn-macros.at
@@ -487,6 +487,24 @@ wait_for_ports_up() {
 done
 fi
 }
+
+# reset_pcap_file iface pcap_file
+# Resets the pcap file associates with OVS interface.  should be used
+# with dummy datapath.
+reset_iface_pcap_file() {
+local iface=$1
+local pcap_file=$2
+check rm -f dummy-*.pcap
+check ovs-vsctl -- set Interface $iface options:tx_pcap=dummy-tx.pcap \
+options:rxq_pcap=dummy-rx.pcap
+OVS_WAIT_WHILE([test 24 = $(wc -c dummy-tx.pcap | cut -d " " -f1)])
+check rm -f ${pcap_file}*.pcap
+check ovs-vsctl -- set Interface $iface 
options:tx_pcap=${pcap_file}-tx.pcap \
+options:rxq_pcap=${pcap_file}-rx.pcap
+
+OVS_WAIT_WHILE([test 24 = $(wc -c ${pcap_file}-tx.pcap | cut -d " " -f1)])
+}
+
 OVS_END_SHELL_HELPERS
 
 m4_define([OVN_POPULATE_ARP], [AT_CHECK(ovn_populate_arp__, [0], [ignore])])
diff --git a/tests/ovn.at b/tests/ovn.at
index 4c3d76d573..71cc7118ba 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -10096,15 +10096,12 @@ AT_CHECK([ovn-nbctl --wait=sb sync], [0], [ignore])
 ovn-sbctl dump-flows > sbflows
 AT_CAPTURE_FILE([sbflows])
 
-reset_pcap_file() {
-local iface=$1
-local pcap_file=$2
-check ovs-vsctl -- set Interface $iface options:tx_pcap=dummy-tx.pcap \
-options:rxq_pcap=dummy-rx.pcap
-rm -f ${pcap_file}*.pcap
-check ovs-vsctl -- set Interface $iface 
options:tx_pcap=${pcap_file}-tx.pcap \
-options:rxq_pcap=${pcap_file}-rx.pcap
-}
+hv1_gw1_ofport=$(as hv1 ovs-vsctl --bare --columns ofport find Interface 
name=ovn-gw1-0)
+hv1_gw2_ofport=$(as hv1 ovs-vsctl --bare --columns ofport find Interface 
name=ovn-gw2-0)
+
+OVS_WAIT_UNTIL([
+test 1 = $(as hv1 ovs-ofctl dump-flows br-int table=37 | grep -c 
"active_backup,ofport,members:$hv1_gw1_ofport,$hv1_gw2_ofport")
+])
 
 test_ip_packet()
 {
@@ -10150,13 +10147,13 @@ test_ip_packet()
 echo $expected > ext1-vif1.expected
 
exp_gw_ip_garp=020102030806000108000604000102010203ac100101ac100101
 echo $exp_gw_ip_garp >> ext1-vif1.expected
-as $active_gw reset_pcap_file br-phys_n1 $active_gw/br-phys_n1
+as $active_gw reset_iface_pcap_file br-phys_n1 $active_gw/br-phys_n1
 
 if test $backup_vswitchd_dead != 1; then
 # Reset the file only if vswitchd in backup gw is alive
-as $backup_gw reset_pcap_file br-phys_n1 $backup_gw/br-phys_n1
+as $backup_gw reset_iface_pcap_file br-phys_n1 $backup_gw/br-phys_n1
 fi
-as ext1 reset_pcap_file ext1-vif1 ext1/vif1
+as ext1 reset_iface_pcap_file ext1-vif1 ext1/vif1
 
 # Resend packet from foo1 to outside1
 check as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet
@@ -10208,6 +10205,10 @@ AT_CHECK(
 <1>
 ])
 
+OVS_WAIT_UNTIL([
+test 1 = $(as hv1 ovs-ofctl dump-flows br-int table=37 | grep -c 
"active_backup,ofport,members:$hv1_gw2_ofport,$hv1_gw1_ofport")
+])
+
 test_ip_packet gw2 gw1 0
 
 # Get the claim count of both gw1 and gw2.
@@ -10228,6 +10229,12 @@ OVS_WAIT_UNTIL([test $gw1_claim_ct = `cat 
gw1/ovn-controller.log \
 AT_CHECK([test $gw2_claim_ct = `cat gw2/ovn-controller.log | \
 grep -c "cr-alice: Claiming"`])
 
+OVS_WAIT_UNTIL([
+bfd_status=$(as hv1 ovs-vsctl get interface ovn-gw2-0 bfd_status:state)
+echo "bfd status = $bfd_status"
+test "$bfd_status" = "down"
+])
+
 test_ip_packet gw1 gw2 1
 
 as gw2
-- 
2.29.2

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH v4 1/2] Encap & Decap actions for MPLS packet type.

2021-04-17 Thread Jan Scheurich via dev


> -Original Message-
> From: Martin Varghese 
> Sent: Tuesday, 13 April, 2021 16:20
> To: Jan Scheurich 
> Cc: Eelco Chaudron ; d...@openvswitch.org;
> pshe...@ovn.org; martin.vargh...@nokia.com
> Subject: Re: [PATCH v4 1/2] Encap & Decap actions for MPLS packet type.
> 
> On Wed, Apr 07, 2021 at 03:49:07PM +, Jan Scheurich wrote:
> > Hi Martin,
> >
> > I guess you are aware of the original design document we wrote for generic
> encap/decap and NSH support:
> > https://protect2.fireeye.com/v1/url?k=993ba795-c6a09d8c-993be70e-8682a
> > aa22bc0-3c9b4464027ca7bf&q=1&e=f89fc25e-8dc0-45bf-bdd9-
> 2d0ca03b5686&u=
> >
> https%3A%2F%2Fdocs.google.com%2Fdocument%2Fd%2F1oWMYUH8sjZJzWa72
> o2q9kU
> > 0N6pNE-rwZcLH3-kbbDR8%2Fedit%23
> >
> > It is no longer 100% aligned with the final implementation in OVS but still 
> > a
> good reference for understanding the design principles behind the
> implementation and some specifics for Ethernet and NSH encap/decap use
> cases.
> >
> > Please find some more answers/comments below.
> >
> > BR, Jan
> >
> > > -Original Message-
> > > From: Martin Varghese 
> > > Sent: Wednesday, 7 April, 2021 10:43
> > > To: Jan Scheurich 
> > > Cc: Eelco Chaudron ; d...@openvswitch.org;
> > > pshe...@ovn.org; martin.vargh...@nokia.com
> > > Subject: Re: [PATCH v4 1/2] Encap & Decap actions for MPLS packet type.
> > >
> > > On Tue, Apr 06, 2021 at 09:00:16AM +, Jan Scheurich wrote:
> > > > Hi,
> > > >
> > > > Thanks for the heads up. The interaction with MPLS push/pop is a
> > > > use case
> > > that was likely not tested during the NSH and generic encap/decap
> > > design. It's complex code and a long time ago. I'm willing to help,
> > > but I will need some time to go back and have a look.
> > > >
> > > > It would definitely help, if you could provide a minimal example
> > > > for
> > > reproducing the problem.
> > > >
> > >
> > > Hi Jan ,
> > >
> > > Thanks for your help.
> > >
> > > I was trying to implement ENCAP/DECAP support for MPLS.
> > >
> > > The programming of datapath flow for the below  userspace rule fails
> > > as there is set(eth() action between pop_mpls and recirc ovs-ofctl
> > > -O OpenFlow13 add- flow br_mpls2
> > > "in_port=$egress_port,dl_type=0x8847
> > > actions=decap(),decap(packet_type(ns=0,type=0),goto_table:1
> > >
> > > 2021-04-05T05:46:49.192Z|00068|dpif(handler51)|WARN|system@ovs-
> > > system: failed to put[create] (Invalid argument)
> > > ufid:1dddb0ba-27fe-44ea- 9a99-5815764b4b9c
> > > recirc_id(0),dp_hash(0/0),skb_priority(0/0),in_port(6),skb_mark(0/0)
> > > ,ct_state
> > > (0/0),ct_zone(0/0),ct_mark(0/0),ct_label(0/0),eth(src=00:00:00:00:00:01/00:
> > > 00:00:00:00:00,dst=00:00:00:00:00:02/00:00:00:00:00:00),eth_type(0x8
> > > 847) ,mpls(label=2/0x0,tc=0/0,ttl=64/0x0,bos=1/1),
> > > actions:pop_eth,pop_mpls(eth_type=0x6558),set(eth()),recirc(0x45)
> > >
> >
> > Conceptually, what should happen in this scenario is that, after the second
> decap(packet_type(ns=0,type=0) action, OVS processes the unchanged inner
> packet as packet type PT_ETH, i.e. as L2 Ethernet frame. Overwriting the
> existing Ethernet header with zero values  through set(eth()) is clearly
> incorrect. That is a logical error inside the ofproto-dpif-xlate module (see
> below).
> >
> > I believe the netdev userspace datapath would still have accepted the
> incorrect datapath flow. I have too little experience with the kernel 
> datapath to
> explain why that rejects the datapath flow as invalid.
> >
> > Unlike in the Ethernet and NSH cases, the MPLS header does not contain any
> indication about the inner packet type. That is why the packet_type must be
> provided by the SDN controller as part of the decap() action.  And the 
> ofproto-
> dpif-xlate module must consider the specified inner packet type when
> continuing the translation. In the general case, a decap() action should 
> trigger
> recirculation for reparsing of the inner packet, so the new packet type must 
> be
> set before recirculation. (Exceptions to the general recirculation rule are 
> those
> where OVS has already parsed further into the packet and ofproto can modify
> the flow on the fly: decap(Ethernet) and possibly decap(MPLS) for all but the
> last bottom of stack label).
> >
> > I have had a look at your new code for encap/decap of MPLS headers, but I
> must admit I cannot fully judge in how far re-using the existing translation
> functions for MPLS label stacks written for the legacy push/pop_mpls case 
> (i.e.
> manipulating a label stack between the L2 and the L3 headers of a PT_ETH
> Packet) are possible to re-use in the new context.
> >
> > BTW: Do you support multiple MPLS label encap or decap actions with your
> patch? Have you tested that?
> >
> > I am uncertain about the handling of the ethertype of the decapsulated inner
> packet. In the design base, the ethertype that is set in the existing L2 
> header of
> the packet after pop_mpls of the last label is coming from the pop_mpls 
> ac