summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/net/run_afpackettests
diff options
context:
space:
mode:
authorWillem de Bruijn <willemb@google.com>2018-02-23 11:56:20 -0500
committerDavid S. Miller <davem@davemloft.net>2018-02-23 12:47:05 -0500
commitcc30c93fa020e13c91f5076e20062df33f944cdc (patch)
tree1b07db1361638f8bb6731c194b791faa18801e30 /tools/testing/selftests/net/run_afpackettests
parent3c69f79233e7c8424abb38bbd0ae9fd9010014af (diff)
selftests/net: ignore background traffic in psock_fanout
The packet fanout test generates UDP traffic and reads this with a pair of packet sockets, testing the various fanout algorithms. Avoid non-determinism from reading unrelated background traffic. Fanout decisions are made before unrelated packets can be dropped with a filter, so that is an insufficient strategy [*]. Run the packet socket tests in a network namespace, similar to msg_zerocopy. It it still good practice to install a filter on a packet socket before accepting traffic. Because this is example code, demonstrate that pattern. Open the socket initially bound to no protocol, install a filter, and only then bind to ETH_P_IP. Another source of non-determinism is hash collisions in FANOUT_HASH. The hash function used to select a socket in the fanout group includes the pseudorandom number hashrnd, which is not visible from userspace. To work around this, the test tries to find a pair of UDP source ports that do not collide. It gives up too soon (5 times, every 32 runs) and output is confusing. Increase tries to 20 and revise the error msg. [*] another approach would be to add a third socket to the fanout group and direct all unexpected traffic here. This is possible only when reimplementing methods like RR or HASH alongside this extra catch-all bucket, using the BPF fanout method. Signed-off-by: Willem de Bruijn <willemb@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/testing/selftests/net/run_afpackettests')
-rwxr-xr-xtools/testing/selftests/net/run_afpackettests4
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/testing/selftests/net/run_afpackettests b/tools/testing/selftests/net/run_afpackettests
index 21fe149e3de1..bea079edc278 100755
--- a/tools/testing/selftests/net/run_afpackettests
+++ b/tools/testing/selftests/net/run_afpackettests
@@ -9,7 +9,7 @@ fi
echo "--------------------"
echo "running psock_fanout test"
echo "--------------------"
-./psock_fanout
+./in_netns.sh ./psock_fanout
if [ $? -ne 0 ]; then
echo "[FAIL]"
else
@@ -19,7 +19,7 @@ fi
echo "--------------------"
echo "running psock_tpacket test"
echo "--------------------"
-./psock_tpacket
+./in_netns.sh ./psock_tpacket
if [ $? -ne 0 ]; then
echo "[FAIL]"
else