mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-30 05:25:35 +00:00
40fa2a420c
Noted on #5915 TS_DEBUG_MTU was not used consistently everywhere. Extract the default into a function that can apply this centrally and use it everywhere. Added envknob.Lookup{Int,Uint}Sized to make it easier to keep CodeQL happy when using converted values. Updates #5915 Signed-off-by: James Tucker <james@tailscale.com>
29 lines
616 B
Go
29 lines
616 B
Go
// Copyright (c) Tailscale Inc & AUTHORS
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
package tstun
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
func TestDefaultMTU(t *testing.T) {
|
|
orig := os.Getenv("TS_DEBUG_MTU")
|
|
defer os.Setenv("TS_DEBUG_MTU", orig)
|
|
|
|
os.Setenv("TS_DEBUG_MTU", "")
|
|
if DefaultMTU() != 1280 {
|
|
t.Errorf("DefaultMTU() = %d, want 1280", DefaultMTU())
|
|
}
|
|
|
|
os.Setenv("TS_DEBUG_MTU", "9000")
|
|
if DefaultMTU() != 9000 {
|
|
t.Errorf("DefaultMTU() = %d, want 9000", DefaultMTU())
|
|
}
|
|
|
|
os.Setenv("TS_DEBUG_MTU", "123456789")
|
|
if DefaultMTU() != maxMTU {
|
|
t.Errorf("DefaultMTU() = %d, want %d", DefaultMTU(), maxMTU)
|
|
}
|
|
}
|