diff mbox series

[ovs-dev,v1] tests: Added NSH related unit test cases for datapath

Message ID 1522367169-4674-1-git-send-email-ashishvarma.ovs@gmail.com
State Accepted
Headers show
Series [ovs-dev,v1] tests: Added NSH related unit test cases for datapath | expand

Commit Message

Ashish Varma March 29, 2018, 11:46 p.m. UTC
Added test cases for encap, decap, replace and forwarding of NSH packets.
Also added a python script 'sendpkt.py' to send hex ethernet frames.

Signed-off-by: Ashish Varma <ashishvarma.ovs@gmail.com>
---
 tests/automake.mk       |   4 +-
 tests/sendpkt.py        |  94 ++++++++++++++++++++++++++++
 tests/system-traffic.at | 163 ++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 260 insertions(+), 1 deletion(-)
 create mode 100755 tests/sendpkt.py

Comments

Ben Pfaff April 4, 2018, 5:23 p.m. UTC | #1
On Thu, Mar 29, 2018 at 04:46:09PM -0700, Ashish Varma wrote:
> Added test cases for encap, decap, replace and forwarding of NSH packets.
> Also added a python script 'sendpkt.py' to send hex ethernet frames.
> 
> Signed-off-by: Ashish Varma <ashishvarma.ovs@gmail.com>

Ashish, do you have a suggestion who should review this?  Greg, are you
the right person?
Gregory Rose April 6, 2018, 2:35 p.m. UTC | #2
On 4/4/2018 10:23 AM, Ben Pfaff wrote:
> On Thu, Mar 29, 2018 at 04:46:09PM -0700, Ashish Varma wrote:
>> Added test cases for encap, decap, replace and forwarding of NSH packets.
>> Also added a python script 'sendpkt.py' to send hex ethernet frames.
>>
>> Signed-off-by: Ashish Varma <ashishvarma.ovs@gmail.com>
> Ashish, do you have a suggestion who should review this?  Greg, are you
> the right person?
I can have a look at them now that I'm back but need to get caught up 
with some other issues first.

Thanks,

- Greg
Gregory Rose April 11, 2018, midnight UTC | #3
On 4/6/2018 7:35 AM, Gregory Rose wrote:
>
>
> On 4/4/2018 10:23 AM, Ben Pfaff wrote:
>> On Thu, Mar 29, 2018 at 04:46:09PM -0700, Ashish Varma wrote:
>>> Added test cases for encap, decap, replace and forwarding of NSH 
>>> packets.
>>> Also added a python script 'sendpkt.py' to send hex ethernet frames.
>>>
>>> Signed-off-by: Ashish Varma <ashishvarma.ovs@gmail.com>
>> Ashish, do you have a suggestion who should review this?  Greg, are you
>> the right person?
> I can have a look at them now that I'm back but need to get caught up 
> with some other issues first.

Ashish,

I continue to be otherwise occupied so I'm sorry for the delay in 
reviewing your patch.  It is still on my radar!

Thanks,

- Greg

>
> Thanks,
>
> - Greg
Ashish Varma April 11, 2018, 6:13 p.m. UTC | #4
Sure, no problem.

Thanks,
Ashish

On Tue, Apr 10, 2018 at 5:00 PM, Gregory Rose <gvrose8192@gmail.com> wrote:

> On 4/6/2018 7:35 AM, Gregory Rose wrote:
>
>>
>>
>> On 4/4/2018 10:23 AM, Ben Pfaff wrote:
>>
>>> On Thu, Mar 29, 2018 at 04:46:09PM -0700, Ashish Varma wrote:
>>>
>>>> Added test cases for encap, decap, replace and forwarding of NSH
>>>> packets.
>>>> Also added a python script 'sendpkt.py' to send hex ethernet frames.
>>>>
>>>> Signed-off-by: Ashish Varma <ashishvarma.ovs@gmail.com>
>>>>
>>> Ashish, do you have a suggestion who should review this?  Greg, are you
>>> the right person?
>>>
>> I can have a look at them now that I'm back but need to get caught up
>> with some other issues first.
>>
>
> Ashish,
>
> I continue to be otherwise occupied so I'm sorry for the delay in
> reviewing your patch.  It is still on my radar!
>
> Thanks,
>
> - Greg
>
>
>> Thanks,
>>
>> - Greg
>>
>
>
Gregory Rose April 16, 2018, 9:58 p.m. UTC | #5
On 4/11/2018 11:13 AM, Ashish Varma wrote:
> Sure, no problem.
>
> Thanks,
> Ashish
>
> On Tue, Apr 10, 2018 at 5:00 PM, Gregory Rose <gvrose8192@gmail.com 
> <mailto:gvrose8192@gmail.com>> wrote:
>
>     On 4/6/2018 7:35 AM, Gregory Rose wrote:
>
>
>
>         On 4/4/2018 10:23 AM, Ben Pfaff wrote:
>
>             On Thu, Mar 29, 2018 at 04:46:09PM -0700, Ashish Varma wrote:
>
>                 Added test cases for encap, decap, replace and
>                 forwarding of NSH packets.
>                 Also added a python script 'sendpkt.py' to send hex
>                 ethernet frames.
>
>                 Signed-off-by: Ashish Varma <ashishvarma.ovs@gmail.com
>                 <mailto:ashishvarma.ovs@gmail.com>>
>
>             Ashish, do you have a suggestion who should review this? 
>             Greg, are you
>             the right person?
>
>         I can have a look at them now that I'm back but need to get
>         caught up with some other issues first.
>
>
>     Ashish,
>
>     I continue to be otherwise occupied so I'm sorry for the delay in
>     reviewing your patch.  It is still on my radar!
>
>     Thanks,
>
>     - Greg
>

Looks good - tests out alright to me:

set /bin/bash '../tests/system-kmod-testsuite' -C tests 
AUTOTEST_PATH='utilities:vswitchd:ovsdb:vtep:tests::/usr:ovn/controller-vtep:ovn/northd:ovn/utilities:ovn/controller' 
-k nsh -j1; \
"$@" || (test X'' = Xyes && "$@" --recheck)
## ------------------------------ ##
## openvswitch 2.9.90 test suite. ##
## ------------------------------ ##

nsh-datapath

  91: nsh - encap header                              ok
  92: nsh - decap header                              ok
  93: nsh - replace header                            ok
  94: nsh - forward                                   ok

## ------------- ##
## Test results. ##
## ------------- ##

All 4 tests were successful.

And the script code looks fine to me as well.

Tested-by: Greg Rose <gvrose8192@gmail.com>
Reviewed-by: Greg Rose <gvrose8192@gmail.com>
Ben Pfaff April 17, 2018, 3:19 p.m. UTC | #6
On Mon, Apr 16, 2018 at 02:58:34PM -0700, Gregory Rose wrote:
> On 4/11/2018 11:13 AM, Ashish Varma wrote:
> >Sure, no problem.
> >
> >Thanks,
> >Ashish
> >
> >On Tue, Apr 10, 2018 at 5:00 PM, Gregory Rose <gvrose8192@gmail.com
> ><mailto:gvrose8192@gmail.com>> wrote:
> >
> >    On 4/6/2018 7:35 AM, Gregory Rose wrote:
> >
> >
> >
> >        On 4/4/2018 10:23 AM, Ben Pfaff wrote:
> >
> >            On Thu, Mar 29, 2018 at 04:46:09PM -0700, Ashish Varma wrote:
> >
> >                Added test cases for encap, decap, replace and
> >                forwarding of NSH packets.
> >                Also added a python script 'sendpkt.py' to send hex
> >                ethernet frames.
> >
> >                Signed-off-by: Ashish Varma <ashishvarma.ovs@gmail.com
> >                <mailto:ashishvarma.ovs@gmail.com>>
> >
> >            Ashish, do you have a suggestion who should review this? 
> >            Greg, are you
> >            the right person?
> >
> >        I can have a look at them now that I'm back but need to get
> >        caught up with some other issues first.
> >
> >
> >    Ashish,
> >
> >    I continue to be otherwise occupied so I'm sorry for the delay in
> >    reviewing your patch.  It is still on my radar!
> >
> >    Thanks,
> >
> >    - Greg
> >
> 
> Looks good - tests out alright to me:
> 
> set /bin/bash '../tests/system-kmod-testsuite' -C tests AUTOTEST_PATH='utilities:vswitchd:ovsdb:vtep:tests::/usr:ovn/controller-vtep:ovn/northd:ovn/utilities:ovn/controller'
> -k nsh -j1; \
> "$@" || (test X'' = Xyes && "$@" --recheck)
> ## ------------------------------ ##
> ## openvswitch 2.9.90 test suite. ##
> ## ------------------------------ ##
> 
> nsh-datapath
> 
>  91: nsh - encap header                              ok
>  92: nsh - decap header                              ok
>  93: nsh - replace header                            ok
>  94: nsh - forward                                   ok
> 
> ## ------------- ##
> ## Test results. ##
> ## ------------- ##
> 
> All 4 tests were successful.
> 
> And the script code looks fine to me as well.
> 
> Tested-by: Greg Rose <gvrose8192@gmail.com>
> Reviewed-by: Greg Rose <gvrose8192@gmail.com>

Thanks Greg and Ashish.

I folded in the following to make the build-time Python checking OK with
it (also fixed a spelling error "eode" => "code"), added Greg's tags,
and applied this to master.

Thanks again!

Ben

--8<--------------------------cut here-------------------------->8--

diff --git a/tests/sendpkt.py b/tests/sendpkt.py
index 6d16d0f45e9e..50a4795ebf34 100755
--- a/tests/sendpkt.py
+++ b/tests/sendpkt.py
@@ -26,7 +26,6 @@
 
 
 import socket
-import struct
 import sys
 from optparse import OptionParser
 
@@ -72,23 +71,23 @@ pkt = "".join(map(chr, hex_list))
 try:
     sockfd = socket.socket(socket.AF_PACKET, socket.SOCK_RAW)
 except socket.error as msg:
-    print 'unable to create socket! error eode: ' + str(msg[0]) + ' : '\
-                                                                    + msg[1]
+    print('unable to create socket! error code: ' + str(msg[0]) + ' : '
+                                                                    + msg[1])
     sys.exit(2)
 
 try:
     sockfd.bind((args[0], 0))
 except socket.error as msg:
-    print 'unable to bind socket! error eode: ' + str(msg[0]) + ' : '\
-                                                                    + msg[1]
+    print('unable to bind socket! error code: ' + str(msg[0]) + ' : '
+                                                                    + msg[1])
     sys.exit(2)
 
 try:
     sockfd.send(pkt)
 except socket.error as msg:
-    print 'unable to send packet! error eode: ' + str(msg[0]) + ' : '\
-                                                                    + msg[1]
+    print('unable to send packet! error code: ' + str(msg[0]) + ' : '
+                                                                    + msg[1])
     sys.exit(2)
 
-print 'send success!'
+print('send success!')
 sys.exit(0)
diff mbox series

Patch

diff --git a/tests/automake.mk b/tests/automake.mk
index 780d3b8..0796123 100644
--- a/tests/automake.mk
+++ b/tests/automake.mk
@@ -400,7 +400,9 @@  CHECK_PYFILES = \
 	tests/test-unix-socket.py \
 	tests/test-unixctl.py \
 	tests/test-vlog.py \
-	tests/uuidfilt.py
+	tests/uuidfilt.py \
+	tests/sendpkt.py
+
 EXTRA_DIST += $(CHECK_PYFILES)
 PYCOV_CLEAN_FILES += $(CHECK_PYFILES:.py=.py,cover) .coverage
 
diff --git a/tests/sendpkt.py b/tests/sendpkt.py
new file mode 100755
index 0000000..6d16d0f
--- /dev/null
+++ b/tests/sendpkt.py
@@ -0,0 +1,94 @@ 
+#! /usr/bin/env python
+
+# Copyright (c) 2018 VMware, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+# This program can be used send L2-L7 protocol messages using the hex bytes
+# of the packet, to test simple protocol scenarios. (e.g. generate simple
+# nsh packets to test nsh match fields/actions)
+#
+# Currently, the script supports sending the packets starting from the
+# Ethernet header. As a part of future enchancement, raw ip packet support
+# can also be added, and that's why there is "-t"/"--type" option
+#
+
+
+import socket
+import struct
+import sys
+from optparse import OptionParser
+
+
+usage = "usage: %prog [OPTIONS] OUT-INTERFACE HEX-BYTES \n \
+         bytes in HEX-BYTES must be separated by space(s)"
+parser = OptionParser(usage=usage)
+parser.add_option("-t", "--type", type="string", dest="packet_type",
+                  help="packet type ('eth' is the default PACKET_TYPE)",
+                  default="eth")
+
+(options, args) = parser.parse_args()
+
+# validate the arguments
+if len(args) < 2:
+    parser.print_help()
+    sys.exit(1)
+
+# validate the "-t" or "--type" option
+if options.packet_type != "eth":
+    parser.error('invalid argument to "-t"/"--type". Allowed value is "eth".')
+
+# store the hex bytes with 0x appended at the beginning
+# if not present in the user input and validate the hex bytes
+hex_list = []
+for a in args[1:]:
+    if a[:2] != "0x":
+        hex_byte = "0x" + a
+    else:
+        hex_byte = a
+    try:
+        temp = int(hex_byte, 0)
+    except:
+        parser.error("invalid hex byte " + a)
+
+    if temp > 0xff:
+        parser.error("hex byte " + a + " cannot be greater than 0xff!")
+
+    hex_list.append(temp)
+
+pkt = "".join(map(chr, hex_list))
+
+try:
+    sockfd = socket.socket(socket.AF_PACKET, socket.SOCK_RAW)
+except socket.error as msg:
+    print 'unable to create socket! error eode: ' + str(msg[0]) + ' : '\
+                                                                    + msg[1]
+    sys.exit(2)
+
+try:
+    sockfd.bind((args[0], 0))
+except socket.error as msg:
+    print 'unable to bind socket! error eode: ' + str(msg[0]) + ' : '\
+                                                                    + msg[1]
+    sys.exit(2)
+
+try:
+    sockfd.send(pkt)
+except socket.error as msg:
+    print 'unable to send packet! error eode: ' + str(msg[0]) + ' : '\
+                                                                    + msg[1]
+    sys.exit(2)
+
+print 'send success!'
+sys.exit(0)
diff --git a/tests/system-traffic.at b/tests/system-traffic.at
index 2afadec..58db095 100644
--- a/tests/system-traffic.at
+++ b/tests/system-traffic.at
@@ -4478,3 +4478,166 @@  NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING
 
 OVS_TRAFFIC_VSWITCHD_STOP
 AT_CLEANUP
+
+
+AT_BANNER([nsh-datapath])
+
+AT_SETUP([nsh - encap header])
+OVS_TRAFFIC_VSWITCHD_START()
+
+ADD_NAMESPACES(at_ns0, at_ns1)
+
+ADD_VETH(p0, at_ns0, br0, "0.0.0.0")
+ADD_VETH(p1, at_ns1, br0, "0.0.0.0")
+
+dnl The flow will encap a nsh header to the TCP syn packet
+dnl eth/ip/tcp --> OVS --> eth/nsh/eth/ip/tcp
+AT_CHECK([ovs-ofctl -Oopenflow13 add-flow br0 "table=0,priority=100,in_port=ovs-p0,ip,actions=encap(nsh(md_type=1)),set_field:0x1234->nsh_spi,set_field:0x11223344->nsh_c1,encap(ethernet),set_field:f2:ff:00:00:00:02->dl_dst,set_field:f2:ff:00:00:00:01->dl_src,ovs-p1"])
+
+rm ovs-p1.pcap
+tcpdump -U -i ovs-p1 -w ovs-p1.pcap &
+sleep 1
+
+dnl The hex dump is a TCP syn packet. pkt=eth/ip/tcp
+dnl The packet is sent from p0(at_ns0) interface directed to
+dnl p1(at_ns1) interface
+NS_CHECK_EXEC([at_ns0], [$PYTHON $srcdir/sendpkt.py p0 f2 00 00 00 00 02 f2 00 00 00 00 01 08 00 45 00 00 28 00 01 00 00 40 06 b0 13 c0 a8 00 0a 0a 00 00 0a 04 00 08 00 00 00 00 c8 00 00 00 00 50 02 20 00 b8 5e 00 00 > /dev/null])
+
+sleep 1
+
+dnl Check the expected nsh encapsulated packet on the egress interface
+AT_CHECK([tcpdump -xx -r ovs-p1.pcap 2>&1 | egrep "0x0000: *f2ff *0000 *0002 *f2ff *0000 *0001 *894f *0fc6" 2>&1 1>/dev/null])
+AT_CHECK([tcpdump -xx -r ovs-p1.pcap 2>&1 | egrep "0x0010: *0103 *0012 *34ff *1122 *3344 *0000 *0000 *0000" 2>&1 1>/dev/null])
+AT_CHECK([tcpdump -xx -r ovs-p1.pcap 2>&1 | egrep "0x0020: *0000 *0000 *0000 *f200 *0000 *0002 *f200 *0000" 2>&1 1>/dev/null])
+AT_CHECK([tcpdump -xx -r ovs-p1.pcap 2>&1 | egrep "0x0030: *0001 *0800 *4500 *0028 *0001 *0000 *4006 *b013" 2>&1 1>/dev/null])
+AT_CHECK([tcpdump -xx -r ovs-p1.pcap 2>&1 | egrep "0x0040: *c0a8 *000a *0a00 *000a *0400 *0800 *0000 *00c8" 2>&1 1>/dev/null])
+AT_CHECK([tcpdump -xx -r ovs-p1.pcap 2>&1 | egrep "0x0050: *0000 *0000 *5002 *2000 *b85e *0000" 2>&1 1>/dev/null])
+
+
+OVS_TRAFFIC_VSWITCHD_STOP
+AT_CLEANUP
+
+AT_SETUP([nsh - decap header])
+OVS_TRAFFIC_VSWITCHD_START()
+
+ADD_NAMESPACES(at_ns0, at_ns1)
+
+ADD_VETH(p0, at_ns0, br0, "0.0.0.0")
+ADD_VETH(p1, at_ns1, br0, "0.0.0.0")
+
+dnl The flow will decap a nsh header which in turn carries a TCP syn packet
+dnl eth/nsh/eth/ip/tcp --> OVS --> eth/ip/tcp
+AT_CHECK([ovs-ofctl -Oopenflow13 add-flow br0 "table=0,priority=100,in_port=ovs-p0,dl_type=0x894f, actions=decap(),decap(), ovs-p1"])
+
+rm ovs-p1.pcap
+tcpdump -U -i ovs-p1 -w ovs-p1.pcap &
+sleep 1
+
+dnl The hex dump is NSH packet with TCP syn payload. pkt=eth/nsh/eth/ip/tcp
+dnl The packet is sent from p0(at_ns0) interface directed to
+dnl p1(at_ns1) interface
+NS_CHECK_EXEC([at_ns0], [$PYTHON $srcdir/sendpkt.py p0 f2 ff 00 00 00 02 f2 ff 00 00 00 01 89 4f 02 06 01 03 00 00 64 03 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 f2 00 00 00 00 02 f2 00 00 00 00 01 08 00 45 00 00 28 00 01 00 00 40 06 b0 13 c0 a8 00 0a 0a 00 00 0a 04 00 08 00 00 00 00 c8 00 00 00 00 50 02 20 00 b8 5e 00 00 > /dev/null])
+
+sleep 1
+
+dnl Check the expected de-capsulated TCP packet on the egress interface
+AT_CHECK([tcpdump -xx -r ovs-p1.pcap 2>&1 | egrep "0x0000: *f200 *0000 *0002 *f200 *0000 *0001 *0800 *4500" 2>&1 1>/dev/null])
+AT_CHECK([tcpdump -xx -r ovs-p1.pcap 2>&1 | egrep "0x0010: *0028 *0001 *0000 *4006 *b013 *c0a8 *000a *0a00" 2>&1 1>/dev/null])
+AT_CHECK([tcpdump -xx -r ovs-p1.pcap 2>&1 | egrep "0x0020: *000a *0400 *0800 *0000 *00c8 *0000 *0000 *5002" 2>&1 1>/dev/null])
+AT_CHECK([tcpdump -xx -r ovs-p1.pcap 2>&1 | egrep "0x0030: *2000 *b85e *0000" 2>&1 1>/dev/null])
+
+
+OVS_TRAFFIC_VSWITCHD_STOP
+AT_CLEANUP
+
+AT_SETUP([nsh - replace header])
+OVS_TRAFFIC_VSWITCHD_START()
+
+ADD_NAMESPACES(at_ns0, at_ns1)
+
+ADD_VETH(p0, at_ns0, br0, "0.0.0.0")
+ADD_VETH(p1, at_ns1, br0, "0.0.0.0")
+
+dnl The flow will decap a nsh header and encap a new nsh header
+dnl eth/nsh-X/eth/ip/tcp --> OVS --> eth/nsh-Y/eth/ip/tcp
+dnl The flow will add another NSH header with nsh_spi=0x101, nsh_si=4,
+dnl nsh_ttl=7 and change the md1 context
+AT_CHECK([ovs-ofctl -Oopenflow13 add-flow br0 "table=0,priority=100,in_port=ovs-p0,dl_type=0x894f,nsh_spi=0x100,nsh_si=0x03,actions=decap(),decap(),encap(nsh(md_type=1)),set_field:0x07->nsh_ttl,set_field:0x0101->nsh_spi,set_field:0x04->nsh_si,set_field:0x100f0e0d->nsh_c1,set_field:0x0c0b0a09->nsh_c2,set_field:0x08070605->nsh_c3,set_field:0x04030201->nsh_c4,encap(ethernet),set_field:f2:ff:00:00:00:02->dl_dst,set_field:f2:ff:00:00:00:01->dl_src,ovs-p1"])
+
+rm ovs-p1.pcap
+tcpdump -U -i ovs-p1 -w ovs-p1.pcap &
+sleep 1
+
+dnl The hex dump is NSH packet with TCP syn payload. pkt=eth/nsh/eth/ip/tcp
+dnl The nsh_ttl is 8, nsh_spi is 0x100 and nsh_si is 3
+dnl The packet is sent from p0(at_ns0) interface directed to
+dnl p1(at_ns1) interface
+NS_CHECK_EXEC([at_ns0], [$PYTHON $srcdir/sendpkt.py p0 f2 ff 00 00 00 02 f2 ff 00 00 00 01 89 4f 02 06 01 03 00 01 00 03 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 f2 00 00 00 00 02 f2 00 00 00 00 01 08 00 45 00 00 28 00 01 00 00 40 06 b0 13 c0 a8 00 0a 0a 00 00 0a 04 00 08 00 00 00 00 c8 00 00 00 00 50 02 20 00 b8 5e 00 00 > /dev/null])
+
+sleep 1
+
+dnl Check the expected NSH packet with new fields in the header
+AT_CHECK([tcpdump -xx -r ovs-p1.pcap 2>&1 | egrep "0x0000: *f2ff *0000 *0002 *f2ff *0000* 0001 *894f *01c6" 2>&1 1>/dev/null])
+AT_CHECK([tcpdump -xx -r ovs-p1.pcap 2>&1 | egrep "0x0010: *0103 *0001 *0104 *100f *0e0d *0c0b *0a09 *0807" 2>&1 1>/dev/null])
+AT_CHECK([tcpdump -xx -r ovs-p1.pcap 2>&1 | egrep "0x0020: *0605 *0403 *0201 *f200 *0000 *0002 *f200 *0000" 2>&1 1>/dev/null])
+AT_CHECK([tcpdump -xx -r ovs-p1.pcap 2>&1 | egrep "0x0030: *0001 *0800 *4500 *0028 *0001 *0000 *4006 *b013" 2>&1 1>/dev/null])
+AT_CHECK([tcpdump -xx -r ovs-p1.pcap 2>&1 | egrep "0x0040: *c0a8 *000a *0a00 *000a *0400 *0800 *0000 *00c8" 2>&1 1>/dev/null])
+AT_CHECK([tcpdump -xx -r ovs-p1.pcap 2>&1 | egrep "0x0050: *0000 *0000 *5002 *2000 *b85e *0000" 2>&1 1>/dev/null])
+
+OVS_TRAFFIC_VSWITCHD_STOP
+AT_CLEANUP
+
+
+AT_SETUP([nsh - forward])
+OVS_TRAFFIC_VSWITCHD_START()
+
+ADD_NAMESPACES(at_ns0, at_ns1, at_ns2)
+
+ADD_VETH(p0, at_ns0, br0, "0.0.0.0")
+ADD_VETH(p1, at_ns1, br0, "0.0.0.0")
+ADD_VETH(p2, at_ns2, br0, "0.0.0.0")
+
+dnl Push two flows to OVS. #1 will check on SPI=0X100, SI=2 and send the
+dnl packet to at_ns1. #2 will check on SPI=0X100, SI=1 and send the
+dnl packet to to at_ns2.
+AT_CHECK([ovs-ofctl -Oopenflow13 add-flow br0 "table=0,priority=100,dl_type=0x894f,nsh_spi=0x100,nsh_si=0x02,actions=ovs-p1"])
+AT_CHECK([ovs-ofctl -Oopenflow13 add-flow br0 "table=0,priority=100,dl_type=0x894f,nsh_spi=0x100,nsh_si=0x01,actions=ovs-p2"])
+
+
+rm ovs-p1.pcap
+rm ovs-p2.pcap
+tcpdump -U -i ovs-p1 -w ovs-p1.pcap &
+tcpdump -U -i ovs-p2 -w ovs-p2.pcap &
+sleep 1
+
+dnl First send packet from at_ns0 --> OVS with SPI=0x100 and SI=2
+NS_CHECK_EXEC([at_ns0], [$PYTHON $srcdir/sendpkt.py p0 f2 ff 00 00 00 02 f2 ff 00 00 00 01 89 4f 02 06 01 03 00 01 00 02 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 f2 00 00 00 00 02 f2 00 00 00 00 01 08 00 45 00 00 28 00 01 00 00 40 06 b0 13 c0 a8 00 0a 0a 00 00 0a 04 00 08 00 00 00 00 c8 00 00 00 00 50 02 20 00 b8 5e 00 00 > /dev/null])
+
+sleep 1
+
+dnl Check for the above packet on ovs-p1 interface
+AT_CHECK([tcpdump -xx -r ovs-p1.pcap 2>&1 | egrep "0x0000: *f2ff *0000 *0002 *f2ff *0000 *0001 *894f *0206" 2>&1 1>/dev/null])
+AT_CHECK([tcpdump -xx -r ovs-p1.pcap 2>&1 | egrep "0x0010: *0103 *0001 *0002 *0102 *0304 *0506 *0708 *090a" 2>&1 1>/dev/null])
+AT_CHECK([tcpdump -xx -r ovs-p1.pcap 2>&1 | egrep "0x0020: *0b0c *0d0e *0f10 *f200 *0000 *0002 *f200 *0000" 2>&1 1>/dev/null])
+AT_CHECK([tcpdump -xx -r ovs-p1.pcap 2>&1 | egrep "0x0030: *0001 *0800 *4500 *0028 *0001 *0000 *4006 *b013" 2>&1 1>/dev/null])
+AT_CHECK([tcpdump -xx -r ovs-p1.pcap 2>&1 | egrep "0x0040: *c0a8 *000a *0a00 *000a *0400 *0800 *0000 *00c8" 2>&1 1>/dev/null])
+AT_CHECK([tcpdump -xx -r ovs-p1.pcap 2>&1 | egrep "0x0050: *0000 *0000 *5002 *2000 *b85e *0000" 2>&1 1>/dev/null])
+
+
+dnl Send the second packet from at_ns1 --> OVS with SPI=0x100 and SI=1
+NS_CHECK_EXEC([at_ns1], [$PYTHON $srcdir/sendpkt.py p1 f2 ff 00 00 00 02 f2 ff 00 00 00 01 89 4f 01 c6 01 03 00 01 00 01 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 f2 00 00 00 00 02 f2 00 00 00 00 01 08 00 45 00 00 28 00 01 00 00 40 06 b0 13 c0 a8 00 0a 0a 00 00 0a 04 00 08 00 00 00 00 c8 00 00 00 00 50 02 20 00 b8 5e 00 00 > /dev/null])
+
+sleep 1
+
+dnl Check for the above packet on ovs-p2 interface
+AT_CHECK([tcpdump -xx -r ovs-p2.pcap 2>&1 | egrep "0x0000: *f2ff *0000 *0002 *f2ff *0000 *0001 *894f *01c6" 2>&1 1>/dev/null])
+AT_CHECK([tcpdump -xx -r ovs-p2.pcap 2>&1 | egrep "0x0010: *0103 *0001 *0001 *0102 *0304 *0506 *0708 *090a" 2>&1 1>/dev/null])
+AT_CHECK([tcpdump -xx -r ovs-p2.pcap 2>&1 | egrep "0x0020: *0b0c *0d0e *0f10 *f200 *0000 *0002 *f200 *0000" 2>&1 1>/dev/null])
+AT_CHECK([tcpdump -xx -r ovs-p2.pcap 2>&1 | egrep "0x0030: *0001 *0800 *4500 *0028 *0001 *0000 *4006 *b013" 2>&1 1>/dev/null])
+AT_CHECK([tcpdump -xx -r ovs-p2.pcap 2>&1 | egrep "0x0040: *c0a8 *000a *0a00 *000a *0400 *0800 *0000 *00c8" 2>&1 1>/dev/null])
+AT_CHECK([tcpdump -xx -r ovs-p2.pcap 2>&1 | egrep "0x0050: *0000 *0000 *5002 *2000 *b85e *0000" 2>&1 1>/dev/null])
+
+
+
+OVS_TRAFFIC_VSWITCHD_STOP
+AT_CLEANUP