You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Mac userspace subnet router binding to wrong interface #5719
On macOS, subnet routers forwarding connections on with netstack can bind to the wrong device when the machine has multiple NICs.
Situation from debug call:
macOS (one of the GUI builds)
three network devices (wired ethernet (primary), wifi, USB ethernet dongle with a /30 to a raspberry pi)
tailscale up --advertise-routes=192.168.1.0/30
The netstack forwarding code gets the packet and does an outbound TCP dial but netns binds the socket to the primary wired ethernet's NIC instead of the USB ethernet dongle.
We should look at the routing table and pick the right device.
I'm pretty sure this is because this code here picks the default route (i.e. "to the internet") to bind to, rather than the route for a specific destination:
I do; it's my system in question. Here's a partial dump just because it's wordy as hell, particularly on the ipv6 section; en0 is wired, en1 is wireless (same network), en8 is the other interface with a small network attached, utun5 is Tailscale.
This may have been fixed by #5940, which went into Tailscale release 1.32.2 for macOS.
App Store releases go through a gradual rollout process which starts with 1% of the fleet on the first day and gradually increases, your Mac may not have been prompted to update yet. Visiting the App Store page for Tailscale should show the update as available even if it hasn't prompted an update yet.
On the assumption that this will resolve this issue: barring further comment, we'll expect to close this during the next regular bug scrub.
(This is the magic phrase that we search for at the start of a bug scrub)
Reopening since we have another report of this issue.
The report was on version: TestFlight 1.35.99, commit ID a45c9f9
Some details from investigating with @mihaip and @andrew-d :
Based on logs, we can see that en0 is consistently chosen as the default route, which results in dropped packets meant to go to other interfaces. The routing code for macOS just selects the default route, while Linux does something a little different that results in setting the bypass mark and not explicitly binding to an interface.
To fix this, Mihai thinks that we’d need to loop over all interfaces and if any have explicitly set InterfaceIPs that matches the target address, prefer that over the default.
Activity
andrew-d commentedon Sep 22, 2022
I'm pretty sure this is because this code here picks the default route (i.e. "to the internet") to bind to, rather than the route for a specific destination:
tailscale/net/netns/netns_darwin_tailscaled.go
Line 35 in 0607832
andrew-d commentedon Sep 22, 2022
@bradfitz - Any chance you can get an (appropriately-redacted, if necessary) dump of
netstat -nrfrom the system in question?net/netns: use AF_ROUTE socket to determine what to bind to
bradfitz commentedon Sep 22, 2022
The line you link to is for tailscaled, not the GUI version. But similar.
I don't have the routing table output but it was as described above: a /30 on a separate link that wasn't the default route's.
quinnypig commentedon Sep 22, 2022
I do; it's my system in question. Here's a partial dump just because it's wordy as hell, particularly on the ipv6 section; en0 is wired, en1 is wireless (same network), en8 is the other interface with a small network attached, utun5 is Tailscale.
quinnypig commentedon Sep 27, 2022
Now that I'm not remote I can troubleshoot more accurately; what can I do to help?
DentonGentry commentedon Nov 1, 2022
This may have been fixed by #5940, which went into Tailscale release 1.32.2 for macOS.
App Store releases go through a gradual rollout process which starts with 1% of the fleet on the first day and gradually increases, your Mac may not have been prompted to update yet. Visiting the App Store page for Tailscale should show the update as available even if it hasn't prompted an update yet.
On the assumption that this will resolve this issue: barring further comment, we'll expect to close this during the next regular bug scrub.
(This is the magic phrase that we search for at the start of a bug scrub)
DentonGentry commentedon Jan 7, 2023
Fixed by #5940
fylie commentedon Jan 13, 2023
Reopening since we have another report of this issue.
The report was on version: TestFlight 1.35.99, commit ID a45c9f9
Some details from investigating with @mihaip and @andrew-d :
Based on logs, we can see that
en0is consistently chosen as the default route, which results in dropped packets meant to go to other interfaces. The routing code for macOS just selects the default route, while Linux does something a little different that results in setting the bypass mark and not explicitly binding to an interface.To fix this, Mihai thinks that we’d need to loop over all interfaces and if any have explicitly set
InterfaceIPsthat matches the target address, prefer that over the default.net/netns: add functionality to bind outgoing sockets based on route …
net/netns: add functionality to bind outgoing sockets based on route …
net/netns: add functionality to bind outgoing sockets based on route …
net/netns: add functionality to bind outgoing sockets based on route …
net/netns: add functionality to bind outgoing sockets based on route …
net/netns: add functionality to bind outgoing sockets based on route …
net/netns: add functionality to bind outgoing sockets based on route …
net/netns: add functionality to bind outgoing sockets based on route …
DentonGentry commentedon Feb 18, 2023
I believe #7065 is available in the current macOS TestFlight.
DentonGentry commentedon Jun 2, 2023
Believed fixed by #7065