]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
selftests/net: ignore background traffic in psock_fanout
authorWillem de Bruijn <willemb@google.com>
Thu, 16 Jan 2020 04:36:29 +0000 (12:36 +0800)
committerKhalid Elmously <khalid.elmously@canonical.com>
Wed, 29 Jan 2020 02:37:38 +0000 (21:37 -0500)
commitcd9117c91386c02277d6fb619cb788eece6f9a70
tree3eabe4d670016b14cc435c44f249333de867cbec
parent762e67b65488edbb648379ff81b3f3486e63f245
selftests/net: ignore background traffic in psock_fanout

BugLink: https://bugs.launchpad.net/bugs/1853375
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>
(cherry picked from commit cc30c93fa020e13c91f5076e20062df33f944cdc)
Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
Acked-by: Connor Kuehl <connor.kuehl@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
tools/testing/selftests/net/in_netns.sh [new file with mode: 0755]
tools/testing/selftests/net/psock_fanout.c
tools/testing/selftests/net/run_afpackettests