mirror of
https://github.com/slackhq/nebula.git
synced 2025-11-24 01:14:25 +01:00
fix tun_linux_test.go & a nit
This commit is contained in:
@@ -6,26 +6,27 @@ package overlay
|
||||
import "testing"
|
||||
|
||||
var runAdvMSSTests = []struct {
|
||||
name string
|
||||
tun *tun
|
||||
r Route
|
||||
expected int
|
||||
name string
|
||||
defaultMTU int
|
||||
maxMTU int
|
||||
r Route
|
||||
expected int
|
||||
}{
|
||||
// Standard case, default MTU is the device max MTU
|
||||
{"default", &tun{DefaultMTU: 1440, MaxMTU: 1440}, Route{}, 0},
|
||||
{"default-min", &tun{DefaultMTU: 1440, MaxMTU: 1440}, Route{MTU: 1440}, 0},
|
||||
{"default-low", &tun{DefaultMTU: 1440, MaxMTU: 1440}, Route{MTU: 1200}, 1160},
|
||||
{"default", 1440, 1440, Route{}, 0},
|
||||
{"default-min", 1440, 1440, Route{MTU: 1440}, 0},
|
||||
{"default-low", 1440, 1440, Route{MTU: 1200}, 1160},
|
||||
|
||||
// Case where we have a route MTU set higher than the default
|
||||
{"route", &tun{DefaultMTU: 1440, MaxMTU: 8941}, Route{}, 1400},
|
||||
{"route-min", &tun{DefaultMTU: 1440, MaxMTU: 8941}, Route{MTU: 1440}, 1400},
|
||||
{"route-high", &tun{DefaultMTU: 1440, MaxMTU: 8941}, Route{MTU: 8941}, 0},
|
||||
{"route", 1440, 8941, Route{}, 1400},
|
||||
{"route-min", 1440, 8941, Route{MTU: 1440}, 1400},
|
||||
{"route-high", 1440, 8941, Route{MTU: 8941}, 0},
|
||||
}
|
||||
|
||||
func TestTunAdvMSS(t *testing.T) {
|
||||
for _, tt := range runAdvMSSTests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
o := tt.tun.advMSS(tt.r)
|
||||
o := advMSS(tt.r, tt.defaultMTU, tt.maxMTU)
|
||||
if o != tt.expected {
|
||||
t.Errorf("got %d, want %d", o, tt.expected)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user