selftests: net: add test for ipv6 fragmentation
Subsystems (3)
PATCH v6 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 review.
v6 changes:
- port -> network byte order
- remove unecessary variable err
- check return value of close()
v5 changes:
- disable_dad: delete - not needed for lo
- main: simplify failure paths
- main: char -> static char buf
- setup: remove pointless return value
- setup: remove unused variable fd
- setup: merge with interface_up() to simplify
- setup: check all system call return values
- remove no longer used headers
v4 changes:
- fix "else should follow close brace" (checkpatch ERROR)
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
v5: https://lore.kernel.org/netdev/[email protected]
v4: https://lore.kernel.org/netdev/[email protected]
v3: https://lore.kernel.org/netdev/[email protected]
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 | 114 ++++++++++++++++++ 3 files changed, 116 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 +114 -0
114 lines not on this page · raw message
base-commit: cd8a4cfa6bb43a441901e82f5c222dddc75a18a3
Signature · 1 line
2.49.1
This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Quoted 9 lines · On Wed, 3 Sep 2025 15:46:01 +0000 you wrote:
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).[...]
Here is the summary with links:
- [net-next,v6] selftests: net: add test for ipv6 fragmentation
https://git.kernel.org/netdev/net-next/c/aeb8d48ea92e
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html