selftests/net: various
Subsystems (3)
cover selftests/net: various
From: Willem de Bruijn <[email protected]>
A few odds and ends to network tests:
- msg_zerocopy: run as part of kselftest
- udp gso: add missing bounds test for minimal sizes
- psocket_snd: initial basic conformance test
Willem de Bruijn (3):
selftests/net: enable msg_zerocopy test selftests/net: udpgso: test small gso_size boundary conditions selftests/net: add packet socket packet_snd test
tools/testing/selftests/net/.gitignore | 1 + tools/testing/selftests/net/Makefile | 4 +- tools/testing/selftests/net/msg_zerocopy.sh | 8 + tools/testing/selftests/net/psock_snd.c | 398 ++++++++++++++++++++ tools/testing/selftests/net/psock_snd.sh | 98 +++++ tools/testing/selftests/net/udpgso.c | 77 +++- 6 files changed, 582 insertions(+), 4 deletions(-) create mode 100644 tools/testing/selftests/net/psock_snd.c create mode 100755 tools/testing/selftests/net/psock_snd.sh
Signature · 1 line
2.17.0.921.gf22659ad46-goog
PATCH 1/3 selftests/net: enable msg_zerocopy test
From: Willem de Bruijn <[email protected]>
The existing msg_zerocopy test takes additional protocol arguments. Add a variant that takes no arguments and runs all supported variants. Call this from kselftest.
--- tools/testing/selftests/net/Makefile | 2 +- tools/testing/selftests/net/msg_zerocopy.sh | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-)
tools/testing/selftests/net/Makefile +1 -1
@@ -6,7 +6,7 @@ CFLAGS += -I../../../../usr/include/ TEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh netdevice.sh rtnetlink.sh TEST_PROGS += fib_tests.sh fib-onlink-tests.sh pmtu.sh udpgso.sh -TEST_PROGS += udpgso_bench.sh fib_rule_tests.sh +TEST_PROGS += udpgso_bench.sh fib_rule_tests.sh msg_zerocopy.sh TEST_PROGS_EXTENDED := in_netns.sh TEST_GEN_FILES = socket TEST_GEN_FILES += psock_fanout psock_tpacket msg_zerocopy
tools/testing/selftests/net/msg_zerocopy.sh +8 -0
@@ -21,6 +21,14 @@ readonly DADDR6='fd::2' readonly path_sysctl_mem="net.core.optmem_max" +# No arguments: automated test +if [[ "$#" -eq "0" ]]; then + $0 4 tcp -t 1 + $0 6 tcp -t 1 + echo "OK. All tests passed" + exit 0 +fi + # Argument parsing if [[ "$#" -lt "2" ]]; then echo "Usage: $0 [4|6] [tcp|udp|raw|raw_hdrincl|packet|packet_dgram] <args>"
Signature · 1 line
2.17.0.921.gf22659ad46-goog
PATCH 2/3 selftests/net: udpgso: test small gso_size boundary conditions
In reply to Willem de BruijnFrom: Willem de Bruijn <[email protected]>
Verify that udpgso can generate segments smaller than device mtu, down to the extreme case of 1B gso_size.
Verify that irrespective of gso_size, udpgso restricts the number of segments it will generate per call (UDP_MAX_SEGMENTS).
--- tools/testing/selftests/net/udpgso.c | 77 +++++++++++++++++++++++++++- 1 file changed, 75 insertions(+), 2 deletions(-)
tools/testing/selftests/net/udpgso.c +75 -2
@@ -34,6 +34,10 @@#define UDP_SEGMENT 103#endif +#ifndef UDP_MAX_SEGMENTS +#define UDP_MAX_SEGMENTS (1 << 6UL) +#endif +#define CONST_MTU_TEST 1500#define CONST_HDRLEN_V4 (sizeof(struct iphdr) + sizeof(struct udphdr))
@@ -135,6 +139,38 @@ struct testcase testcases_v4[] = { .gso_len = CONST_MSS_V4, .tfail = true, }, + { + /* send a single 1B MSS: will fail, see single MSS above */ + .tlen = 1, + .gso_len = 1, + .tfail = true, + .r_num_mss = 1, + }, + { + /* send 2 1B segments */ + .tlen = 2, + .gso_len = 1, + .r_num_mss = 2, + }, + { + /* send 2B + 2B + 1B segments */ + .tlen = 5, + .gso_len = 2, + .r_num_mss = 2, + .r_len_last = 1, + }, + { + /* send max number of min sized segments */ + .tlen = UDP_MAX_SEGMENTS - CONST_HDRLEN_V4, + .gso_len = 1, + .r_num_mss = UDP_MAX_SEGMENTS - CONST_HDRLEN_V4, + }, + { + /* send max number + 1 of min sized segments: fail */ + .tlen = UDP_MAX_SEGMENTS - CONST_HDRLEN_V4 + 1, + .gso_len = 1, + .tfail = true, + }, { /* EOL */ }
@@ -210,6 +246,38 @@ struct testcase testcases_v6[] = { .gso_len = CONST_MSS_V6, .tfail = true, }, + { + /* send a single 1B MSS: will fail, see single MSS above */ + .tlen = 1, + .gso_len = 1, + .tfail = true, + .r_num_mss = 1, + }, + { + /* send 2 1B segments */ + .tlen = 2, + .gso_len = 1, + .r_num_mss = 2, + }, + { + /* send 2B + 2B + 1B segments */ + .tlen = 5, + .gso_len = 2, + .r_num_mss = 2, + .r_len_last = 1, + }, + { + /* send max number of min sized segments */ + .tlen = UDP_MAX_SEGMENTS - CONST_HDRLEN_V6, + .gso_len = 1, + .r_num_mss = UDP_MAX_SEGMENTS - CONST_HDRLEN_V6, + }, + { + /* send max number + 1 of min sized segments: fail */ + .tlen = UDP_MAX_SEGMENTS - CONST_HDRLEN_V6 + 1, + .gso_len = 1, + .tfail = true, + }, { /* EOL */ }
@@ -375,7 +443,8 @@ static bool __send_one(int fd, struct msghdr *msg, int flags)int ret; ret =sendmsg (fd, msg, flags); -if (ret ==-1 && (errno ==EMSGSIZE || errno ==ENOMEM )) +if (ret ==-1 && + (errno ==EMSGSIZE || errno ==ENOMEM || errno ==EINVAL ))return false;if (ret ==-1 )error (1 , errno,"sendmsg" );
@@ -466,7 +535,11 @@ static void run_one(struct testcase *test, int fdt, int fdr,if (!sent)return ; - mss = addr->sa_family ==AF_INET ?CONST_MSS_V4 :CONST_MSS_V6 ; +if (test->gso_len) + mss = test->gso_len; +else + mss = addr->sa_family ==AF_INET ?CONST_MSS_V4 :CONST_MSS_V6 ; +/* Recv all full MSS datagrams */ for (i =0 ; i < test->r_num_mss; i++) {
Signature · 1 line
2.17.0.921.gf22659ad46-goog
PATCH 3/3 selftests/net: add packet socket packet_snd test
In reply to Willem de BruijnFrom: Willem de Bruijn <[email protected]>
Add regression tests for PF_PACKET transmission using packet_snd.
The TPACKET ring interface has tests for transmission and reception. This is an initial stab at the same for the send call based interface.
Packets are sent over loopback, then read twice. The entire packet is read from another packet socket and compared. The packet is also verified to arrive at a UDP socket for protocol conformance.
The test sends a packet over loopback, testing the following options (not the full cross-product):
- SOCK_DGRAM
- SOCK_RAW
- vlan tag
- qdisc bypass
- bind() and sendto()
- virtio_net_hdr
- csum offload (NOT actual csum feature, ignored on loopback)
- gso
Besides these basic functionality tests, the test runs from a set of bounds checks, positive and negative. Running over loopback, which has dev->min_header_len, it cannot generate variable length hhlen.
--- tools/testing/selftests/net/.gitignore | 1 + tools/testing/selftests/net/Makefile | 4 +- tools/testing/selftests/net/psock_snd.c | 398 +++++++++++++++++++++++ tools/testing/selftests/net/psock_snd.sh | 98 ++++++ 4 files changed, 499 insertions(+), 2 deletions(-) create mode 100644 tools/testing/selftests/net/psock_snd.c create mode 100755 tools/testing/selftests/net/psock_snd.sh
tools/testing/selftests/net/.gitignore +1 -0
@@ -1,6 +1,7 @@ msg_zerocopy socket psock_fanout +psock_snd psock_tpacket reuseport_bpf reuseport_bpf_cpu
tools/testing/selftests/net/Makefile +2 -2
@@ -6,11 +6,11 @@ CFLAGS += -I../../../../usr/include/ TEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh netdevice.sh rtnetlink.sh TEST_PROGS += fib_tests.sh fib-onlink-tests.sh pmtu.sh udpgso.sh -TEST_PROGS += udpgso_bench.sh fib_rule_tests.sh msg_zerocopy.sh +TEST_PROGS += udpgso_bench.sh fib_rule_tests.sh msg_zerocopy.sh psock_snd.sh TEST_PROGS_EXTENDED := in_netns.sh TEST_GEN_FILES = socket TEST_GEN_FILES += psock_fanout psock_tpacket msg_zerocopy -TEST_GEN_FILES += tcp_mmap tcp_inq +TEST_GEN_FILES += tcp_mmap tcp_inq psock_snd TEST_GEN_FILES += udpgso udpgso_bench_tx udpgso_bench_rx TEST_GEN_PROGS = reuseport_bpf reuseport_bpf_cpu reuseport_bpf_numa TEST_GEN_PROGS += reuseport_dualstack reuseaddr_conflict
tools/testing/selftests/net/psock_snd.c new file +398 -0
398 lines not on this page · raw message
tools/testing/selftests/net/psock_snd.sh new file +98 -0
98 lines not on this page · raw message
Signature · 1 line
2.17.0.921.gf22659ad46-goog
David Miller
maintainerFrom: Willem de Bruijn <[email protected]>
Date: Thu, 31 May 2018 12:14:37 -0400
Quoted 7 lines
From: Willem de Bruijn <[email protected]>
A few odds and ends to network tests:
-
msg_zerocopy: run as part of kselftest
- udp gso: add missing bounds test for minimal sizes
-psocket_snd: initial basic conformance test
Always great to see new tests.
Series applied, thanks Willem.