control/controlknobs, all: add plumbed Knobs type, not global variables
Previously two tsnet nodes in the same process couldn't have disjoint sets of controlknob settings from control as both would overwrite each other's global variables. This plumbs a new controlknobs.Knobs type around everywhere and hangs the knobs sent by control on that instead. Updates #9351 Change-Id: I75338646d36813ed971b4ffad6f9a8b41ec91560 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
d050700a3b
commit
4e91cf20a8
@@ -11,6 +11,7 @@ import (
|
||||
|
||||
"go4.org/mem"
|
||||
"tailscale.com/cmd/testwrapper/flakytest"
|
||||
"tailscale.com/control/controlknobs"
|
||||
"tailscale.com/net/dns"
|
||||
"tailscale.com/net/netaddr"
|
||||
"tailscale.com/net/tstun"
|
||||
@@ -152,15 +153,16 @@ func TestUserspaceEngineReconfig(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUserspaceEnginePortReconfig(t *testing.T) {
|
||||
tstest.Replace(t, &randomizeClientPort, func() bool { return false })
|
||||
|
||||
flakytest.Mark(t, "https://github.com/tailscale/tailscale/issues/2855")
|
||||
const defaultPort = 49983
|
||||
|
||||
var knobs controlknobs.Knobs
|
||||
|
||||
// Keep making a wgengine until we find an unused port
|
||||
var ue *userspaceEngine
|
||||
for i := 0; i < 100; i++ {
|
||||
attempt := uint16(defaultPort + i)
|
||||
e, err := NewFakeUserspaceEngine(t.Logf, attempt)
|
||||
e, err := NewFakeUserspaceEngine(t.Logf, attempt, &knobs)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -199,7 +201,7 @@ func TestUserspaceEnginePortReconfig(t *testing.T) {
|
||||
t.Errorf("no debug setting changed local port to %d from %d", got, startingPort)
|
||||
}
|
||||
|
||||
randomizeClientPort = func() bool { return true }
|
||||
knobs.RandomizeClientPort.Store(true)
|
||||
if err := ue.Reconfig(cfg, routerCfg, &dns.Config{}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -208,7 +210,7 @@ func TestUserspaceEnginePortReconfig(t *testing.T) {
|
||||
}
|
||||
|
||||
lastPort := ue.magicConn.LocalPort()
|
||||
randomizeClientPort = func() bool { return false }
|
||||
knobs.RandomizeClientPort.Store(false)
|
||||
if err := ue.Reconfig(cfg, routerCfg, &dns.Config{}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user