util/linuxfw: clamp MSS to PMTU in both forward directions (#20077)
ClampMSSToPMTU only added a rule matching the output interface (-o tun / OIFNAME), which clamps the SYN forwarded out towards the tailnet peer but not the SYN-ACK that arrives on tun and is forwarded back towards the originating endpoint. As a result only one side of a forwarded handshake had its MSS clamped; the endpoint on the other side of the proxy kept advertising an MSS based on its own (larger) MTU. When path MTU discovery is broken (e.g. proxies created by the Tailscale Kubernetes operator, where tailscale0 has a 1280 MTU), the unclamped endpoint's large segments exceed the tun MTU and are silently dropped, causing TCP connections through proxy group pods to stall mid-stream on large payloads. The earlier proxy-group fix (#19686) wired ClampMSSToPMTU into the HA code paths but inherited this single-direction limitation, so connections could still hang. Add a second rule matching the input interface (-i tun / IIFNAME) in both the iptables and nftables runners so both directions of the forwarded handshake negotiate a PMTU-safe MSS. Updates #19812 Signed-off-by: Samy Djemaï <53857555+SamyDjemai@users.noreply.github.com>
This commit is contained in:
@@ -322,7 +322,16 @@ func (i *iptablesRunner) DNATWithLoadBalancer(origDst netip.Addr, dsts []netip.A
|
||||
|
||||
func (i *iptablesRunner) ClampMSSToPMTU(tun string, addr netip.Addr) error {
|
||||
table := i.getIPTByAddr(addr)
|
||||
return table.Append("mangle", "FORWARD", "-o", tun, "-p", "tcp", "--tcp-flags", "SYN,RST", "SYN", "-j", "TCPMSS", "--clamp-mss-to-pmtu")
|
||||
// Clamp MSS on forwarded TCP handshakes in both directions: the SYN
|
||||
// leaving via tun towards the tailnet peer, and the SYN-ACK arriving on
|
||||
// tun and being forwarded back out towards the originating endpoint. A
|
||||
// single -o tun rule only clamps one side of the handshake, leaving the
|
||||
// endpoint on the other side advertising an MSS that is too large for the
|
||||
// tun MTU, which black-holes large segments when PMTU discovery is broken.
|
||||
if err := table.Append("mangle", "FORWARD", "-o", tun, "-p", "tcp", "--tcp-flags", "SYN,RST", "SYN", "-j", "TCPMSS", "--clamp-mss-to-pmtu"); err != nil {
|
||||
return err
|
||||
}
|
||||
return table.Append("mangle", "FORWARD", "-i", tun, "-p", "tcp", "--tcp-flags", "SYN,RST", "SYN", "-j", "TCPMSS", "--clamp-mss-to-pmtu")
|
||||
}
|
||||
|
||||
// addBase6 adds some basic IPv6 processing rules to be
|
||||
|
||||
Reference in New Issue
Block a user