Skip to content

Commit

Permalink
wgengine/netstack: fix 4via6 subnet routes
Browse files Browse the repository at this point in the history
Fix a bug where, for a subnet router that advertizes
4via6 route, all packets with a source IP matching
the 4via6 address were being sent to the host itself.
Instead, only send to host packets whose destination
address is host's local address.

Fixes #12448

Co-authored-by: Andrew Dunham <andrew@du.nham.ca>
Signed-off-by: Irbe Krumina <irbe@tailscale.com>
  • Loading branch information
irbekrm and andrew-d committed Jun 13, 2024
1 parent ccdd2e6 commit abf2e95
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions wgengine/netstack/netstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -831,10 +831,17 @@ func (ns *Impl) inject() {
// Only send to the host if this 4via6 route is
// something this node handles.
if ns.lb != nil && ns.lb.ShouldHandleViaIP(srcIP) {
sendToHost = true
if debugNetstack() {
ns.logf("netstack: sending 4via6 packet to host: %v", srcIP)
}
dstIP := netip.AddrFrom16(v.DestinationAddress().As16())
// Also, only forward to the host if
// the packet is destined for a local
// IP; otherwise, we'd send traffic
// that's intended for another peer
// from the local 4via6 address to the
// host instead of outbound to
// WireGuard. See:
// https://github.com/tailscale/tailscale/issues/12448
sendToHost = ns.isLocalIP(dstIP)
ns.logf("netstack: sending 4via6 packet to host: src=%v dst=%v", srcIP, dstIP)
}
}
default:
Expand Down

0 comments on commit abf2e95

Please sign in to comment.