From 241c983920485d84005a055b9919f114657d0f38 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Sat, 23 Sep 2023 11:48:20 -0700 Subject: [PATCH] net/tstun: use untyped consts, simplify DefaultMTU func Updates #cleanup Change-Id: Ic9ad1d6134818699f777c66a31024e846dfdc5d4 Signed-off-by: Brad Fitzpatrick --- net/tstun/mtu.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/net/tstun/mtu.go b/net/tstun/mtu.go index 2307d47f9..fe8eab3e8 100644 --- a/net/tstun/mtu.go +++ b/net/tstun/mtu.go @@ -5,8 +5,8 @@ package tstun import "tailscale.com/envknob" const ( - maxMTU uint32 = 65536 - defaultMTU uint32 = 1280 + maxMTU = 65536 + defaultMTU = 1280 ) // DefaultMTU returns either the constant default MTU of 1280, or the value set @@ -21,13 +21,8 @@ func DefaultMTU() uint32 { // 1280 is the smallest MTU allowed for IPv6, which is a sensible // "probably works everywhere" setting until we develop proper PMTU // discovery. - tunMTU := defaultMTU if mtu, ok := envknob.LookupUintSized("TS_DEBUG_MTU", 10, 32); ok { - mtu := uint32(mtu) - if mtu > maxMTU { - mtu = maxMTU - } - tunMTU = mtu + return min(uint32(mtu), maxMTU) } - return tunMTU + return defaultMTU }