Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1336fb7

Browse files
committed
wgengine/netstack: make netstack MTU be 1280 also
Updates tailscale#3878 Change-Id: I1850085b32c8a40d85607b4ad433622c97d96a8d Signed-off-by: Brad Fitzpatrick <[email protected]>
1 parent 8148716 commit 1336fb7

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

net/tstun/constants.go

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright (c) 2022 Tailscale Inc & AUTHORS All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package tstun
6+
7+
// DefaultMTU is the Tailscale default MTU for now.
8+
//
9+
// wireguard-go defaults to 1420 bytes, which only works if the
10+
// "outer" MTU is 1500 bytes. This breaks on DSL connections
11+
// (typically 1492 MTU) and on GCE (1460 MTU?!).
12+
//
13+
// 1280 is the smallest MTU allowed for IPv6, which is a sensible
14+
// "probably works everywhere" setting until we develop proper PMTU
15+
// discovery.
16+
const DefaultMTU = 1280

net/tstun/tun.go

+1-9
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,7 @@ import (
2020
"tailscale.com/types/logger"
2121
)
2222

23-
// tunMTU is the MTU we set on tailscale's TUN interface. wireguard-go
24-
// defaults to 1420 bytes, which only works if the "outer" MTU is 1500
25-
// bytes. This breaks on DSL connections (typically 1492 MTU) and on
26-
// GCE (1460 MTU?!).
27-
//
28-
// 1280 is the smallest MTU allowed for IPv6, which is a sensible
29-
// "probably works everywhere" setting until we develop proper PMTU
30-
// discovery.
31-
var tunMTU = 1280
23+
var tunMTU = DefaultMTU
3224

3325
func init() {
3426
if mtu, ok := envknob.LookupInt("TS_DEBUG_MTU"); ok {

wgengine/netstack/netstack.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ type Impl struct {
131131
var handleSSH func(logger.Logf, *ipnlocal.LocalBackend, net.Conn) error
132132

133133
const nicID = 1
134-
const mtu = 1500
134+
const mtu = tstun.DefaultMTU
135135

136136
// Create creates and populates a new Impl.
137137
func Create(logf logger.Logf, tundev *tstun.Wrapper, e wgengine.Engine, mc *magicsock.Conn, dialer *tsdial.Dialer, dns *dns.Manager) (*Impl, error) {
@@ -1018,7 +1018,7 @@ func startPacketCopy(ctx context.Context, cancel context.CancelFunc, dst net.Pac
10181018
}
10191019
go func() {
10201020
defer cancel() // tear down the other direction's copy
1021-
pkt := make([]byte, mtu)
1021+
pkt := make([]byte, 1500)
10221022
for {
10231023
select {
10241024
case <-ctx.Done():

0 commit comments

Comments
 (0)