These tests contain plain hex dumps that are hard to read and modify.
Replace with equivalent calls to ovs-ofctl compose-packet --bare and
ovs-pcap.
Tcpdump calls modified to write actual pcaps instead of text output,
so ovs-pcap can be used while checking the results.
While at it, replacing sleeps with more robust waiting for tcpdump
to start listening.
M4 macros are better than shell variables, because we can see the
substitution result in the test log. So, using m4_define and m4_join
extensively.
Signed-off-by: Ilya Maximets
---
tests/system-traffic.at | 233 ++--
1 file changed, 152 insertions(+), 81 deletions(-)
diff --git a/tests/system-traffic.at b/tests/system-traffic.at
index bd7647cbe..c4cebb0a3 100644
--- a/tests/system-traffic.at
+++ b/tests/system-traffic.at
@@ -2390,11 +2390,22 @@ table=20 actions=drop
AT_CHECK([ovs-ofctl del-flows br0])
AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
+m4_define([ND_NS_PKT], [m4_join([,],
+ [eth_src=36:b1:ee:7c:01:03,eth_dst=36:b1:ee:7c:01:02,eth_type=0x86dd],
+ [ipv6_src=fe80::f816:3eff:fe04:6604,ipv6_dst=fe80::f816:3eff:fea7:dd0e],
+ [nw_proto=58,nw_ttl=255,nw_frag=no],
+ [icmpv6_type=136,icmpv6_code=0],
+ [nd_options_type=2,nd_tll=36:b1:ee:7c:01:03])])
+
dnl Send a mismatching neighbor discovery.
-NS_CHECK_EXEC([at_ns0], [$PYTHON3 $srcdir/sendpkt.py p0 36 b1 ee 7c 01 02 36
b1 ee 7c 01 03 86 dd 60 00 00 00 00 20 3a ff fe 80 00 00 00 00 00 00 f8 16 3e
ff fe 04 66 04 fe 80 00 00 00 00 00 00 f8 16 3e ff fe a7 dd 0e 88 00 f1 f2 20
00 00 00 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 02 01 36 b1 ee 7c 01
03 > /dev/null])
+NS_CHECK_EXEC([at_ns0], [$PYTHON3 $srcdir/sendpkt.py p0 \
+$(ovs-ofctl compose-packet --bare 'ND_NS_PKT,nd_target=3000::1')],
+ [0], [ignore])
dnl Send a matching neighbor discovery.
-NS_CHECK_EXEC([at_ns0], [$PYTHON3 $srcdir/sendpkt.py p0 36 b1 ee 7c 01 02 36
b1 ee 7c 01 03 86 dd 60 00 00 00 00 20 3a ff fe 80 00 00 00 00 00 00 f8 16 3e
ff fe 04 66 04 fe 80 00 00 00 00 00 00 f8 16 3e ff fe a7 dd 0e 88 00 fe 5f 20
00 00 00 20 01 00 00 00 00 00 00 00 00 00 01 00 00 03 92 02 01 36 b1 ee 7c 01
03 > /dev/null])
+NS_CHECK_EXEC([at_ns0], [$PYTHON3 $srcdir/sendpkt.py p0 \
+$(ovs-ofctl compose-packet --bare 'ND_NS_PKT,nd_target=2001::1:0:392')],
+ [0], [ignore])
AT_CHECK([ovs-appctl dpctl/dump-flows | strip_stats | strip_used | dnl
strip_key32 | strip_ptype | strip_eth | strip_recirc | dnl
@@ -2406,10 +2417,14 @@
recirc_id(),in_port(2),eth_type(0x86dd),ipv6(proto=58,frag=no),icmpv6(ty
OVS_WAIT_UNTIL([ovs-appctl dpctl/dump-flows | grep ",nd" | wc -l | grep -E ^0])
dnl Send a matching neighbor discovery.
-NS_CHECK_EXEC([at_ns0], [$PYTHON3 $srcdir/sendpkt.py p0 36 b1 ee 7c 01 02 36
b1 ee 7c 01 03 86 dd 60 00 00 00 00 20 3a ff fe 80 00 00 00 00 00 00 f8 16 3e
ff fe 04 66 04 fe 80 00 00 00 00 00 00 f8 16 3e ff fe a7 dd 0e 88 00 fe 5f 20
00 00 00 20 01 00 00 00 00 00 00 00 00 00 01 00 00 03 92 02 01 36 b1 ee 7c 01
03 > /dev/null])
+NS_CHECK_EXEC([at_ns0], [$PYTHON3 $srcdir/sendpkt.py p0 \
+$(ovs-ofctl compose-packet --bare 'ND_NS_PKT,nd_target=2001::1:0:392')],
+ [0], [ignore])
dnl Send a mismatching neighbor discovery.
-NS_CHECK_EXEC([at_ns0], [$PYTHON3 $srcdir/sendpkt.py p0 36 b1 ee 7c 01 02 36
b1 ee 7c 01 03 86 dd 60 00 00 00 00 20 3a ff fe 80 00 00 00 00 00 00 f8 16 3e
ff fe 04 66 04 fe 80 00 00 00 00 00 00 f8 16 3e ff fe a7 dd 0e 88 00 f1 f2 20
00 00 00 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 02 01 36 b1 ee 7c 01
03 > /dev/null])
+NS_CHECK_EXEC([at_ns0], [$PYTHON3 $srcdir/sendpkt.py p0 \
+$(ovs-ofctl compose-packet --bare 'ND_NS_PKT,nd_target=3000::1')],
+ [0], [ignore])
AT_CHECK([ovs-appctl dpctl/dump-flows | strip_stats | strip_used | dnl
strip_key32 | strip_ptype | strip_eth | strip_recirc | dnl
@@ -2438,20 +2453,29 @@ dnl The flow will encap a mpls header to the ip packet
dnl eth/ip/icmp --> OVS --> eth/mpls/eth/ip/icmp
AT_CHECK([ovs-ofctl -Oopenflow13 add-flow br0
"table=0,priority=100,dl_type=0x0800
actions=encap(mpls),set_mpls_label:2,encap(ethernet),set_field:00:00:00:00:00:02->dl_dst,set_field:00:00:00:00:00:01->dl_src,ovs-p1"])
-rm -rf p1.pcap
-NETNS_DAEMONIZE([at_ns1], [tcpdump -l -n -xx -U -i p1 > p1.pcap],
[tcpdump.pid])
-sleep 1
+NETNS_DAEMONIZE([at_ns1],
+ [tcpdump -l -n -xx -U -i p1 -w p1.pcap 2>tcpdump_err], [tcpdump.pid])
+OVS_WAIT_UNTIL([grep "listening" tcpdump_err])
+
+m4_define([ICMP_PKT], [m4_join([,],
+ [eth_src=36:b1:ee:7c:01:03,eth_dst=36:b1:ee:7c:01:02,eth_type=0x0800],
+ [nw_src=10.1.1.1,nw_dst=10.1.1.2],
+ [nw_proto=1,nw_ttl=64,nw_frag=no],
+ [icmp_type=8,icmp_code=0])])
-dnl The hex dump is a icmp packet. pkt=eth/ip/icmp
dnl The packet is sent from p0(at_ns0) interface directed to
-dnl p1(at_ns1) interface
-NS_CHECK_EXEC([at_ns0], [$PYTHON3 $srcdir/sendpkt.py p0 36 b1 ee 7c 01 02 36
b1 ee 7c 01 03 08 00 45 00 00 54 03 44 40 00 40 01 21 61 0a 01 01 01 0a 01 01
02