tun_linux_test.go 958 B

12345678910111213141516171819202122232425262728293031323334
  1. //go:build !e2e_testing
  2. // +build !e2e_testing
  3. package nebula
  4. import "testing"
  5. var runAdvMSSTests = []struct {
  6. name string
  7. tun Tun
  8. r route
  9. expected int
  10. }{
  11. // Standard case, default MTU is the device max MTU
  12. {"default", Tun{DefaultMTU: 1440, MaxMTU: 1440}, route{}, 0},
  13. {"default-min", Tun{DefaultMTU: 1440, MaxMTU: 1440}, route{mtu: 1440}, 0},
  14. {"default-low", Tun{DefaultMTU: 1440, MaxMTU: 1440}, route{mtu: 1200}, 1160},
  15. // Case where we have a route MTU set higher than the default
  16. {"route", Tun{DefaultMTU: 1440, MaxMTU: 8941}, route{}, 1400},
  17. {"route-min", Tun{DefaultMTU: 1440, MaxMTU: 8941}, route{mtu: 1440}, 1400},
  18. {"route-high", Tun{DefaultMTU: 1440, MaxMTU: 8941}, route{mtu: 8941}, 0},
  19. }
  20. func TestTunAdvMSS(t *testing.T) {
  21. for _, tt := range runAdvMSSTests {
  22. t.Run(tt.name, func(t *testing.T) {
  23. o := tt.tun.advMSS(tt.r)
  24. if o != tt.expected {
  25. t.Errorf("got %d, want %d", o, tt.expected)
  26. }
  27. })
  28. }
  29. }