mirror of
https://github.com/slackhq/nebula.git
synced 2025-11-22 08:24:25 +01:00
fix tun_linux_test.go & a nit
This commit is contained in:
@@ -282,7 +282,7 @@ func (f *Interface) listenOut(i int) {
|
|||||||
plaintext := make([]byte, udp.MTU)
|
plaintext := make([]byte, udp.MTU)
|
||||||
h := &header.H{}
|
h := &header.H{}
|
||||||
fwPacket := &firewall.Packet{}
|
fwPacket := &firewall.Packet{}
|
||||||
nb := make([]byte, 12, 12)
|
nb := make([]byte, 12)
|
||||||
|
|
||||||
li.ListenOut(func(fromUdpAddr netip.AddrPort, payload []byte) {
|
li.ListenOut(func(fromUdpAddr netip.AddrPort, payload []byte) {
|
||||||
f.readOutsidePackets(fromUdpAddr, nil, plaintext[:0], payload, h, fwPacket, lhh, nb, i, ctCache.Get(f.l))
|
f.readOutsidePackets(fromUdpAddr, nil, plaintext[:0], payload, h, fwPacket, lhh, nb, i, ctCache.Get(f.l))
|
||||||
|
|||||||
@@ -6,26 +6,27 @@ package overlay
|
|||||||
import "testing"
|
import "testing"
|
||||||
|
|
||||||
var runAdvMSSTests = []struct {
|
var runAdvMSSTests = []struct {
|
||||||
name string
|
name string
|
||||||
tun *tun
|
defaultMTU int
|
||||||
r Route
|
maxMTU int
|
||||||
expected int
|
r Route
|
||||||
|
expected int
|
||||||
}{
|
}{
|
||||||
// Standard case, default MTU is the device max MTU
|
// Standard case, default MTU is the device max MTU
|
||||||
{"default", &tun{DefaultMTU: 1440, MaxMTU: 1440}, Route{}, 0},
|
{"default", 1440, 1440, Route{}, 0},
|
||||||
{"default-min", &tun{DefaultMTU: 1440, MaxMTU: 1440}, Route{MTU: 1440}, 0},
|
{"default-min", 1440, 1440, Route{MTU: 1440}, 0},
|
||||||
{"default-low", &tun{DefaultMTU: 1440, MaxMTU: 1440}, Route{MTU: 1200}, 1160},
|
{"default-low", 1440, 1440, Route{MTU: 1200}, 1160},
|
||||||
|
|
||||||
// Case where we have a route MTU set higher than the default
|
// Case where we have a route MTU set higher than the default
|
||||||
{"route", &tun{DefaultMTU: 1440, MaxMTU: 8941}, Route{}, 1400},
|
{"route", 1440, 8941, Route{}, 1400},
|
||||||
{"route-min", &tun{DefaultMTU: 1440, MaxMTU: 8941}, Route{MTU: 1440}, 1400},
|
{"route-min", 1440, 8941, Route{MTU: 1440}, 1400},
|
||||||
{"route-high", &tun{DefaultMTU: 1440, MaxMTU: 8941}, Route{MTU: 8941}, 0},
|
{"route-high", 1440, 8941, Route{MTU: 8941}, 0},
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTunAdvMSS(t *testing.T) {
|
func TestTunAdvMSS(t *testing.T) {
|
||||||
for _, tt := range runAdvMSSTests {
|
for _, tt := range runAdvMSSTests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
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 {
|
if o != tt.expected {
|
||||||
t.Errorf("got %d, want %d", o, tt.expected)
|
t.Errorf("got %d, want %d", o, tt.expected)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user