summaryrefslogtreecommitdiffhomepage
path: root/net/tstun
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@tailscale.com>2026-04-15 00:49:12 +0000
committerBrad Fitzpatrick <bradfitz@tailscale.com>2026-04-25 01:53:13 +0000
commitf9cd7ada42a79a0ce552ec597f230bc7bf9a5702 (patch)
treeee4d73e8041520b402c13190f26aec5e71785129 /net/tstun
parent873b8b8e2e537026d3947df74399439d31d7dfbb (diff)
downloadtailscale-bradfitz/rm_lazy_wg.tar.xz
tailscale-bradfitz/rm_lazy_wg.zip
wgengine, all: remove LazyWG, use wireguard-go callback API for on-demand peersbradfitz/rm_lazy_wg
Replace the UAPI text protocol-based wireguard configuration with wireguard-go's new direct callback API (SetPeerLookupFunc, SetPeerByIPPacketFunc, RemoveMatchingPeers, SetPrivateKey). Instead of computing a trimmed wireguard config ahead of time upon control plane updates and pushing it via UAPI, install callbacks so wireguard-go creates peers on demand when packets arrive. This removes all the LazyWG trimming machinery: idle peer tracking, activity maps, noteRecvActivity callbacks, the KeepFullWGConfig control knob, and the ts_omit_lazywg build tag. For incoming packets, PeerLookupFunc answers wireguard-go's questions about unknown public keys by looking up the peer in the full config. For outgoing packets, PeerByIPPacketFunc (installed from LocalBackend.lookupPeerByIP) maps destination IPs to node public keys using the existing nodeByAddr index. Updates tailscale/corp#12345 Change-Id: I4cba80979ac49a1231d00a01fdba5f0c2af95dd8 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
Diffstat (limited to 'net/tstun')
-rw-r--r--net/tstun/wrap.go28
1 files changed, 1 insertions, 27 deletions
diff --git a/net/tstun/wrap.go b/net/tstun/wrap.go
index 1b28eb157..cd75aff5c 100644
--- a/net/tstun/wrap.go
+++ b/net/tstun/wrap.go
@@ -111,8 +111,7 @@ type Wrapper struct {
// you might need to add an align64 field here.
lastActivityAtomic mono.Time // time of last send or receive
- destIPActivity syncs.AtomicValue[map[netip.Addr]func()]
- discoKey syncs.AtomicValue[key.DiscoPublic]
+ discoKey syncs.AtomicValue[key.DiscoPublic]
// timeNow, if non-nil, will be used to obtain the current time.
timeNow func() time.Time
@@ -340,16 +339,6 @@ func (t *Wrapper) now() time.Time {
return time.Now()
}
-// SetDestIPActivityFuncs sets a map of funcs to run per packet
-// destination (the map keys).
-//
-// The map ownership passes to the Wrapper. It must be non-nil.
-func (t *Wrapper) SetDestIPActivityFuncs(m map[netip.Addr]func()) {
- if buildfeatures.HasLazyWG {
- t.destIPActivity.Store(m)
- }
-}
-
// SetDiscoKey sets the current discovery key.
//
// It is only used for filtering out bogus traffic when network
@@ -997,13 +986,6 @@ func (t *Wrapper) Read(buffs [][]byte, sizes []int, offset int) (int, error) {
for _, data := range res.data {
p.Decode(data[res.dataOffset:])
- if buildfeatures.HasLazyWG {
- if m := t.destIPActivity.Load(); m != nil {
- if fn := m[p.Dst.Addr()]; fn != nil {
- fn()
- }
- }
- }
if buildfeatures.HasCapture && captHook != nil {
captHook(packet.FromLocal, t.now(), p.Buffer(), p.CaptureMeta)
}
@@ -1136,14 +1118,6 @@ func (t *Wrapper) injectedRead(res tunInjectedRead, outBuffs [][]byte, sizes []i
pc.snat(p)
invertGSOChecksum(pkt, gso)
- if buildfeatures.HasLazyWG {
- if m := t.destIPActivity.Load(); m != nil {
- if fn := m[p.Dst.Addr()]; fn != nil {
- fn()
- }
- }
- }
-
if res.packet != nil {
var gsoOptions tun.GSOOptions
gsoOptions, err = stackGSOToTunGSO(pkt, gso)