mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-11 21:27:31 +00:00
wgengine,net,ipn,disco: split up and define different types of MTU
Prepare for path MTU discovery by splitting up the concept of DefaultMTU() into the concepts of the Tailscale TUN MTU, MTUs of underlying network interfaces, minimum "safe" TUN MTU, user configured TUN MTU, probed path MTU to a peer, and maximum probed MTU. Add a set of likely MTUs to probe. Updates #311 Signed-off-by: Val <valerie@tailscale.com>
This commit is contained in:
@@ -422,6 +422,10 @@ func (de *endpoint) noteActiveLocked() {
|
||||
}
|
||||
}
|
||||
|
||||
// MaxDiscoPingSize is the largest useful ping message size that we
|
||||
// can send - the maximum packet size minus the IPv4 and UDP headers.
|
||||
var MaxDiscoPingSize = tstun.MaxPacketSize - 20 - 8
|
||||
|
||||
// cliPing starts a ping for the "tailscale ping" command. res is value to call cb with,
|
||||
// already partially filled.
|
||||
func (de *endpoint) cliPing(res *ipnstate.PingResult, size int, cb func(*ipnstate.PingResult)) {
|
||||
@@ -433,6 +437,11 @@ func (de *endpoint) cliPing(res *ipnstate.PingResult, size int, cb func(*ipnstat
|
||||
cb(res)
|
||||
return
|
||||
}
|
||||
if size > MaxDiscoPingSize {
|
||||
res.Err = errPingTooBig.Error()
|
||||
cb(res)
|
||||
return
|
||||
}
|
||||
|
||||
now := mono.Now()
|
||||
udpAddr, derpAddr, _ := de.addrForSendLocked(now)
|
||||
@@ -457,6 +466,7 @@ func (de *endpoint) cliPing(res *ipnstate.PingResult, size int, cb func(*ipnstat
|
||||
var (
|
||||
errExpired = errors.New("peer's node key has expired")
|
||||
errNoUDPOrDERP = errors.New("no UDP or DERP addr")
|
||||
errPingTooBig = errors.New("ping size too big")
|
||||
)
|
||||
|
||||
func (de *endpoint) send(buffs [][]byte) error {
|
||||
@@ -564,13 +574,9 @@ const discoPingSize = len(disco.Magic) + key.DiscoPublicRawLen + disco.NonceLen
|
||||
// The caller should use de.discoKey as the discoKey argument.
|
||||
// It is passed in so that sendDiscoPing doesn't need to lock de.mu.
|
||||
func (de *endpoint) sendDiscoPing(ep netip.AddrPort, discoKey key.DiscoPublic, txid stun.TxID, size int, logLevel discoLogLevel) {
|
||||
padding := 0
|
||||
if size > int(tstun.DefaultMTU()) {
|
||||
size = int(tstun.DefaultMTU())
|
||||
}
|
||||
if size-discoPingSize > 0 {
|
||||
padding = size - discoPingSize
|
||||
}
|
||||
size = min(size, MaxDiscoPingSize)
|
||||
padding := max(size-discoPingSize, 0)
|
||||
|
||||
sent, _ := de.c.sendDiscoMessage(ep, de.publicKey, discoKey, &disco.Ping{
|
||||
TxID: [12]byte(txid),
|
||||
NodeKey: de.c.publicKeyAtomic.Load(),
|
||||
|
Reference in New Issue
Block a user