> The mfex pcap generation script is improved for varied length
> traffic and also removes the hard coded mfex_pcap and instead uses
> the script itself to generate complex traffic patterns for testing.
> 
> Signed-off-by: Kumar Amber <[email protected]>
> 

So in general I think this approach is a bit more improved.

@Phelan, Michael do you know if we currently run this testing in our CI? Also 
@Amber, Kumar et al, should the CI be expanded now to do both fuzzy and 
non-fuzzy testing as both seem to be an option now?

Regards
Ian

> ---
> v8:
> - Reduce IO writes.
> --
> ---
>  tests/automake.mk         |   1 -
>  tests/mfex_fuzzy.py       |  66 +++++++++++++++++++++++++++-----------
>  tests/pcap/mfex_test.pcap | Bin 416 -> 0 bytes
>  tests/system-dpdk.at      |  23 +++++++++----
>  4 files changed, 63 insertions(+), 27 deletions(-)
>  delete mode 100644 tests/pcap/mfex_test.pcap
> 
> diff --git a/tests/automake.mk b/tests/automake.mk
> index 8a9151f81..507da2ee8 100644
> --- a/tests/automake.mk
> +++ b/tests/automake.mk
> @@ -145,7 +145,6 @@ $(srcdir)/tests/fuzz-regression-list.at:
> tests/automake.mk
> 
>  EXTRA_DIST += $(MFEX_AUTOVALIDATOR_TESTS)
>  MFEX_AUTOVALIDATOR_TESTS = \
> -     tests/pcap/mfex_test.pcap \
>       tests/mfex_fuzzy.py
> 
>  OVSDB_CLUSTER_TESTSUITE_AT = \
> diff --git a/tests/mfex_fuzzy.py b/tests/mfex_fuzzy.py
> index 3efe1152d..dbde5fe1b 100755
> --- a/tests/mfex_fuzzy.py
> +++ b/tests/mfex_fuzzy.py
> @@ -3,30 +3,58 @@
>  import sys
> 
>  from scapy.all import RandMAC, RandIP, PcapWriter, RandIP6, RandShort, fuzz
> -from scapy.all import IPv6, Dot1Q, IP, Ether, UDP, TCP
> +from scapy.all import IPv6, Dot1Q, IP, Ether, UDP, TCP, random
> 
> +# Relative path for the pcap file location.
>  path = str(sys.argv[1]) + "/pcap/fuzzy.pcap"
> +# The number of packets generated will be size * 8.
> +size = int(sys.argv[2])
> +# Traffic option is used to choose between fuzzy or simple packet type.
> +traffic_opt = str(sys.argv[3])
> +
>  pktdump = PcapWriter(path, append=False, sync=True)
> 
> -for i in range(0, 2000):
> +pkt = []
> +
> +for i in range(0, size):
> 
> -    # Generate random protocol bases, use a fuzz() over the combined packet
> -    # for full fuzzing.
>      eth = Ether(src=RandMAC(), dst=RandMAC())
>      vlan = Dot1Q()
> -    ipv4 = IP(src=RandIP(), dst=RandIP())
> -    ipv6 = IPv6(src=RandIP6(), dst=RandIP6())
>      udp = UDP(dport=RandShort(), sport=RandShort())
> -    tcp = TCP(dport=RandShort(), sport=RandShort())
> -
> -    # IPv4 packets with fuzzing
> -    pktdump.write(fuzz(eth / ipv4 / udp))
> -    pktdump.write(fuzz(eth / ipv4 / tcp))
> -    pktdump.write(fuzz(eth / vlan / ipv4 / udp))
> -    pktdump.write(fuzz(eth / vlan / ipv4 / tcp))
> -
> -    # IPv6 packets with fuzzing
> -    pktdump.write(fuzz(eth / ipv6 / udp))
> -    pktdump.write(fuzz(eth / ipv6 / tcp))
> -    pktdump.write(fuzz(eth / vlan / ipv6 / udp))
> -    pktdump.write(fuzz(eth / vlan / ipv6 / tcp))
> +
> +    if traffic_opt == "fuzzy":
> +
> +        ipv4 = IP(src=RandIP(), dst=RandIP(), len=random.randint(0, 100))
> +        ipv6 = IPv6(src=RandIP6(), dst=RandIP6(), plen=random.randint(0, 
> 100))
> +        tcp = TCP(dport=RandShort(), sport=RandShort(), flags='S',
> +                  dataofs=random.randint(0, 20))
> +        # 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))
> +
> +        # 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))
> +
> +    else:
> +
> +        ipv4 = IP(src=RandIP(), dst=RandIP())
> +        ipv6 = IPv6(src=RandIP6(), dst=RandIP6())
> +        tcp = TCP(dport=RandShort(), sport=RandShort(), 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)
> +
> +        # IPv6 packets
> +        pkt.append(eth / ipv6 / udp)
> +        pkt.append(eth / ipv6 / tcp)
> +        pkt.append(eth / vlan / ipv6 / udp)
> +        pkt.append(eth / vlan / ipv6 / tcp)
> +
> +pktdump.write(pkt)
> diff --git a/tests/pcap/mfex_test.pcap b/tests/pcap/mfex_test.pcap
> deleted file mode 100644
> index
> 1aac67b8d643ecb016c758cba4cc32212a80f52a..0000000000000000000000000
> 000000000000000
> GIT binary patch
> literal 0
> HcmV?d00001
> 
> literal 416
> zcmca|c+)~A1{MYw`2U}Qff2}Q<eHVR>K`M68ITRa|G@yFii5$Gfk6YL%z>@uY&}o
> |
> z2s4N<1VH2&7y^V87$)XGOtD~MV$cFgfG~zBGGJ2#YtF$<F=a4i;9x8Q*<ZrSM6Uf
> z
> xK>KST_NTIwYriok6N4Vm)gX-
> Q@<yO<!C`>c^{cp<7_5LgK^UuU{2>VS0RZ!RQ+EIW
> 
> diff --git a/tests/system-dpdk.at b/tests/system-dpdk.at
> index 7d2715c4a..1476e470c 100644
> --- a/tests/system-dpdk.at
> +++ b/tests/system-dpdk.at
> @@ -226,12 +226,13 @@ dnl 
> -------------------------------------------------------------
> -------------
>  dnl Add standard DPDK PHY port
>  AT_SETUP([OVS-DPDK - MFEX Autovalidator])
>  AT_KEYWORDS([dpdk])
> -
> +AT_SKIP_IF([! $PYTHON3 -c "import scapy"], [], [])
> +AT_CHECK([$PYTHON3 $srcdir/mfex_fuzzy.py $srcdir 2000 0], [], [stdout])
>  OVS_DPDK_START()
> 
>  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_pcap1,rx_pcap=$srcdir/pcap/mfex_test.pcap,infinite_rx=1], [],
> [stdout], [stderr])
> +AT_CHECK([ovs-vsctl add-port br0 p1 -- set Interface p1 type=dpdk
> options:dpdk-
> devargs=net_pcap1,rx_pcap=$srcdir/pcap/fuzzy.pcap,infinite_rx=1], [], 
> [stdout],
> [stderr])
>  AT_CHECK([ovs-vsctl show], [], [stdout])
> 
>  AT_SKIP_IF([! ovs-appctl dpif-netdev/miniflow-parser-get | sed 1,4d | grep
> "True"], [], [dnl
> @@ -245,11 +246,15 @@ AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-
> set autovalidator], [0], [dnl
>  Miniflow extract implementation set to autovalidator.
>  ])
> 
> -OVS_WAIT_UNTIL([test `ovs-vsctl get interface p1 statistics | grep -oP
> 'rx_packets=\s*\K\d+'` -ge 1000])
> +OVS_WAIT_UNTIL([test `ovs-vsctl get interface p1 statistics | grep -oP
> 'rx_packets=\s*\K\d+'` -ge 16000])
> 
>  dnl Clean up
>  AT_CHECK([ovs-vsctl del-port br0 p1], [], [stdout], [stderr])
> -OVS_VSWITCHD_STOP("[SYSTEM_DPDK_ALLOWED_LOGS]")
> +OVS_VSWITCHD_STOP("m4_join([], [SYSTEM_DPDK_ALLOWED_LOGS], [
> +\@upcall: datapath reached the dynamic limit of .* flows.@d
> +\@received packet on unknown port .* on bridge br0 while processing@d
> +\@upcall_cb failure: ukey installation fails@d
> +])")
>  AT_CLEANUP
>  dnl 
> --------------------------------------------------------------------------
> 
> @@ -258,7 +263,7 @@ dnl Add standard DPDK PHY port
>  AT_SETUP([OVS-DPDK - MFEX Autovalidator Fuzzy])
>  AT_KEYWORDS([dpdk])
>  AT_SKIP_IF([! $PYTHON3 -c "import scapy"], [], [])
> -AT_CHECK([$PYTHON3 $srcdir/mfex_fuzzy.py $srcdir], [], [stdout])
> +AT_CHECK([$PYTHON3 $srcdir/mfex_fuzzy.py $srcdir 2000 fuzzy], [], [stdout])
>  OVS_DPDK_START()
> 
>  dnl Add userspace bridge and attach it to OVS
> @@ -277,12 +282,14 @@ AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-
> set autovalidator], [0], [dnl
>  Miniflow extract implementation set to autovalidator.
>  ])
> 
> -OVS_WAIT_UNTIL([test `ovs-vsctl get interface p1 statistics | grep -oP
> 'rx_packets=\s*\K\d+'` -ge 100000])
> +OVS_WAIT_UNTIL([test `ovs-vsctl get interface p1 statistics | grep -oP
> 'rx_packets=\s*\K\d+'` -ge 16000])
> 
>  dnl Clean up
>  AT_CHECK([ovs-vsctl del-port br0 p1], [], [stdout], [stderr])
>  OVS_VSWITCHD_STOP("m4_join([], [SYSTEM_DPDK_ALLOWED_LOGS], [
>  \@upcall: datapath reached the dynamic limit of .* flows.@d
> +\@received packet on unknown port .* on bridge br0 while processing@d
> +\@upcall_cb failure: ukey installation fails@d
>  ])")
>  AT_CLEANUP
>  dnl 
> --------------------------------------------------------------------------
> @@ -290,11 +297,13 @@ dnl 
> -------------------------------------------------------------
> -------------
>  dnl 
> --------------------------------------------------------------------------
>  AT_SETUP([OVS-DPDK - MFEX Configuration])
>  AT_KEYWORDS([dpdk])
> +AT_SKIP_IF([! $PYTHON3 -c "import scapy"], [], [])
> +AT_CHECK([$PYTHON3 $srcdir/mfex_fuzzy.py $srcdir 1 fuzzy], [], [stdout])
>  OVS_DPDK_START()
>  AT_CHECK([ovs-vsctl --no-wait set Open_vSwitch . other_config:pmd-cpu-
> mask=0xC])
>  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_pcap1,rx_pcap=$srcdir/pcap/mfex_test.pcap,infinite_rx=1], [],
> [stdout], [stderr])
> +AT_CHECK([ovs-vsctl add-port br0 p1 -- set Interface p1 type=dpdk
> options:dpdk-
> devargs=net_pcap1,rx_pcap=$srcdir/pcap/fuzzy.pcap,infinite_rx=1], [], 
> [stdout],
> [stderr])
>  AT_CHECK([ovs-vsctl show], [], [stdout])
> 
>  AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set scalar 1], [2],
> --
> 2.25.1

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to