all: remove some Debug fields, NetworkMap.Debug, Reconfig Debug arg
Updates #8923 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
86ad1ea60e
commit
af2e4909b6
@@ -114,7 +114,7 @@ func setupWGTest(b *testing.B, logf logger.Logf, traf *TrafficGen, a1, a2 netip.
|
||||
AllowedIPs: []netip.Prefix{a1},
|
||||
}
|
||||
c2.Peers = []wgcfg.Peer{p}
|
||||
e2.Reconfig(&c2, &router.Config{}, new(dns.Config), nil)
|
||||
e2.Reconfig(&c2, &router.Config{}, new(dns.Config))
|
||||
e1waitDoneOnce.Do(wait.Done)
|
||||
})
|
||||
|
||||
@@ -151,7 +151,7 @@ func setupWGTest(b *testing.B, logf logger.Logf, traf *TrafficGen, a1, a2 netip.
|
||||
AllowedIPs: []netip.Prefix{a2},
|
||||
}
|
||||
c1.Peers = []wgcfg.Peer{p}
|
||||
e1.Reconfig(&c1, &router.Config{}, new(dns.Config), nil)
|
||||
e1.Reconfig(&c1, &router.Config{}, new(dns.Config))
|
||||
e2waitDoneOnce.Do(wait.Done)
|
||||
})
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ import (
|
||||
"io"
|
||||
"net"
|
||||
"net/netip"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"slices"
|
||||
"strconv"
|
||||
@@ -1756,17 +1755,12 @@ func (c *Conn) SetNetworkMap(nm *netmap.NetworkMap) {
|
||||
}
|
||||
|
||||
priorNetmap := c.netMap
|
||||
var priorDebug *tailcfg.Debug
|
||||
if priorNetmap != nil {
|
||||
priorDebug = priorNetmap.Debug
|
||||
}
|
||||
debugChanged := !reflect.DeepEqual(priorDebug, nm.Debug)
|
||||
metricNumPeers.Set(int64(len(nm.Peers)))
|
||||
|
||||
// Update c.netMap regardless, before the following early return.
|
||||
c.netMap = nm
|
||||
|
||||
if priorNetmap != nil && nodesEqual(priorNetmap.Peers, nm.Peers) && !debugChanged {
|
||||
if priorNetmap != nil && nodesEqual(priorNetmap.Peers, nm.Peers) {
|
||||
// The rest of this function is all adjusting state for peers that have
|
||||
// changed. But if the set of peers is equal and the debug flags (for
|
||||
// silent disco) haven't changed, no need to do anything else.
|
||||
|
||||
@@ -766,7 +766,9 @@ func hasOverlap(aips, rips []netip.Prefix) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (e *userspaceEngine) Reconfig(cfg *wgcfg.Config, routerCfg *router.Config, dnsCfg *dns.Config, debug *tailcfg.Debug) error {
|
||||
var randomizeClientPort = controlclient.RandomizeClientPort
|
||||
|
||||
func (e *userspaceEngine) Reconfig(cfg *wgcfg.Config, routerCfg *router.Config, dnsCfg *dns.Config) error {
|
||||
if routerCfg == nil {
|
||||
panic("routerCfg must not be nil")
|
||||
}
|
||||
@@ -792,8 +794,7 @@ func (e *userspaceEngine) Reconfig(cfg *wgcfg.Config, routerCfg *router.Config,
|
||||
e.mu.Unlock()
|
||||
|
||||
listenPort := e.confListenPort
|
||||
if controlclient.RandomizeClientPort() || // new way (capver 70)
|
||||
debug != nil && debug.RandomizeClientPort { // old way which server might still send (as of 2023-08-16)
|
||||
if randomizeClientPort() {
|
||||
listenPort = 0
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ func TestUserspaceEngineReconfig(t *testing.T) {
|
||||
}
|
||||
|
||||
e.SetNetworkMap(nm)
|
||||
err = e.Reconfig(cfg, routerCfg, &dns.Config{}, nil)
|
||||
err = e.Reconfig(cfg, routerCfg, &dns.Config{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -143,6 +143,8 @@ 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
|
||||
// Keep making a wgengine until we find an unused port
|
||||
@@ -181,13 +183,15 @@ func TestUserspaceEnginePortReconfig(t *testing.T) {
|
||||
},
|
||||
}
|
||||
routerCfg := &router.Config{}
|
||||
if err := ue.Reconfig(cfg, routerCfg, &dns.Config{}, nil); err != nil {
|
||||
if err := ue.Reconfig(cfg, routerCfg, &dns.Config{}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := ue.magicConn.LocalPort(); got != startingPort {
|
||||
t.Errorf("no debug setting changed local port to %d from %d", got, startingPort)
|
||||
}
|
||||
if err := ue.Reconfig(cfg, routerCfg, &dns.Config{}, &tailcfg.Debug{RandomizeClientPort: true}); err != nil {
|
||||
|
||||
randomizeClientPort = func() bool { return true }
|
||||
if err := ue.Reconfig(cfg, routerCfg, &dns.Config{}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := ue.magicConn.LocalPort(); got == startingPort {
|
||||
@@ -195,7 +199,8 @@ func TestUserspaceEnginePortReconfig(t *testing.T) {
|
||||
}
|
||||
|
||||
lastPort := ue.magicConn.LocalPort()
|
||||
if err := ue.Reconfig(cfg, routerCfg, &dns.Config{}, nil); err != nil {
|
||||
randomizeClientPort = func() bool { return false }
|
||||
if err := ue.Reconfig(cfg, routerCfg, &dns.Config{}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if startingPort == defaultPort {
|
||||
|
||||
@@ -119,8 +119,8 @@ func (e *watchdogEngine) watchdog(name string, fn func()) {
|
||||
})
|
||||
}
|
||||
|
||||
func (e *watchdogEngine) Reconfig(cfg *wgcfg.Config, routerCfg *router.Config, dnsCfg *dns.Config, debug *tailcfg.Debug) error {
|
||||
return e.watchdogErr("Reconfig", func() error { return e.wrap.Reconfig(cfg, routerCfg, dnsCfg, debug) })
|
||||
func (e *watchdogEngine) Reconfig(cfg *wgcfg.Config, routerCfg *router.Config, dnsCfg *dns.Config) error {
|
||||
return e.watchdogErr("Reconfig", func() error { return e.wrap.Reconfig(cfg, routerCfg, dnsCfg) })
|
||||
}
|
||||
func (e *watchdogEngine) GetFilter() *filter.Filter {
|
||||
return e.wrap.GetFilter()
|
||||
|
||||
@@ -72,10 +72,8 @@ type Engine interface {
|
||||
// This is called whenever tailcontrol (the control plane)
|
||||
// sends an updated network map.
|
||||
//
|
||||
// The *tailcfg.Debug parameter can be nil.
|
||||
//
|
||||
// The returned error is ErrNoChanges if no changes were made.
|
||||
Reconfig(*wgcfg.Config, *router.Config, *dns.Config, *tailcfg.Debug) error
|
||||
Reconfig(*wgcfg.Config, *router.Config, *dns.Config) error
|
||||
|
||||
// PeerForIP returns the node to which the provided IP routes,
|
||||
// if any. If none is found, (nil, false) is returned.
|
||||
|
||||
Reference in New Issue
Block a user