github.com/slackhq/nebula@v1.9.0/overlay/tun_linux_test.go (about)

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