Skip to content

FR: Implement peer MTU discovery through the tailnet #311

Open

Description

@apenwarr

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.

Activity

  1. added
    connectivity
    L3 Some users
    P5 Halts deployment
    on Apr 22, 2020
  2. added
    L2 Few
    and removed
    L3 Some users
    on Sep 4, 2020
  3. DanielJoyce commented on Dec 21, 2020

    @DanielJoyce

    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...

  4. bradfitz commented on Feb 8, 2021

    @bradfitz
    Member

    This is much easier to do these days. Our disco messages' Ping/Pong basically do a lot of what we'd need.

  5. DentonGentry commented on Feb 8, 2021

    @DentonGentry
    Contributor

    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.

  6. apenwarr commented on Feb 8, 2021

    @apenwarr
    MemberAuthor
  7. bradfitz commented on Feb 9, 2021

    @bradfitz
    Member

    (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.

  8. apenwarr commented on Feb 9, 2021

    @apenwarr
    MemberAuthor
  9. DentonGentry commented on Aug 27, 2022

    @DentonGentry
    Contributor

    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

  10. changed the title [-]Properly handle PMTU discovery[/-] [+]FR: Implement peer MTU discovery through the tailnet[/+] on Jun 2, 2023
  11. 236 remaining items

  12. oviano commented on Jul 24, 2024

    @oviano

    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?

  13. added a commit that references this issue on Jul 31, 2024
  14. added a commit that references this issue on Aug 23, 2024
  15. bcreane commented on Aug 6, 2026

    @bcreane
    Contributor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

L4 Most usersP5 Halts deploymentT0 New featureconnectivity

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions