You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
FR: Implement peer MTU discovery through the tailnet #311
Bug #246 and others note that we have a hardcoded MTU calculation on different OSes, either using a strictly fixed size or some formula based on the MTU of the default route's interface. This is also more or less what plain wireguard does.
Unfortunately it's guaranteed to be completely wrong on some networks. The MTU can be constrained by either end of a link. If WireGuard packets are using the DF flag, then intermediate routers will refuse to fragment them and will (attempt to) send back an ICMP Fragmentation Needed packet. WireGuard doesn't trust those because they could be forged, so it discards them instead.
A proper fix would do a more expensive form of MTU probing in both directions, which neither relies on nor trusts ICMP Fragmentation Needed packets. We can afford to try harder than regular TCP would do, because we can calculate the MTU once per long-lived peer connection instead of once per short-lived TCP connection.
Once we know the MTU, we'd have to generate our own synthetic ICMP Fragmentation Needed packets inside the tunnel, so that the inner TCP can do proper PMTU discovery.
Reacted by Pedro Gomes, Bastien Gandouet and Star Brilliant
Further notes from bug scrub: DISCO can be used to do a binary search of what packet size works, and Ping takes a size argument (though it might currently be ignored). We'll need a test environment where we can constrain the MTU in some links.
AFAIK the ping response doesn't need to accept a size argument. You can
detect PMTU in the send direction even if the response is always as short
as possible (and that's probably a good idea). PMTU in the opposite
direction is the responsibility of the other end.
(meeting follow-up) It's not so much that it takes a size argument as it accepts a ping with an arbitrary unparsed payload suffix and responds with a pong regardless. So we can add N padding bytes at the end of the pings.
In cases where there are two subnet routers with 1500 byte MTUs on either end of the link but a 1280 byte MTU in the middle, it Path MTU Discovery is not working the following can be used on the subnet routers to force TCP sessions to set the MSS to no more than 1280.
iptables -t mangle -A FORWARD -i tailscale0 -o eth0 -p tcp -m tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
I recently discovered Tailscale; absolutely love it, great job. I am wondering when this feature will be available so we can have a more reasonable MTU for many use-cases?
Peer MTU probing landed 893bdd7 but doesn't feed the data path yet. I built an MTU-constrained natlab repro while investigating #20668 and measured it.
Two nodes, direct UDP path, WAN MTU set to 1280, 1 MiB HTTP transfer:
Underlay MTU
PMTUD
Transferred
1500 (control)
off
1048576 / 1048576 - 590ms, 14.2 Mbit/s
1280
off
512 / 1048576
1280
on
512 / 1048576
Enabling PMTUD makes no difference: both runs transfer exactly 512 bytes.
1360/1400/1500 are WireMTUsToProbe; both nodes probe both directions. Only the 1280 probe is answered, so discovery finds the correct path MTU. Data packets stay at 1340 (1280 TUN + 60 framing) because DefaultTUNMTU returns safeTUNMTU regardless, per the TODO pending PTB generation. Probe results feed only metricMaxPeerMTUProbed.
So the probing half of this issue is done and the remaining work is the plumbing plus synthetic PTB - the second half of the original description here, and what #9480 describes. Enabling PMTUD by default would not help.
Repro in #20681: TestSmallMTUUnderlayThroughput (gated behind --run-unfixed-tests) with TestLargeMTUUnderlayThroughput as an in-CI harness control, on new vnet.Network.SetMTU support.
Activity
DanielJoyce commentedon Dec 21, 2020
PMTU can be unreliable and fails to work if a single firewall or router doesn't handle it properly.
A manual option to specify an MTU should be provided. Speaking from experience using similar products...
bradfitz commentedon Feb 8, 2021
This is much easier to do these days. Our disco messages' Ping/Pong basically do a lot of what we'd need.
DentonGentry commentedon Feb 8, 2021
Further notes from bug scrub: DISCO can be used to do a binary search of what packet size works, and Ping takes a size argument (though it might currently be ignored). We'll need a test environment where we can constrain the MTU in some links.
apenwarr commentedon Feb 8, 2021
bradfitz commentedon Feb 9, 2021
(meeting follow-up) It's not so much that it takes a size argument as it accepts a ping with an arbitrary unparsed payload suffix and responds with a pong regardless. So we can add N padding bytes at the end of the pings.
apenwarr commentedon Feb 9, 2021
DentonGentry commentedon Aug 27, 2022
In cases where there are two subnet routers with 1500 byte MTUs on either end of the link but a 1280 byte MTU in the middle, it Path MTU Discovery is not working the following can be used on the subnet routers to force TCP sessions to set the MSS to no more than 1280.
iptables -t mangle -A FORWARD -i tailscale0 -o eth0 -p tcp -m tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu[-]Properly handle PMTU discovery[/-][+]FR: Implement peer MTU discovery through the tailnet[/+]236 remaining items
oviano commentedon Jul 24, 2024
I recently discovered Tailscale; absolutely love it, great job. I am wondering when this feature will be available so we can have a more reasonable MTU for many use-cases?
net/packet: allow more ICMP errors
net/packet: allow more ICMP errors
tstest/natlab: add WAN MTU support, with a repro for #311
bcreane commentedon Aug 6, 2026
Peer MTU probing landed 893bdd7 but doesn't feed the data path yet. I built an MTU-constrained natlab repro while investigating #20668 and measured it.
Two nodes, direct UDP path, WAN MTU set to 1280, 1 MiB HTTP transfer:
Enabling PMTUD makes no difference: both runs transfer exactly 512 bytes.
1360/1400/1500 are WireMTUsToProbe; both nodes probe both directions. Only the 1280 probe is answered, so discovery finds the correct path MTU. Data packets stay at 1340 (1280 TUN + 60 framing) because
DefaultTUNMTUreturnssafeTUNMTUregardless, per the TODO pending PTB generation. Probe results feed onlymetricMaxPeerMTUProbed.So the probing half of this issue is done and the remaining work is the plumbing plus synthetic PTB - the second half of the original description here, and what #9480 describes. Enabling PMTUD by default would not help.
Repro in #20681:
TestSmallMTUUnderlayThroughput(gated behind --run-unfixed-tests) withTestLargeMTUUnderlayThroughputas an in-CI harness control, on newvnet.Network.SetMTUsupport.tstest/natlab: add WAN MTU support, with a repro for #311
net/packet: add ICMP Packet Too Big / Fragmentation Needed generation
net/tstun, wgengine/netstack: enforce peer path MTUs on the outbound …
wgengine/magicsock, wgengine: track peer path MTUs and react to ICMP …
tailcfg, ipn/ipnstate, cmd/tailscale/cli: surface peer path MTU
net/packet: add ICMP Packet Too Big / Fragmentation Needed generation
net/tstun, wgengine/netstack: enforce peer path MTUs on the outbound …
wgengine/magicsock, wgengine: track peer path MTUs and react to ICMP …
tailcfg, ipn/ipnstate, cmd/tailscale/cli: surface peer path MTU