mirror of
https://github.com/openvswitch/ovs
synced 2025-09-01 14:55:18 +00:00
test/sytem-dpdk: Add unit test for mfex autovalidator
Tests: 6: OVS-DPDK - MFEX Autovalidator 7: OVS-DPDK - MFEX Autovalidator Fuzzy 8: OVS-DPDK - MFEX Configuration Added a new directory to store the PCAP file used in the tests and a script to generate the fuzzy traffic type pcap to be used in fuzzy unit test. Signed-off-by: Kumar Amber <kumar.amber@intel.com> Acked-by: Flavio Leitner <fbl@sysclose.org> Acked-by: Flavio Leitner <fbl@sysclose.org> Acked-by: Eelco Chaudron <echaudro@redhat.com> Signed-off-by: Ian Stokes <ian.stokes@intel.com>
This commit is contained in:
@@ -346,3 +346,59 @@ A compile time option is available in order to test it with the OVS unit
|
||||
test suite. Use the following configure option ::
|
||||
|
||||
$ ./configure --enable-mfex-default-autovalidator
|
||||
|
||||
Unit Test Miniflow Extract
|
||||
++++++++++++++++++++++++++
|
||||
|
||||
Unit test can also be used to test the workflow mentioned above by running
|
||||
the following test-case in tests/system-dpdk.at ::
|
||||
|
||||
make check-dpdk TESTSUITEFLAGS='-k MFEX'
|
||||
OVS-DPDK - MFEX Autovalidator
|
||||
|
||||
The unit test uses mulitple traffic type to test the correctness of the
|
||||
implementaions.
|
||||
|
||||
The MFEX commands can also be tested for negative and positive cases to
|
||||
verify that the MFEX set command does not allow for incorrect parameters.
|
||||
A user can directly run the following configuration test case in
|
||||
tests/system-dpdk.at ::
|
||||
|
||||
make check-dpdk TESTSUITEFLAGS='-k MFEX'
|
||||
OVS-DPDK - MFEX Configuration
|
||||
|
||||
Running Fuzzy test with Autovalidator
|
||||
+++++++++++++++++++++++++++++++++++++
|
||||
|
||||
Fuzzy tests can also be done on miniflow extract with the help of
|
||||
auto-validator and Scapy. The steps below describes the steps to
|
||||
reproduce the setup with IP being fuzzed to generate packets.
|
||||
|
||||
Scapy is used to create fuzzy IP packets and save them into a PCAP ::
|
||||
|
||||
pkt = fuzz(Ether()/IP()/TCP())
|
||||
|
||||
Set the miniflow extract to autovalidator using ::
|
||||
|
||||
$ ovs-appctl dpif-netdev/miniflow-parser-set autovalidator
|
||||
|
||||
OVS is configured to receive the generated packets ::
|
||||
|
||||
$ ovs-vsctl add-port br0 pcap0 -- \
|
||||
set Interface pcap0 type=dpdk options:dpdk-devargs=net_pcap0
|
||||
"rx_pcap=fuzzy.pcap"
|
||||
|
||||
With this workflow, the autovalidator will ensure that all MFEX
|
||||
implementations are classifying each packet in exactly the same way.
|
||||
If an optimized MFEX implementation causes a different miniflow to be
|
||||
generated, the autovalidator has ovs_assert and logging statements that
|
||||
will inform about the issue.
|
||||
|
||||
Unit Fuzzy test with Autovalidator
|
||||
+++++++++++++++++++++++++++++++++++++
|
||||
|
||||
Unit test can also be used to test the workflow mentioned above by running
|
||||
the following test-case in tests/system-dpdk.at ::
|
||||
|
||||
make check-dpdk TESTSUITEFLAGS='-k MFEX'
|
||||
OVS-DPDK - MFEX Autovalidator Fuzzy
|
||||
|
1
tests/.gitignore
vendored
1
tests/.gitignore
vendored
@@ -11,6 +11,7 @@
|
||||
/ovsdb-cluster-testsuite
|
||||
/ovsdb-cluster-testsuite.dir/
|
||||
/ovsdb-cluster-testsuite.log
|
||||
/pcap/
|
||||
/pki/
|
||||
/system-afxdp-testsuite
|
||||
/system-afxdp-testsuite.dir/
|
||||
|
@@ -143,6 +143,11 @@ $(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/pcap/mfex_test.pcap \
|
||||
tests/mfex_fuzzy.py
|
||||
|
||||
OVSDB_CLUSTER_TESTSUITE_AT = \
|
||||
tests/ovsdb-cluster-testsuite.at \
|
||||
tests/ovsdb-execution.at \
|
||||
@@ -512,6 +517,7 @@ tests_test_type_props_SOURCES = tests/test-type-props.c
|
||||
CHECK_PYFILES = \
|
||||
tests/appctl.py \
|
||||
tests/flowgen.py \
|
||||
tests/mfex_fuzzy.py \
|
||||
tests/ovsdb-monitor-sort.py \
|
||||
tests/test-daemon.py \
|
||||
tests/test-json.py \
|
||||
|
33
tests/mfex_fuzzy.py
Executable file
33
tests/mfex_fuzzy.py
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/python3
|
||||
try:
|
||||
from scapy.all import RandMAC, RandIP, PcapWriter, RandIP6, RandShort, fuzz
|
||||
from scapy.all import IPv6, Dot1Q, IP, Ether, UDP, TCP
|
||||
except ModuleNotFoundError as err:
|
||||
print(err + ": Scapy")
|
||||
import sys
|
||||
|
||||
path = str(sys.argv[1]) + "/pcap/fuzzy.pcap"
|
||||
pktdump = PcapWriter(path, append=False, sync=True)
|
||||
|
||||
for i in range(0, 2000):
|
||||
|
||||
# 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))
|
BIN
tests/pcap/mfex_test.pcap
Normal file
BIN
tests/pcap/mfex_test.pcap
Normal file
Binary file not shown.
@@ -232,3 +232,163 @@ OVS_VSWITCHD_STOP(["\@does not exist. The Open vSwitch kernel module is probably
|
||||
\@EAL: No free hugepages reported in hugepages-1048576kB@d"])
|
||||
AT_CLEANUP
|
||||
dnl --------------------------------------------------------------------------
|
||||
|
||||
dnl --------------------------------------------------------------------------
|
||||
dnl Add standard DPDK PHY port
|
||||
AT_SETUP([OVS-DPDK - MFEX Autovalidator])
|
||||
AT_KEYWORDS([dpdk])
|
||||
|
||||
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 show], [], [stdout])
|
||||
|
||||
AT_SKIP_IF([! ovs-appctl dpif-netdev/miniflow-parser-get | sed 1,4d | grep "True"], [], [dnl
|
||||
])
|
||||
|
||||
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])
|
||||
|
||||
dnl Clean up
|
||||
AT_CHECK([ovs-vsctl del-port br0 p1], [], [stdout], [stderr])
|
||||
AT_CLEANUP
|
||||
dnl --------------------------------------------------------------------------
|
||||
|
||||
dnl --------------------------------------------------------------------------
|
||||
dnl Add standard DPDK PHY port
|
||||
AT_SETUP([OVS-DPDK - MFEX Autovalidator Fuzzy])
|
||||
AT_KEYWORDS([dpdk])
|
||||
AT_SKIP_IF([! pip3 list | grep scapy], [], [])
|
||||
AT_CHECK([$PYTHON3 $srcdir/mfex_fuzzy.py $srcdir], [], [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/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])
|
||||
|
||||
dnl Clean up
|
||||
AT_CHECK([ovs-vsctl del-port br0 p1], [], [stdout], [stderr])
|
||||
AT_CLEANUP
|
||||
dnl --------------------------------------------------------------------------
|
||||
|
||||
dnl --------------------------------------------------------------------------
|
||||
AT_SETUP([OVS-DPDK - MFEX Configuration])
|
||||
AT_KEYWORDS([dpdk])
|
||||
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 show], [], [stdout])
|
||||
|
||||
AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set scalar 1], [2],
|
||||
[], [dnl
|
||||
Error: unknown argument 1.
|
||||
ovs-appctl: ovs-vswitchd: server returned an error
|
||||
])
|
||||
|
||||
AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set -pmd 6 study 300 xyz], [2],
|
||||
[], [dnl
|
||||
Error: invalid study_pkt_cnt value: xyz.
|
||||
ovs-appctl: ovs-vswitchd: server returned an error
|
||||
])
|
||||
|
||||
AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set scalar abcd], [2],
|
||||
[], [dnl
|
||||
Error: unknown argument abcd.
|
||||
ovs-appctl: ovs-vswitchd: server returned an error
|
||||
])
|
||||
|
||||
AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set -pmd 0 scalar abcd], [2],
|
||||
[], [dnl
|
||||
Error: unknown argument abcd.
|
||||
ovs-appctl: ovs-vswitchd: server returned an error
|
||||
])
|
||||
|
||||
AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set -pmd], [2],
|
||||
[], [dnl
|
||||
Error: -pmd option requires a thread id argument.
|
||||
ovs-appctl: ovs-vswitchd: server returned an error
|
||||
])
|
||||
|
||||
AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set tudy abcd], [2],
|
||||
[], [dnl
|
||||
Error: unknown argument abcd.
|
||||
ovs-appctl: ovs-vswitchd: server returned an error
|
||||
])
|
||||
|
||||
AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set -pmd 7 study abcd], [2],
|
||||
[], [dnl
|
||||
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 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 study 512], [0], [dnl
|
||||
Miniflow extract implementation set to study, studying 512 packets.
|
||||
])
|
||||
|
||||
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 zero study], [2],
|
||||
[], [dnl
|
||||
Error: miniflow extract parser not changed, PMD thread passed is not valid: 'zero'. Pass a valid pmd thread ID.
|
||||
ovs-appctl: ovs-vswitchd: server returned an error
|
||||
])
|
||||
|
||||
AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set -pmd 1], [2],
|
||||
[], [dnl
|
||||
Error: no miniflow extract name provided. Output of miniflow-parser-get shows implementation list.
|
||||
ovs-appctl: ovs-vswitchd: server returned an error
|
||||
])
|
||||
|
||||
AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set -pmd 1 superstudy], [2],
|
||||
[], [dnl
|
||||
Error: unknown miniflow extract implementation superstudy.
|
||||
ovs-appctl: ovs-vswitchd: server returned an error
|
||||
])
|
||||
|
||||
AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set superstudy], [2],
|
||||
[], [dnl
|
||||
Error: unknown miniflow extract implementation superstudy.
|
||||
ovs-appctl: ovs-vswitchd: server returned an error
|
||||
])
|
||||
|
||||
AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set -pmd 1 study -pmd], [2],
|
||||
[], [dnl
|
||||
Error: invalid study_pkt_cnt value: -pmd.
|
||||
ovs-appctl: ovs-vswitchd: server returned an error
|
||||
])
|
||||
|
||||
dnl Clean up
|
||||
AT_CHECK([ovs-vsctl del-port br0 p1], [], [stdout], [stderr])
|
||||
AT_CLEANUP dnl
|
||||
dnl --------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user