MCPcopy
hub / github.com/tailscale/tailscale / TestUserspaceEnginePeerMTUReconfig

Function TestUserspaceEnginePeerMTUReconfig

wgengine/userspace_test.go:335–415  ·  view source on GitHub ↗

Test that enabling and disabling peer path MTU discovery works correctly.

(t *testing.T)

Source from the content-addressed store, hash-verified

333
334// Test that enabling and disabling peer path MTU discovery works correctly.
335func TestUserspaceEnginePeerMTUReconfig(t *testing.T) {
336 if runtime.GOOS != "linux" && runtime.GOOS != "darwin" {
337 t.Skipf("skipping on %q; peer MTU not supported", runtime.GOOS)
338 }
339
340 defer os.Setenv("TS_DEBUG_ENABLE_PMTUD", os.Getenv("TS_DEBUG_ENABLE_PMTUD"))
341 envknob.Setenv("TS_DEBUG_ENABLE_PMTUD", "")
342 // Turn on debugging to help diagnose problems.
343 defer os.Setenv("TS_DEBUG_PMTUD", os.Getenv("TS_DEBUG_PMTUD"))
344 envknob.Setenv("TS_DEBUG_PMTUD", "true")
345
346 var knobs controlknobs.Knobs
347
348 bus := eventbustest.NewBus(t)
349 ht := health.NewTracker(bus)
350 reg := new(usermetric.Registry)
351 e, err := NewFakeUserspaceEngine(t.Logf, 0, &knobs, ht, reg, bus)
352 if err != nil {
353 t.Fatal(err)
354 }
355 t.Cleanup(e.Close)
356 ue := e.(*userspaceEngine)
357
358 if ue.magicConn.PeerMTUEnabled() != false {
359 t.Error("peer MTU enabled by default, should not be")
360 }
361 osDefaultDF, err := ue.magicConn.DontFragSetting()
362 if err != nil {
363 t.Errorf("get don't fragment bit failed: %v", err)
364 }
365 t.Logf("Info: OS default don't fragment bit(s) setting: %v", osDefaultDF)
366
367 // Build a set of configs to use as we change the peer MTU settings.
368 nodeKey, err := key.ParseNodePublicUntyped(mem.S("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"))
369 if err != nil {
370 t.Fatal(err)
371 }
372 cfg := &wgcfg.Config{
373 Peers: []wgcfg.Peer{
374 {
375 PublicKey: nodeKey,
376 AllowedIPs: []netip.Prefix{
377 netip.PrefixFrom(netaddr.IPv4(100, 100, 99, 1), 32),
378 },
379 },
380 },
381 }
382 routerCfg := &router.Config{}
383
384 tests := []struct {
385 desc string // test description
386 wantP bool // desired value of PMTUD setting
387 wantDF bool // desired value of don't fragment bits
388 shouldP opt.Bool // if set, force peer MTU to this value
389 }{
390 {desc: "after_first_reconfig", wantP: false, wantDF: osDefaultDF, shouldP: ""},
391 {desc: "enabling_PMTUD_first_time", wantP: true, wantDF: true, shouldP: "true"},
392 {desc: "disabling_PMTUD", wantP: false, wantDF: false, shouldP: "false"},

Callers

nothing calls this directly

Calls 15

SetenvFunction · 0.92
NewBusFunction · 0.92
NewTrackerFunction · 0.92
ParseNodePublicUntypedFunction · 0.92
IPv4Function · 0.92
NewFakeUserspaceEngineFunction · 0.85
SkipfMethod · 0.65
SetenvMethod · 0.65
FatalMethod · 0.65
CleanupMethod · 0.65
ErrorMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…