diff mbox series

[ovs-dev,02/13] tests: Use fmt_pkt in 3 HVs, 1 LS, 3 lports/HV.

Message ID 20231010203400.1045353-3-mmichels@redhat.com
State Changes Requested
Headers show
Series tests: 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 Oct. 10, 2023, 8:33 p.m. UTC
This only uses fmt_pkt in test_arp(). test_packet() purposely sends
packets with odd and/or malformed ethertypes, which makes it a poor fit
for fmt_pkt(). We could use some sort of raw packet method of scapy, but
that seems like a roundabout way of getting what we already have in the
test.

Execution time: 10.313s
Execution time on "main" branch: 8.575s

Signed-off-by: Mark Michelson <mmichels@redhat.com>
---
 tests/ovn.at | 32 +++++++++++++++++---------------
 1 file changed, 17 insertions(+), 15 deletions(-)
diff mbox series

Patch

diff --git a/tests/ovn.at b/tests/ovn.at
index 3f00829ff..a8c483098 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -2474,7 +2474,8 @@  test_packet() {
 # SPA and TPA are each 8 hex digits.
 test_arp() {
     local inport=$1 sha=$2 spa=$3 tpa=$4 reply_ha=$5
-    local request=ffffffffffff${sha}08060001080006040001${sha}${spa}ffffffffffff${tpa}
+    local request=$(fmt_pkt "Ether(dst='ff:ff:ff:ff:ff:ff', src='${sha}')/ \
+                             ARP(hwsrc='${sha}', hwdst='ff:ff:ff:ff:ff:ff', psrc='${spa}', pdst='${tpa}')")
     hv=`vif_to_hv $inport`
     as $hv ovs-appctl netdev-dummy/receive vif$inport $request
 
@@ -2491,7 +2492,8 @@  test_arp() {
         done
     else
         # Expect to receive the reply, if any.
-        local reply=${sha}${reply_ha}08060001080006040002${reply_ha}${tpa}${sha}${spa}
+        local reply=$(fmt_pkt "Ether(dst='${sha}', src='${reply_ha}') /
+                               ARP(op=2, hwsrc='${reply_ha}', hwdst='${sha}', psrc='${tpa}', pdst='${spa}')")
         echo $reply >> $inport.expected
     fi
 }
@@ -2579,23 +2581,23 @@  for is in 1 2 3; do
                 bacl2="$bacl2 $acl2"
                 bacl3="$bacl3 $acl3"
 
-                sip=`ip_to_hex 192 168 0 $is$js`
-                tip=`ip_to_hex 192 168 0 $id$jd`
-                tip_unknown=`ip_to_hex 11 11 11 11`
+                sip="192.168.0.$is$js"
+                tip="192.168.0.$id$jd"
+                tip_unknown="11.11.11.11"
                 reply_ha=;
                 if test $d != $s; then
                     if test $jd != 1; then
-                        reply_ha=f000000000$d
+                        reply_ha="f0:00:00:00:00:$d"
                     fi
                 fi
 
-                test_arp $s f000000000$s $sip $tip $reply_ha               #9
-                test_arp $s f000000000$s $sip $tip_unknown                 #10
+                test_arp $s f0:00:00:00:00:$s $sip $tip $reply_ha               #9
+                test_arp $s f0:00:00:00:00:$s $sip $tip_unknown                 #10
 
                 if test $jd = 3; then
                     # lsp[123]3 has an additional ip 192.169.0.[123]3.
-                    tip=`ip_to_hex 192 169 0 $id$jd`
-                    test_arp $s f000000000$s $sip $tip $reply_ha           #9
+                    tip="192.169.0.$id$jd"
+                    test_arp $s f0:00:00:00:00:$s $sip $tip $reply_ha           #9
                 fi
             done
         done
@@ -2625,13 +2627,13 @@  done
 # lp13 should be configured with only 192.168.0.13.
 check ovn-nbctl --wait=hv lsp-set-addresses lp13 "f0:00:00:00:00:13 192.168.0.13 invalid 192.169.0.13"
 
-sip=`ip_to_hex 192 168 0 11`
-tip=`ip_to_hex 192 168 0 13`
-test_arp 11 f00000000011  $sip $tip f00000000013
+sip="192.168.0.11"
+tip="192.168.0.13"
+test_arp 11 f0:00:00:00:00:11  $sip $tip f0:00:00:00:00:13
 
-tip=`ip_to_hex 192 169 0 13`
+tip="192.169.0.13"
 #arp request for 192.169.0.13 should be flooded
-test_arp 11 f00000000011  $sip $tip
+test_arp 11 f0:00:00:00:00:11  $sip $tip
 
 # dump information and flows with counters
 ovn-sbctl dump-flows -- list multicast_group > sbflows