Skip to content

Commit 241c983

Browse files
committed
net/tstun: use untyped consts, simplify DefaultMTU func
Updates #cleanup Change-Id: Ic9ad1d6134818699f777c66a31024e846dfdc5d4 Signed-off-by: Brad Fitzpatrick <[email protected]>
1 parent 3b32d6c commit 241c983

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

net/tstun/mtu.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ package tstun
55
import "tailscale.com/envknob"
66

77
const (
8-
maxMTU uint32 = 65536
9-
defaultMTU uint32 = 1280
8+
maxMTU = 65536
9+
defaultMTU = 1280
1010
)
1111

1212
// DefaultMTU returns either the constant default MTU of 1280, or the value set
@@ -21,13 +21,8 @@ func DefaultMTU() uint32 {
2121
// 1280 is the smallest MTU allowed for IPv6, which is a sensible
2222
// "probably works everywhere" setting until we develop proper PMTU
2323
// discovery.
24-
tunMTU := defaultMTU
2524
if mtu, ok := envknob.LookupUintSized("TS_DEBUG_MTU", 10, 32); ok {
26-
mtu := uint32(mtu)
27-
if mtu > maxMTU {
28-
mtu = maxMTU
29-
}
30-
tunMTU = mtu
25+
return min(uint32(mtu), maxMTU)
3126
}
32-
return tunMTU
27+
return defaultMTU
3328
}

0 commit comments

Comments
 (0)