Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d5e15816b5 |
@@ -61,18 +61,27 @@ func probeEgressMTU(target string) MTUResult {
|
|||||||
_ = syscall.SetsockoptInt(fd, syscall.IPPROTO_IPV6, ipv6MTUDiscover, ipv6PMTUDiscDo)
|
_ = syscall.SetsockoptInt(fd, syscall.IPPROTO_IPV6, ipv6MTUDiscover, ipv6PMTUDiscDo)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Full-size probe: 1500 total − IP/UDP headers (28 v4, 48 v6).
|
// IP_MTU reflects the CONNECTED path's MTU, so the socket must be connected
|
||||||
payload := 1472
|
// (an unconnected socket returns ENOTCONN). No handshake — UDP connect just
|
||||||
|
// pins the destination and resolves the route.
|
||||||
sa := sockaddr(addr, 33434)
|
sa := sockaddr(addr, 33434)
|
||||||
|
if err := syscall.Connect(fd, sa); err != nil {
|
||||||
|
res.Err = "connect: " + errStr(err)
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// Full-size probe: 1500 total − IP/UDP headers (28 v4, 48 v6). A DF send
|
||||||
|
// larger than the local MTU fails immediately with EMSGSIZE; a path
|
||||||
|
// reduction updates IP_MTU after the ICMP frag-needed returns, so we send,
|
||||||
|
// briefly wait, and read the discovered MTU.
|
||||||
|
payload := 1472
|
||||||
if !is4 {
|
if !is4 {
|
||||||
payload = 1452
|
payload = 1452
|
||||||
}
|
}
|
||||||
// A DF send larger than the local MTU fails immediately with EMSGSIZE; a
|
probe := make([]byte, payload)
|
||||||
// path reduction updates IP_MTU after the ICMP frag-needed returns, so we
|
_, _ = syscall.Write(fd, probe)
|
||||||
// send, briefly wait, and read the discovered MTU.
|
|
||||||
_ = syscall.Sendto(fd, make([]byte, payload), 0, sa)
|
|
||||||
time.Sleep(700 * time.Millisecond)
|
time.Sleep(700 * time.Millisecond)
|
||||||
_ = syscall.Sendto(fd, make([]byte, payload), 0, sa) // second send observes any reduction
|
_, _ = syscall.Write(fd, probe) // second send observes any reduction
|
||||||
|
|
||||||
level, opt := syscall.IPPROTO_IP, ipMTU
|
level, opt := syscall.IPPROTO_IP, ipMTU
|
||||||
if !is4 {
|
if !is4 {
|
||||||
|
|||||||
Reference in New Issue
Block a user