selftests: net: add test for ipv6 fragmentation
Subsystems (3)
PATCH v3 1/1 selftests: net: add test for ipv6 fragmentation
Add selftest for the IPv6 fragmentation regression which affected several stable kernels.
Commit a18dfa9925b9 ("ipv6: save dontfrag in cork") was backported to stable without some prerequisite commits. This caused a regression when sending IPv6 UDP packets by preventing fragmentation and instead returning -1 (EMSGSIZE).
Add selftest to check for this issue by attempting to send a packet larger than the interface MTU. The packet will be fragmented on a working kernel, with sendmsg(2) correctly returning the expected number of bytes sent. When the regression is present, sendmsg returns -1 and sets errno to EMSGSIZE.
---
Thanks again Willem for the prompt review. I've incorporated your suggested changes into v3.
v3 changes:
- add usleep instead of busy polling on sendmsg
- simplify error handling by using error() and leaving cleanup to O/S
- use loopback interface - don't bother creating TAP
- send to localhost (::1)
v2 changes:
- remove superfluous namespace calls - unshare(2) suffices
- remove usleep(). Don't wait for the interface to be ready, just send, and handle the (less likely) error case by retrying.
- set destination address only once
- document our use of the IPv6 link-local source address
- send to port 9 (DISCARD) instead of 4242 (DONT PANIC)
- ensure sockets are closed on failure paths
- use KSFT exit codes for clarity
v2: https://lore.kernel.org/netdev/[email protected]
v1: https://lore.kernel.org/netdev/[email protected]
tools/testing/selftests/net/.gitignore | 1 + tools/testing/selftests/net/Makefile | 1 + .../selftests/net/ipv6_fragmentation.c | 145 ++++++++++++++++++ 3 files changed, 147 insertions(+) create mode 100644 tools/testing/selftests/net/ipv6_fragmentation.c
tools/testing/selftests/net/.gitignore +1 -0
@@ -16,6 +16,7 @@ ip_local_port_range ipsec ipv6_flowlabel ipv6_flowlabel_mgr +ipv6_fragmentation log.txt msg_oob msg_zerocopy
tools/testing/selftests/net/Makefile +1 -0
@@ -117,6 +117,7 @@ TEST_GEN_FILES += tfo TEST_PROGS += tfo_passive.sh TEST_PROGS += broadcast_pmtu.sh TEST_PROGS += ipv6_force_forwarding.sh +TEST_GEN_PROGS += ipv6_fragmentation TEST_PROGS += route_hint.sh # YNL files, must be before "include ..lib.mk"
tools/testing/selftests/net/ipv6_fragmentation.c new file +145 -0
145 lines not on this page · raw message
base-commit: 864ecc4a6dade82d3f70eab43dad0e277aa6fc78
Signature · 1 line
2.49.1