linux/tools/testing/selftests/net
Willem de Bruijn cc30c93fa0 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>
2018-02-23 12:47:05 -05:00
..
.gitignore selftest: add a reuseaddr test 2017-09-19 14:09:26 -06:00
config selftests: net: Adding config fragment CONFIG_NUMA=y 2017-12-20 14:25:34 -05:00
fib_tests.sh selftests: fib_tests: sleep after changing carrier 2018-02-13 14:34:28 -05:00
fib-onlink-tests.sh selftests: Add FIB onlink tests 2018-02-13 14:47:33 -05:00
in_netns.sh selftests/net: ignore background traffic in psock_fanout 2018-02-23 12:47:05 -05:00
Makefile selftests: fib_tests: Add test cases for IPv4/IPv6 FIB 2018-01-07 21:29:41 -05:00
msg_zerocopy.c selftests/net: add zerocopy support for PF_RDS test case 2018-02-16 16:04:17 -05:00
msg_zerocopy.sh test: add msg_zerocopy test 2017-08-03 21:37:30 -07:00
netdevice.sh License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
psock_fanout.c selftests/net: ignore background traffic in psock_fanout 2018-02-23 12:47:05 -05:00
psock_lib.h selftests/net: Fixes psock_fanout CBPF test case 2017-04-20 15:39:19 -04:00
psock_tpacket.c tools: psock_tpacket: block Rx until socket filter has been added and socket has been bound to loopback. 2017-01-05 15:03:41 -05:00
reuseaddr_conflict.c selftest: add a reuseaddr test 2017-09-19 14:09:26 -06:00
reuseport_bpf_cpu.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
reuseport_bpf_numa.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
reuseport_bpf.c bpf: fix rlimit in reuseport net selftest 2018-02-09 14:46:37 -05:00
reuseport_dualstack.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
rtnetlink.sh selftests: rtnetlink: add erspan and ip6erspan 2018-01-02 13:37:42 -05:00
run_afpackettests selftests/net: ignore background traffic in psock_fanout 2018-02-23 12:47:05 -05:00
run_netsocktests License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
socket.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
test_bpf.sh License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00