On 11 May 2022, at 18:28, Kumar Amber wrote:

> 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.

I did not follow the discussion around the fuzzy testing being part of the unit 
tests, so I’ll only express my concerns below.

> Signed-off-by: Kumar Amber <kumar.am...@intel.com>
> Acked-by: Cian Ferriter <cian.ferri...@intel.com>
>
> ---
> v2:
> - Add huge page test-skip.
> - Change core id to 3 to 0 to allow the mfex config test-case
>   to run on any system.
> ---
> ---
>  tests/automake.mk         |   1 -
>  tests/mfex_fuzzy.py       |  66 +++++++++++++++++++++++++++-----------
>  tests/pcap/mfex_test.pcap | Bin 416 -> 0 bytes
>  tests/system-dpdk.at      |  44 +++++++++++++++++--------
>  4 files changed, 77 insertions(+), 34 deletions(-)
>  delete mode 100644 tests/pcap/mfex_test.pcap
>
> diff --git a/tests/automake.mk b/tests/automake.mk
> index 34ddda6aa..204e86fac 100644
> --- a/tests/automake.mk
> +++ b/tests/automake.mk
> @@ -146,7 +146,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])

Think here we should check for the existence of sys.argv[3], and if not just 
initialize traffic_opt as “” so we do not have to supply a dummy “0” option.

> +
>  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))

dataof is 4 bits, why go to 20? Do we want more of the lower values?

> +        # 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

The thing I do not like about creating a random dynamic file is that it will be 
hard to reproduce. If someone reports a failure and we do not have the pcap 
file it might be hard to reproduce. Is there a specific reason for using random 
Mac/ip/ports? Can we use a fixed range for non-fuzz testing?

> deleted file mode 100644
> index 
> 1aac67b8d643ecb016c758cba4cc32212a80f52a..0000000000000000000000000000000000000000
> 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*<ZrSM6Ufz
> 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..27ba42954 100644
> --- a/tests/system-dpdk.at
> +++ b/tests/system-dpdk.at
> @@ -226,12 +226,14 @@ dnl 
> --------------------------------------------------------------------------
>  dnl Add standard DPDK PHY port
>  AT_SETUP([OVS-DPDK - MFEX Autovalidator])
>  AT_KEYWORDS([dpdk])
> -
> +OVS_DPDK_PRE_CHECK()
> +AT_SKIP_IF([! $PYTHON3 -c "import scapy"], [], [])
> +AT_CHECK([$PYTHON3 $srcdir/mfex_fuzzy.py $srcdir 2000 0], [], [stdout])

See the comment above, we could remove the 0 here.

>  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

Can we hustle this code around a bit, because else we wait a long time 
generating the pcap file if we do not need this (also for the fuzzy test 
below). Something like:

diff --git a/tests/system-dpdk.at b/tests/system-dpdk.at
index 27ba42954..a6447ecc4 100644
--- a/tests/system-dpdk.at
+++ b/tests/system-dpdk.at
@@ -227,18 +227,19 @@ dnl Add standard DPDK PHY port
 AT_SETUP([OVS-DPDK - MFEX Autovalidator])
 AT_KEYWORDS([dpdk])
 OVS_DPDK_PRE_CHECK()
+OVS_DPDK_START()
+
+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 $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/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
-])
-
 AT_CHECK([ovs-appctl dpif-netdev/dpif-impl-set dpif_avx512], [0], [dnl
 DPIF implementation set to dpif_avx512.
 ])
@@ -264,18 +265,19 @@ dnl Add standard DPDK PHY port
 AT_SETUP([OVS-DPDK - MFEX Autovalidator Fuzzy])
 AT_KEYWORDS([dpdk])
 OVS_DPDK_PRE_CHECK()
+OVS_DPDK_START()
+
+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 $srcdir 2000 fuzzy], [], [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/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
-])
-
 AT_CHECK([ovs-appctl dpif-netdev/dpif-impl-set dpif_avx512], [0], [dnl
 DPIF implementation set to dpif_avx512.
 ])

> @@ -245,11 +247,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 
> --------------------------------------------------------------------------
>
> @@ -257,8 +263,9 @@ dnl 
> --------------------------------------------------------------------------
>  dnl Add standard DPDK PHY port
>  AT_SETUP([OVS-DPDK - MFEX Autovalidator Fuzzy])
>  AT_KEYWORDS([dpdk])
> +OVS_DPDK_PRE_CHECK()
>  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 +284,18 @@ 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
> +\@Unreasonably long .* poll interval@d
> +\@context switches: .* voluntary, .* involuntary@d
> +\@faults: .* minor, .* major@d
> +\@upcall_cb failure: ukey installation fails@d

There was some discussion about adding these in the past with Ilya if I 
remember correctly? Was this settled, and ACKed?

>  ])")
>  AT_CLEANUP
>  dnl 
> --------------------------------------------------------------------------
> @@ -290,11 +303,14 @@ dnl 
> --------------------------------------------------------------------------
>  dnl 
> --------------------------------------------------------------------------
>  AT_SETUP([OVS-DPDK - MFEX Configuration])
>  AT_KEYWORDS([dpdk])
> +OVS_DPDK_PRE_CHECK()
> +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])
> +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_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],
> @@ -339,12 +355,12 @@ Error: invalid study_pkt_cnt value: abcd.
>  ovs-appctl: ovs-vswitchd: server returned an error
>  ])
>
> -AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set -pmd 3 study], [0], [dnl
> -Miniflow extract implementation set to study, on pmd thread 3, studying 128 
> packets.
> +AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set -pmd 0 study], [0], [dnl
> +Miniflow extract implementation set to study, on pmd thread 0, studying 128 
> packets.
>  ])
>
> -AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set -pmd 3 study 512], [0], 
> [dnl
> -Miniflow extract implementation set to study, on pmd thread 3, studying 512 
> packets.
> +AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set -pmd 0 study 512], [0], 
> [dnl
> +Miniflow extract implementation set to study, on pmd thread 0, studying 512 
> packets.
>  ])
>
>  AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set study 512], [0], [dnl
> @@ -355,8 +371,8 @@ AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set 
> study], [0], [dnl
>  Miniflow extract implementation set to study, studying 128 packets.
>  ])
>
> -AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set -pmd 3 autovalidator], 
> [0], [dnl
> -Miniflow extract implementation set to autovalidator, on pmd thread 3.
> +AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set -pmd 0 autovalidator], 
> [0], [dnl
> +Miniflow extract implementation set to autovalidator, on pmd thread 0.
>  ])
>
>  AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set -pmd zero study], [2],
> -- 
> 2.25.1

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to