mirror of
https://github.com/tailscale/tailscale.git
synced 2025-10-15 10:49:18 +00:00
wgengine/magicsock: replace CanPMTUD() with ShouldPMTUD()
Replace CanPMTUD() with ShouldPMTUD() to check if peer path MTU discovery should be enabled, in preparation for adding support for enabling/disabling peer MTU dynamically. Updated #311 Signed-off-by: Val <valerie@tailscale.com>
This commit is contained in:
@@ -165,6 +165,9 @@ type Conn struct {
|
||||
// port is the preferred port from opts.Port; 0 means auto.
|
||||
port atomic.Uint32
|
||||
|
||||
// peerMTUEnabled is whether path MTU discovery to peers is enabled.
|
||||
peerMTUEnabled atomic.Bool
|
||||
|
||||
// stats maintains per-connection counters.
|
||||
stats atomic.Pointer[connstats.Statistics]
|
||||
|
||||
@@ -2310,15 +2313,6 @@ func (c *Conn) bindSocket(ruc *RebindingUDPConn, network string, curPortFate cur
|
||||
}
|
||||
trySetSocketBuffer(pconn, c.logf)
|
||||
|
||||
if CanPMTUD() {
|
||||
err = c.setDontFragment(network, true)
|
||||
if err != nil {
|
||||
c.logf("magicsock: set dontfragment failed for %v port %d: %v", network, port, err)
|
||||
// TODO disable PMTUD in this case. We don't expect the setsockopt to fail on
|
||||
// supported platforms, but we might as well be paranoid.
|
||||
}
|
||||
}
|
||||
|
||||
// Success.
|
||||
if debugBindSocket() {
|
||||
c.logf("magicsock: bindSocket: successfully listened %v port %d", network, port)
|
||||
@@ -2358,6 +2352,7 @@ func (c *Conn) rebind(curPortFate currentPortFate) error {
|
||||
return fmt.Errorf("magicsock: Rebind IPv4 failed: %w", err)
|
||||
}
|
||||
c.portMapper.SetLocalPort(c.LocalPort())
|
||||
c.UpdatePMTUD()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user