wgengine: use set.HandleSet in another place

I guess we missed this one earlier when we unified the various
copies into set.HandleSet.

Updates #cleanup

Change-Id: I7e6de9ce16e8fc4846abf384dfcc8eaec4d99e60
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick 2023-09-11 19:30:49 -07:00 committed by Brad Fitzpatrick
parent 42072683d6
commit f06e64c562
2 changed files with 3 additions and 9 deletions

View File

@ -133,7 +133,7 @@ type userspaceEngine struct {
peerSequence []key.NodePublic
endpoints []tailcfg.Endpoint
pendOpen map[flowtrack.Tuple]*pendingOpenFlow // see pendopen.go
networkMapCallbacks map[*someHandle]NetworkMapCallback
networkMapCallbacks set.HandleSet[NetworkMapCallback]
tsIPByIPPort map[netip.AddrPort]netip.Addr // allows registration of IP:ports as belonging to a certain Tailscale IP for whois lookups
// pongCallback is the map of response handlers waiting for disco or TSMP
@ -1162,10 +1162,9 @@ func (e *userspaceEngine) AddNetworkMapCallback(cb NetworkMapCallback) func() {
e.mu.Lock()
defer e.mu.Unlock()
if e.networkMapCallbacks == nil {
e.networkMapCallbacks = make(map[*someHandle]NetworkMapCallback)
e.networkMapCallbacks = make(set.HandleSet[NetworkMapCallback])
}
h := new(someHandle)
e.networkMapCallbacks[h] = cb
h := e.networkMapCallbacks.Add(cb)
return func() {
e.mu.Lock()
defer e.mu.Unlock()

View File

@ -42,11 +42,6 @@ type Status struct {
// into network map updates.
type NetworkMapCallback func(*netmap.NetworkMap)
// someHandle is allocated so its pointer address acts as a unique
// map key handle. (It needs to have non-zero size for Go to guarantee
// the pointer is unique.)
type someHandle struct{ _ byte }
// ErrNoChanges is returned by Engine.Reconfig if no changes were made.
var ErrNoChanges = errors.New("no changes made to Engine config")