wgengine,ipn/ipnlocal: remove Engine.PeerKeyForIP and the engine's peer route table
The engine kept its own longest-prefix-match table (peerByIPRoute), rebuilt from the full peer list on every reconfig, to route outbound packets and answer PeerKeyForIP. That's now the route manager's job: LocalBackend already installs a PeerByIPPacketFunc backed by the RouteManager's incrementally-maintained outbound table, so the engine's copy was redundant state with redundant O(n peers) rebuild work. Delete the table, the PeerKeyForIP interface method, and the BART-only default callback. LocalBackend's peerForIP now queries the RouteManager's outbound table directly for the subnet-route and exit-node fallback. Engines running without a LocalBackend (such as wgengine/bench) must install their own outbound peer lookup, since the device's standard AllowedIPs trie only covers peers that already exist and can't lazily create them. Updates #12542 Change-Id: I25100399e273ed6c2bb1f6136b7cd81bc83e7313 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
3c800dcd71
commit
2506ede862
+2
-10
@@ -126,18 +126,10 @@ type Engine interface {
|
||||
// If fn is nil, PeerForIP returns (zero, false) for every IP.
|
||||
//
|
||||
// LocalBackend installs a func backed by the live nodeBackend for
|
||||
// exact-match and self addresses, with [Engine.PeerKeyForIP]
|
||||
// supplying the subnet-route / exit-node fallback.
|
||||
// exact-match and self addresses, with the RouteManager's outbound
|
||||
// table supplying the subnet-route / exit-node fallback.
|
||||
SetPeerForIPFunc(fn func(netip.Addr) (_ PeerForIP, ok bool))
|
||||
|
||||
// PeerKeyForIP returns the peer's NodePublic and the matched prefix
|
||||
// for the longest-prefix match of ip in the engine's AllowedIPs
|
||||
// table (the wireguard config most recently installed via
|
||||
// [Engine.Reconfig]). Exit-node selection is honored: an unselected
|
||||
// exit node's 0.0.0.0/0 is not matched. It is the same table the
|
||||
// outbound packet hot path consults via [Engine.SetPeerByIPPacketFunc].
|
||||
PeerKeyForIP(netip.Addr) (_ key.NodePublic, _ netip.Prefix, ok bool)
|
||||
|
||||
// GetFilter returns the current packet filter, if any.
|
||||
GetFilter() *filter.Filter
|
||||
|
||||
|
||||
Reference in New Issue
Block a user