PMTUD exploration, start small then grow

This commit is contained in:
Nate Brown
2026-05-05 17:05:50 -05:00
parent 33c2d7277c
commit 16a836a73f
33 changed files with 1036 additions and 11 deletions

View File

@@ -44,3 +44,17 @@ func NewListenConfig(multi bool) net.ListenConfig {
func (u *GenericConn) Rebind() error {
return nil
}
// EnablePathMTUDiscovery sets the don't-fragment bit on outbound packets.
// Android is Linux underneath, so we use IP_PMTUDISC_PROBE (kernel sets DF but
// does not consume incoming ICMP frag-needed for its PMTU cache; the manager
// drives discovery via authenticated probes).
func (u *GenericConn) EnablePathMTUDiscovery() error {
v4 := u.isV4Socket()
return u.controlFD(func(fd uintptr) error {
if v4 {
return unix.SetsockoptInt(int(fd), unix.IPPROTO_IP, unix.IP_MTU_DISCOVER, unix.IP_PMTUDISC_PROBE)
}
return unix.SetsockoptInt(int(fd), unix.IPPROTO_IPV6, unix.IPV6_MTU_DISCOVER, unix.IPV6_PMTUDISC_PROBE)
})
}