2021-10-21 23:24:11 +02:00
|
|
|
//go:build !e2e_testing
|
2021-03-29 21:29:20 +02:00
|
|
|
// +build !e2e_testing
|
|
|
|
|
2021-11-11 23:37:29 +01:00
|
|
|
package overlay
|
2020-06-26 19:47:21 +02:00
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
|
|
|
var runAdvMSSTests = []struct {
|
|
|
|
name string
|
2021-11-12 17:47:36 +01:00
|
|
|
tun tun
|
2021-11-11 23:37:29 +01:00
|
|
|
r Route
|
2020-06-26 19:47:21 +02:00
|
|
|
expected int
|
|
|
|
}{
|
|
|
|
// Standard case, default MTU is the device max MTU
|
2021-11-12 17:47:36 +01:00
|
|
|
{"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},
|
2020-06-26 19:47:21 +02:00
|
|
|
|
|
|
|
// Case where we have a route MTU set higher than the default
|
2021-11-12 17:47:36 +01:00
|
|
|
{"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},
|
2020-06-26 19:47:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestTunAdvMSS(t *testing.T) {
|
|
|
|
for _, tt := range runAdvMSSTests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
o := tt.tun.advMSS(tt.r)
|
|
|
|
if o != tt.expected {
|
|
|
|
t.Errorf("got %d, want %d", o, tt.expected)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|