diff --git a/tests/automake.mk b/tests/automake.mk index f8a925012d6..2ae0aeecaff 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -146,10 +146,6 @@ $(srcdir)/tests/fuzz-regression-list.at: tests/automake.mk echo "TEST_FUZZ_REGRESSION([$$basename])"; \ done > $@.tmp && mv $@.tmp $@ -EXTRA_DIST += $(MFEX_AUTOVALIDATOR_TESTS) -MFEX_AUTOVALIDATOR_TESTS = \ - tests/mfex_fuzzy.py - OVSDB_CLUSTER_TESTSUITE_AT = \ tests/ovsdb-cluster-testsuite.at \ tests/ovsdb-execution.at \ @@ -522,7 +518,7 @@ tests_test_type_props_SOURCES = tests/test-type-props.c CHECK_PYFILES = \ tests/appctl.py \ tests/flowgen.py \ - tests/mfex_fuzzy.py \ + tests/genpkts.py \ tests/ovsdb-monitor-sort.py \ tests/test-daemon.py \ tests/test-dpparse.py \ diff --git a/tests/mfex_fuzzy.py b/tests/genpkts.py similarity index 66% rename from tests/mfex_fuzzy.py rename to tests/genpkts.py index 50b9870641d..3354e116d0c 100755 --- a/tests/mfex_fuzzy.py +++ b/tests/genpkts.py @@ -17,51 +17,44 @@ from scapy.all import RandMAC, RandIP, PcapWriter, RandIP6, RandShort, fuzz from scapy.all import IPv6, Dot1Q, IP, Ether, UDP, TCP, random -# Path for the pcap file location. -path = str(sys.argv[1]) # The number of packets generated will be size * 8. -size = int(sys.argv[2]) +size = int(sys.argv[1]) # Traffic option is used to choose between fuzzy or simple packet type. -if len(sys.argv) > 3: - traffic_opt = str(sys.argv[3]) +if len(sys.argv) > 2: + traffic_opt = str(sys.argv[2]) else: traffic_opt = "" -pktdump = PcapWriter(path, append=False, sync=True) - -pkt = [] - for i in range(0, size): + pkt = [] + if traffic_opt == "fuzzy": eth = Ether(src=RandMAC(), dst=RandMAC()) vlan = Dot1Q() - udp = UDP(dport=RandShort(), sport=RandShort()) ipv4 = IP(src=RandIP(), dst=RandIP(), len=random.randint(0, 100)) ipv6 = IPv6(src=RandIP6(), dst=RandIP6(), plen=random.randint(0, 100)) + udp = UDP(dport=RandShort(), sport=RandShort()) tcp = TCP(dport=RandShort(), sport=RandShort(), flags='S', dataofs=random.randint(0, 15)) # IPv4 packets with fuzzing - pkt.append(fuzz(eth / ipv4 / udp)) - pkt.append(fuzz(eth / ipv4 / tcp)) - pkt.append(fuzz(eth / vlan / ipv4 / udp)) - pkt.append(fuzz(eth / vlan / ipv4 / tcp)) + pkt.append(fuzz(eth / ipv4 / udp).build().hex()) + pkt.append(fuzz(eth / ipv4 / tcp).build().hex()) + pkt.append(fuzz(eth / vlan / ipv4 / udp).build().hex()) + pkt.append(fuzz(eth / vlan / ipv4 / tcp).build().hex()) # IPv6 packets with fuzzing - pkt.append(fuzz(eth / ipv6 / udp)) - pkt.append(fuzz(eth / ipv6 / tcp)) - pkt.append(fuzz(eth / vlan / ipv6 / udp)) - pkt.append(fuzz(eth / vlan / ipv6 / tcp)) + pkt.append(fuzz(eth / ipv6 / udp).build().hex()) + pkt.append(fuzz(eth / ipv6 / tcp).build().hex()) + pkt.append(fuzz(eth / vlan / ipv6 / udp).build().hex()) + pkt.append(fuzz(eth / vlan / ipv6 / tcp).build().hex()) else: mac_addr_src = "52:54:00:FF:FF:{:02X}".format(i % 0xff) mac_addr_dst = "80:FF:FF:FF:FF:{:02X}".format(i % 0xff) - src_port = 200 + (i % 20) - dst_port = 1000 + (i % 20) eth = Ether(src=mac_addr_src, dst=mac_addr_dst) vlan = Dot1Q(vlan=(i % 10)) - udp = UDP(dport=src_port, sport=dst_port) # IPv4 address range limits to 255 and IPv6 limit to 65535 ipv4_addr_src = "192.168.150." + str((i % 255)) ipv4_addr_dst = "200.100.198." + str((i % 255)) @@ -71,18 +64,21 @@ .format(i % 0xffff) ipv4 = IP(src=ipv4_addr_src, dst=ipv4_addr_dst) ipv6 = IPv6(src=ipv6_addr_src, dst=ipv6_addr_dst) + src_port = 200 + (i % 20) + dst_port = 1000 + (i % 20) + udp = UDP(dport=src_port, sport=dst_port) tcp = TCP(dport=src_port, sport=dst_port, flags='S') # IPv4 packets - pkt.append(eth / ipv4 / udp) - pkt.append(eth / ipv4 / tcp) - pkt.append(eth / vlan / ipv4 / udp) - pkt.append(eth / vlan / ipv4 / tcp) + pkt.append((eth / ipv4 / udp).build().hex()) + pkt.append((eth / ipv4 / tcp).build().hex()) + pkt.append((eth / vlan / ipv4 / udp).build().hex()) + pkt.append((eth / vlan / ipv4 / tcp).build().hex()) # IPv6 packets - pkt.append(eth / ipv6 / udp) - pkt.append(eth / ipv6 / tcp) - pkt.append(eth / vlan / ipv6 / udp) - pkt.append(eth / vlan / ipv6 / tcp) + pkt.append((eth / ipv6 / udp).build().hex()) + pkt.append((eth / ipv6 / tcp).build().hex()) + pkt.append((eth / vlan / ipv6 / udp).build().hex()) + pkt.append((eth / vlan / ipv6 / tcp).build().hex()) -pktdump.write(pkt) + print(' '.join(pkt)) diff --git a/tests/system-dpdk.at b/tests/system-dpdk.at index d19062d987e..ab72860a639 100644 --- a/tests/system-dpdk.at +++ b/tests/system-dpdk.at @@ -821,16 +821,16 @@ AT_SETUP([OVS-DPDK - MFEX Autovalidator]) AT_KEYWORDS([dpdk]) OVS_CHECK_GITHUB_ACTION() OVS_DPDK_PRE_CHECK() -OVS_DPDK_START([--no-pci]) +OVS_DPDK_START([--no-pci], [--enable-dummy]) AT_CHECK([ovs-vsctl add-br br0 -- set bridge br0 datapath_type=netdev]) AT_SKIP_IF([! ovs-appctl dpif-netdev/miniflow-parser-get | sed 1,4d | grep "True"], [], [dnl ]) AT_SKIP_IF([! $PYTHON3 -c "import scapy"], [], []) -AT_CHECK([$PYTHON3 $srcdir/mfex_fuzzy.py test_traffic.pcap 2000], [], [stdout]) +AT_SKIP_IF([! $PYTHON3 $srcdir/genpkts.py 2000 > packets]) dnl Add userspace bridge and attach it to OVS -AT_CHECK([ovs-vsctl add-port br0 p1 -- set Interface p1 type=dpdk options:dpdk-devargs=net_pcap1,rx_pcap=test_traffic.pcap,infinite_rx=1], [], [stdout], [stderr]) +AT_CHECK([ovs-vsctl add-port br0 p1 -- set Interface p1 type=dummy-pmd]) AT_CHECK([ovs-vsctl show], [], [stdout]) AT_CHECK([ovs-appctl dpif-netdev/dpif-impl-set dpif_avx512], [0], [dnl @@ -841,6 +841,10 @@ AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set autovalidator], [0], [dnl Miniflow extract implementation set to autovalidator. ]) +cat packets | while read line; do + AT_CHECK([ovs-appctl netdev-dummy/receive p1 $line], [0], [ignore]) +done + OVS_WAIT_UNTIL([test `ovs-vsctl get interface p1 statistics | grep -oP 'rx_packets=\s*\K\d+'` -ge 16000]) dnl Clean up @@ -855,16 +859,16 @@ AT_SETUP([OVS-DPDK - MFEX Autovalidator Fuzzy]) AT_KEYWORDS([dpdk]) OVS_CHECK_GITHUB_ACTION() OVS_DPDK_PRE_CHECK() -OVS_DPDK_START([--no-pci]) +OVS_DPDK_START([--no-pci], [--enable-dummy]) AT_CHECK([ovs-vsctl add-br br0 -- set bridge br0 datapath_type=netdev]) AT_SKIP_IF([! ovs-appctl dpif-netdev/miniflow-parser-get | sed 1,4d | grep "True"], [], [dnl ]) AT_SKIP_IF([! $PYTHON3 -c "import scapy"], [], []) -AT_CHECK([$PYTHON3 $srcdir/mfex_fuzzy.py fuzzy.pcap 2000 fuzzy], [], [stdout]) +AT_SKIP_IF([! $PYTHON3 $srcdir/genpkts.py 2000 fuzzy > packets]) dnl Add userspace bridge and attach it to OVS -AT_CHECK([ovs-vsctl add-port br0 p1 -- set Interface p1 type=dpdk options:dpdk-devargs=net_pcap1,rx_pcap=fuzzy.pcap,infinite_rx=1], [], [stdout], [stderr]) +AT_CHECK([ovs-vsctl add-port br0 p1 -- set Interface p1 type=dummy-pmd]) AT_CHECK([ovs-vsctl show], [], [stdout]) AT_CHECK([ovs-appctl dpif-netdev/dpif-impl-set dpif_avx512], [0], [dnl @@ -875,6 +879,10 @@ AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set autovalidator], [0], [dnl Miniflow extract implementation set to autovalidator. ]) +cat packets | while read line; do + AT_CHECK([ovs-appctl netdev-dummy/receive p1 $line], [0], [ignore]) +done + OVS_WAIT_UNTIL([test `ovs-vsctl get interface p1 statistics | grep -oP 'rx_packets=\s*\K\d+'` -ge 16000]) dnl Clean up @@ -888,11 +896,11 @@ dnl -------------------------------------------------------------------------- AT_SETUP([OVS-DPDK - MFEX Configuration]) AT_KEYWORDS([dpdk]) OVS_DPDK_PRE_CHECK() -OVS_DPDK_START([--no-pci]) +OVS_DPDK_START([--no-pci], [--enable-dummy]) AT_CHECK([ovs-vsctl --no-wait set Open_vSwitch . other_config:pmd-cpu-mask=0x1]) dnl Add userspace bridge and attach it to OVS AT_CHECK([ovs-vsctl add-br br0 -- set bridge br0 datapath_type=netdev]) -AT_CHECK([ovs-vsctl add-port br0 p1 -- set Interface p1 type=dpdk options:dpdk-devargs=net_null0,no-rx=1], [], [stdout], [stderr]) +AT_CHECK([ovs-vsctl add-port br0 p1 -- set Interface p1 type=dummy-pmd]) AT_CHECK([ovs-vsctl show], [], [stdout]) AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set scalar 1], [2],