diff mbox series

[ovs-dev,v2,04/13] tests: Use fmt_pkt in VLAN transparency, ...

Message ID 20231114205417.175004-5-mmichels@redhat.com
State Accepted
Headers show
Series Convert some tests to use fmt_pkt. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/github-robot-_ovn-kubernetes success github build: passed

Commit Message

Mark Michelson Nov. 14, 2023, 8:54 p.m. UTC
...passthru=true, ND/NA responder disabled.

Note that in order to be able to get the solicited node multicast
address, we need access to the socket library. This commit imports the
socket library from python. To reduce the amount of text in OVN test
cases, we import *.

Execution time: 2.290s
Execution time on "main" branch: 1.157s

Signed-off-by: Mark Michelson <mmichels@redhat.com>
---
 tests/ovn.at          | 18 +++++++++++-------
 tests/scapy-server.py |  1 +
 2 files changed, 12 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/tests/ovn.at b/tests/ovn.at
index 1f96f2091..e49baa7e4 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -3734,6 +3734,7 @@  AT_CLEANUP
 
 OVN_FOR_EACH_NORTHD([
 AT_SETUP([VLAN transparency, passthru=true, ND/NA responder disabled])
+AT_SKIP_IF([test $HAVE_SCAPY = no])
 ovn_start
 
 net_add net
@@ -3766,22 +3767,25 @@  AT_CHECK([grep -w "ls_in_arp_rsp" lsflows | sed 's/table=../table=??/' | sort],
 
 test_nd_na() {
     local inport=$1 outport=$2 sha=$3 spa=$4 tpa=$5 reply_ha=$6
-    tag=8100fefe
-    icmp_type=87
-    local request=ffffffffffff${sha}${tag}86dd6000000000183aff${spa}ff0200000000000000000001ff${tpa: -6}${icmp_type}007ea100000000${tpa}
+    local request=$(fmt_pkt "Ether(dst='ff:ff:ff:ff:ff:ff', src='${sha}')/ \
+                             Dot1Q(vlan=0xefe)/ \
+                             IPv6(src='${spa}', dst=inet_ntop(AF_INET6, in6_getnsma(inet_pton(AF_INET6, '${tpa}'))))/ \
+                             ICMPv6ND_NS(tgt='${tpa}')")
     ovs-appctl netdev-dummy/receive vif$inport $request
     echo $request >> $outport.expected
     echo $request
 
-    icmp_type=88
-    local reply=${sha}${reply_ha}${tag}86dd6000000000183aff${tpa}${spa}${icmp_type}003da540000000${tpa}
+    local reply=$(fmt_pkt "Ether(dst='${sha}', src='${reply_ha}')/ \
+                           Dot1Q(vlan=0xefe)/ \
+                           IPv6(src='${tpa}', dst='${spa}')/ \
+                           ICMPv6ND_NA(tgt='${tpa}')")
     ovs-appctl netdev-dummy/receive vif$outport $reply
     echo $reply >> $inport.expected
     echo $reply
 }
 
-test_nd_na 1 2 f00000000001 fe000000000000000000000000000001 fe000000000000000000000000000002 f00000000002
-test_nd_na 2 1 f00000000002 fe000000000000000000000000000002 fe000000000000000000000000000001 f00000000001
+test_nd_na 1 2 f0:00:00:00:00:01 fe00::1 fe00::2 f0:00:00:00:00:02
+test_nd_na 2 1 f0:00:00:00:00:02 fe00::2 fe00::1 f0:00:00:00:00:01
 
 for i in 1 2; do
     OVN_CHECK_PACKETS([vif$i-tx.pcap], [$i.expected])
diff --git a/tests/scapy-server.py b/tests/scapy-server.py
index a7255c84d..bd1c1cffe 100755
--- a/tests/scapy-server.py
+++ b/tests/scapy-server.py
@@ -7,6 +7,7 @@  import ovs.unixctl
 import ovs.unixctl.server
 
 import binascii
+from socket import *  # noqa: F401,F403
 from scapy.all import *  # noqa: F401,F403
 from scapy.all import raw