tailscale/util/linuxfw
Brendan Creane 77d2c87b17
wgengine/router/osrouter,util/linuxfw: remove orphaned tailnet addrs (#20199)
Router.Set reconciled tailscale0's addresses only against the in-memory
r.addrs map, which starts empty each run. After a restart the kernel can
still hold the addresses a previous profile put on tailscale0. With no
record of them, Set never removed them, leaving two tailnets' CGNAT
addresses on the interface. That broke connectivity, because the kernel
could source traffic from the wrong IP.

Fix this by scanning the addresses actually on the interface and, after
reconciling the desired set, removing any in Tailscale's CGNAT/ULA ranges
that aren't in the config. Non-Tailscale addresses are never touched,
and IPv6 addresses are skipped when IPv6 is unavailable, since delAddress
no-ops there. To avoid a netlink dump on every Set, the scan runs only on
the first Set and when the desired address set changes.

This also needs the iptables DelLoopbackRule to tolerate a missing rule:
an orphan left by a previous instance never went through AddLoopbackRule
here, and iptables (unlike nftables) errors when deleting an absent
rule, which would otherwise block the address delete.

Fixes #19974

Signed-off-by: Brendan Creane <bcreane@gmail.com>
2026-06-24 13:41:36 -07:00
..
detector.go all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
fake_netfilter.go go.mod,wgengine/magicsock: pull wireguard-go fix for roaming endpoints (#20118) 2026-06-12 10:50:35 -07:00
fake.go util/linuxfw: fix nil pointer panic in connmark rules without IPv6 (#18946) 2026-03-10 15:19:15 -04:00
helpers.go all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
iptables_disabled.go all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
iptables_for_svcs_test.go all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
iptables_for_svcs.go all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
iptables_runner_test.go wgengine/router/osrouter,util/linuxfw: remove orphaned tailnet addrs (#20199) 2026-06-24 13:41:36 -07:00
iptables_runner.go wgengine/router/osrouter,util/linuxfw: remove orphaned tailnet addrs (#20199) 2026-06-24 13:41:36 -07:00
iptables.go all: use Go 1.26 things, run most gofix modernizers 2026-03-06 13:32:03 -08:00
linuxfw.go util/linuxfw: fix nftables endianness and add connmark conditional check (#19725) 2026-05-14 09:11:24 -04:00
nftables_for_svcs_test.go all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
nftables_for_svcs.go all: use Go 1.26 things, run most gofix modernizers 2026-03-06 13:32:03 -08:00
nftables_runner_test.go util/linuxfw: fix nftables endianness and add connmark conditional check (#19725) 2026-05-14 09:11:24 -04:00
nftables_runner.go util/linuxfw: clamp MSS to PMTU in both forward directions (#20077) 2026-06-22 11:25:15 +01:00
nftables_types.go all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
nftables.go all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00