tcpip: fix IP_MTU_DISCOVER for locally-originated packets - #14143
Open
Ar1es-XD wants to merge 1 commit into
Open
tcpip: fix IP_MTU_DISCOVER for locally-originated packets#14143Ar1es-XD wants to merge 1 commit into
Ar1es-XD wants to merge 1 commit into
Conversation
Fixes google#12319 When IP_MTU_DISCOVER is set to IP_PMTUDISC_DO or IP_PMTUDISC_PROBE, locally-originated packets exceeding the MTU should return ErrMessageTooLong (EMSGSIZE), matching Linux kernel semantics. Changes: 1. pkg/tcpip/network/ipv4/ipv4.go: Remove the IsForwardedPacket guard from the DF+fragmentation check. When the Don't Fragment bit is set, packets exceeding network MTU return ErrMessageTooLong. Default UDP sockets maintain PMTUDiscoveryDont (DF=false), preventing regressions for large unfragmented UDP datagrams (google#12479). 2. pkg/tcpip/transport/udp/endpoint.go: When UDP WritePacket fails with ErrMessageTooLong, queue a local error on the socket error queue when IP_RECVERR is enabled, matching Linux net/ipv4/udp.c:udp_send_skb(). 3. test/packetimpact/tests/ipv4_id_uniqueness_test.go: Update comment now that IP_PMTUDISC_DONT is supported. Assisted-by: Gemini CLI
Ar1es-XD
force-pushed
the
fix-ip-mtu-discover
branch
from
August 16, 2026 18:41
bc2a83d to
5374207
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #12319
Problem
tracepathfails withtracepath: IP_MTU_DISCOVER: Operation not supportedbecausesetsockopt(IP_MTU_DISCOVER, IP_PMTUDISC_DO)andIP_PMTUDISC_PROBEpreviously returnedENOTSUP.A previous attempt to support this in PR #12366 was rolled back because of a regression where large UDP datagrams failed with
EMSGSIZE(#12479).Solution
pkg/tcpip/network/ipv4/ipv4.go:Remove the
IsForwardedPacketguard from theDontFragmentcheck. When the Don't Fragment (DF) bit is set and the packet exceeds the MTU, returnErrMessageTooLong(EMSGSIZE), matching Linux kernel semantics.IP_PMTUDISC_DONT,0) haveDF=false, so large datagrams continue to be fragmented locally without error, preventing regressions for workloads such as JavaDatagramChannel(Java runtime tests fail on buildkite #12479).pkg/tcpip/transport/udp/endpoint.go:When UDP
WritePacketfails withErrMessageTooLong, queue a local error on the socket's error queue ifIP_RECVERR/IPV6_RECVERRis enabled. This mirrors Linuxnet/ipv4/udp.c:udp_send_skb()behaviour, allowingtracepathto receive the error viaMSG_ERRQUEUE.test/packetimpact/tests/ipv4_id_uniqueness_test.go:Clean up stale TODO comment as
IP_PMTUDISC_DONTis supported.Verification
All unit tests, integration tests, and static checks passed:
//pkg/tcpip/network/ipv4:ipv4_test(passes all fragmentation & forwarding test cases)//pkg/tcpip/network/ipv4:ipv4_unit_test//pkg/tcpip/transport/udp:udp_x_test//pkg/tcpip/transport/internal/network:network_test//pkg/tcpip/transport/tcp:tcp_test//pkg/tcpip/tests/integration:...nogostatic analysis for all modified packagesAssisted-by: Gemini CLI