summaryrefslogtreecommitdiffhomepage
path: root/wgengine/netstack
AgeCommit message (Collapse)AuthorFilesLines
2023-06-12ipn/ipnlocal,wgengine/netstack: move LocalBackend specifc serving logic to ↵Maisem Ali1-52/+8
LocalBackend The netstack code had a bunch of logic to figure out if the LocalBackend should handle an incoming connection and then would call the function directly on LocalBackend. Move that logic to LocalBackend and refactor the methods to return conn handlers. Updates #cleanup Signed-off-by: Maisem Ali <maisem@tailscale.com>
2023-06-12wgengine/netstack: increase maxInFlightConnectionAttemptsDenton Gentry1-1/+1
Address reports of subnet router instability when running in `--tun=userspace-networking` mode. Fixes https://github.com/tailscale/corp/issues/12184 Signed-off-by: Denton Gentry <dgentry@tailscale.com>
2023-05-28wgengine/netstack: use ping6 on BSD platformsDenton Gentry1-2/+12
Various BSD-derived operating systems including macOS and FreeBSD require that ping6 be used for IPv6 destinations. The "ping" command does not understand an IPv6 destination. FreeBSD 13.x and later do handle IPv6 in the regular ping command, but also retain a ping6 command. We use ping6 on all versions of FreeBSD. Fixes https://github.com/tailscale/tailscale/issues/8225 Signed-off-by: Denton Gentry <dgentry@tailscale.com>
2023-05-04tsd: add package with System type to unify subsystem init, discoveryBrad Fitzpatrick2-31/+18
This is part of an effort to clean up tailscaled initialization between tailscaled, tailscaled Windows service, tsnet, and the mac GUI. Updates #8036 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2023-04-10wgengine/netstack: fix data-race on startupJames Tucker1-2/+2
Running tailscaled with the race detector enabled immediately fires on this field, as it is updated after first read. Updates #cleanup Signed-off-by: James Tucker <james@tailscale.com>
2023-03-30envknob,net/tstun,wgengine: use TS_DEBUG_MTU consistentlyJames Tucker1-3/+2
Noted on #5915 TS_DEBUG_MTU was not used consistently everywhere. Extract the default into a function that can apply this centrally and use it everywhere. Added envknob.Lookup{Int,Uint}Sized to make it easier to keep CodeQL happy when using converted values. Updates #5915 Signed-off-by: James Tucker <james@tailscale.com>
2023-03-28wgengine/netstack: do not send packets to netstack after closeJames Tucker1-0/+8
Use the local context on Impl to check for shut down state in order to drop rather than inject packets after close has begun. Netstack sets endpoint.dispatcher to nil during shutdown. After the recent adjustment in 920ec69241930c352818b0bf3eab20e62df93ed1 we now wait for netstack to fully shutdown before we release tests. This means that we may continue to accept packets and attempt to inject them, which we must prevent in order to avoid nil pointer panic. References google/gvisor#8765 Fixes #7715 Signed-off-by: James Tucker <james@tailscale.com>
2023-03-27tsnet,wgenegine/netstack: add test and fix resource leaksMaisem Ali1-0/+1
We were not closing the http.Server and were also not waiting for netstack to fully close. Signed-off-by: Maisem Ali <maisem@tailscale.com>
2023-03-23net/tstun: rename filterIn/filterOut methods to be more descriptiveMaisem Ali1-2/+2
Updates tailscale/corp#8020 Signed-off-by: Maisem Ali <maisem@tailscale.com>
2023-03-23all: pass log IDs as the proper type rather than stringsWill Norris1-2/+3
This change focuses on the backend log ID, which is the mostly commonly used in the client. Tests which don't seem to make use of the log ID just use the zero value. Signed-off-by: Will Norris <will@tailscale.com>
2023-03-07tsnet: only intercept TCP flows that have listenersMaisem Ali1-10/+25
Previously, it would accept all TCP connections and then close the ones it did not care about. Make it only ever accept the connections that it cares about. Signed-off-by: Maisem Ali <maisem@tailscale.com>
2023-03-05wgengine/netstack: add support for custom UDP flow handlersBrad Fitzpatrick1-6/+33
To be used by tsnet and sniproxy later. Updates #5871 Updates #1748 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2023-02-01all: use Go 1.20's bytes.CloneBrad Fitzpatrick1-2/+3
Updates #7123 Updates #6257 (more to do in other repos) Change-Id: I073e2a6d81a5d7fbecc29caddb7e057ff65239d0 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2023-01-30ipn/ipnlocal: drop not required StateKey parameterMaisem Ali1-2/+2
This is #cleanup now that #7121 is merged. Signed-off-by: Maisem Ali <maisem@tailscale.com>
2023-01-27all: update copyright and license headersWill Norris4-12/+8
This updates all source files to use a new standard header for copyright and license declaration. Notably, copyright no longer includes a date, and we now use the standard SPDX-License-Identifier header. This commit was done almost entirely mechanically with perl, and then some minimal manual fixes. Updates #6865 Signed-off-by: Will Norris <will@tailscale.com>
2023-01-19wgengine/netstack: fix data race in testsAndrew Dunham1-6/+2
This uses the helper function added in #6173 to avoid flakes like: https://github.com/tailscale/tailscale/actions/runs/3826912237/jobs/6511078024 Signed-off-by: Andrew Dunham <andrew@du.nham.ca> Change-Id: If3f1d3b9c0f64ffcb4ba9a30d3522ec49484f993
2022-12-23wgengine/netstack: change netstack API to require LocalBackendClaire Wang2-53/+46
The macOS client was forgetting to call netstack.Impl.SetLocalBackend. Change the API so that it can't be started without one, eliminating this class of bug. Then update all the callers. Updates #6764 Change-Id: I2b3a4f31fdfd9fdbbbbfe25a42db0c505373562f Signed-off-by: Claire Wang <claire@tailscale.com> Co-authored-by: Brad Fitzpatrick <bradfitz@tailscale.com> Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-12-22wgengine/netstack: delete some dead code, old comment, use atomic int typesBrad Fitzpatrick2-13/+7
Noticed while looking at something else; #cleanup. Change-Id: Icde7749363014eab9bebe1dd80708f5491f933d1 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-12-20go.mod, etc: bump gvisorandig2-22/+9
Fixes #6554 Change-Id: Ia04ae37a47b67fa57091c9bfe1d45a1842589aa8 Signed-off-by: andig <cpuidle@gmx.de>
2022-11-22ipn/ipnlocal: call checkPrefs in Start tooMaisem Ali1-5/+10
We were not calling checkPrefs on `opts.*Prefs` in (*LocalBackend).Start(). Updates #713 Signed-off-by: Maisem Ali <maisem@tailscale.com>
2022-11-11ipn/ipnlocal: add support for multiple user profilesMaisem Ali1-11/+6
Signed-off-by: Maisem Ali <maisem@tailscale.com>
2022-11-09ipn/ipnlocal: add start of handling TCP proxyingBrad Fitzpatrick1-4/+9
Updates tailscale/corp#7515 Change-Id: I82d19b5864674b2169f25ec8e429f60a543e0c57 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-11-08wgengine/netstack: optimize shouldProcessInbound, avoiding 4via6 lookupsBrad Fitzpatrick2-3/+11
All IPv6 packets for the self address were doing netip.Prefix.Contains lookups. If if we know they're for a self address (which we already previously computed and have sitting in a bool), then they can't be for a 4via6 range. Change-Id: Iaaaf1248cb3fecec229935a80548ead0eb4cb892 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-11-08ipn/ipnlocal, wgengine/netstack: start handling ports for future servingbradfitz/port_interceptBrad Fitzpatrick1-3/+10
Updates tailscale/corp#7515 Change-Id: I966e936e72a2ee99be8d0f5f16872b48cc150258 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-11-08wgengine/netstack: add tests for shouldProcessInboundAndrew Dunham1-0/+221
Inspired by #6235, let's explicitly test the behaviour of this function to ensure that we're not processing things we don't expect to. Change-Id: I158050a63be7410fb99452089ea607aaf89fe91a Signed-off-by: Andrew Dunham <andrew@tailscale.com>
2022-11-08wgengine/netstack: fix shouldProcessInbound peerapi non-SYN handlingBrad Fitzpatrick1-15/+15
It was eating TCP packets to peerapi ports to subnet routers. Some of the TCP flow's packets went onward, some got eaten. So some TCP flows to subnet routers, if they used an unfortunate TCP port number, got broken. Change-Id: Ifea036119ccfb081f4dfa18b892373416a5239f8 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-11-02wgengine/netstack: remove old unused handleSSH hookBrad Fitzpatrick1-4/+0
It's leftover from an earlier Tailscale SSH wiring and I forgot to delete it apparently. Change-Id: I14f071f450e272b98d90080a71ce68ba459168d1 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-10-31wgengine/netstack: use 72h as the KeepAlive Idle time for Tailscale SSHMaisem Ali1-4/+13
Setting TCP KeepAlives for Tailscale SSH connections results in them unnecessarily disconnecting. However, we can't turn them off completely as that would mean we start leaking sessions waiting for a peer to come back which may have gone away forever (e.g. if the node was deleted from the tailnet during a session). Updates #5021 Signed-off-by: Maisem Ali <maisem@tailscale.com>
2022-10-25wgengine/netstack: enable TCP SACK (#6066)Jordan Whited1-0/+5
TCP selective acknowledgement can improve throughput by an order of magnitude in the presence of loss. Signed-off-by: Jordan Whited <jordan@tailscale.com>
2022-09-26all: fix resource leaks with missing .Close() callsEmmanuel T Odeke1-0/+3
Fixes #5706 Signed-off-by: Emmanuel T Odeke <emmanuel@orijtech.com>
2022-09-21wgengine/netstack: always respond to 4via6 echo requests (#5712)Andrew Dunham2-49/+68
As the comment in the code says, netstack should always respond to ICMP echo requests to a 4via6 address, even if the netstack instance isn't normally processing subnet traffic. Follow-up to #5709 Change-Id: I504d0776c5824071b2a2e0e687bc33e24f6c4746 Signed-off-by: Andrew Dunham <andrew@tailscale.com>
2022-09-21wgengine/netstack: handle 4via6 packets when pinging (#5709)Andrew Dunham2-2/+208
Change-Id: Ib6ebbaa11219fb91b550ed7fc6ede61f83262e89 Signed-off-by: Andrew Dunham <andrew@tailscale.com>
2022-09-15envknob: support changing envknobs post-initBrad Fitzpatrick1-9/+9
Updates #5114 Change-Id: Ia423fc7486e1b3f3180a26308278be0086fae49b Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-09-06wgengine/netstack: only accept connection after dialing (#5503)Andrew Dunham1-34/+84
If we accept a forwarded TCP connection before dialing, we can erroneously signal to a client that we support IPv6 (or IPv4) without that actually being possible. Instead, we only complete the client's TCP handshake after we've dialed the outbound connection; if that fails, we respond with a RST. Updates #5425 (maybe fixes!) Signed-off-by: Andrew Dunham <andrew@tailscale.com>
2022-08-04all: use syncs.AtomicValueMaisem Ali1-2/+2
Signed-off-by: Maisem Ali <maisem@tailscale.com>
2022-08-02all: migrate code from netaddr.FromStdAddr to Go 1.18Brad Fitzpatrick1-4/+17
With caveat https://github.com/golang/go/issues/53607#issuecomment-1203466984 that then requires a new wrapper. But a simpler one at least. Updates #5162 Change-Id: I0a5265065bfcd7f21e8dd65b2bd74cae90d76090 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-08-02all: migrate more code code to net/netip directlyBrad Fitzpatrick1-3/+4
Instead of going through the tailscale.com/net/netaddr transitional wrappers. Updates #5162 Change-Id: I3dafd1c2effa1a6caa9b7151ecf6edd1a3fda3dd Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-07-25all: convert more code to use net/netip directlyBrad Fitzpatrick2-26/+27
perl -i -npe 's,netaddr.IPPrefixFrom,netip.PrefixFrom,' $(git grep -l -F netaddr.) perl -i -npe 's,netaddr.IPPortFrom,netip.AddrPortFrom,' $(git grep -l -F netaddr. ) perl -i -npe 's,netaddr.IPPrefix,netip.Prefix,g' $(git grep -l -F netaddr. ) perl -i -npe 's,netaddr.IPPort,netip.AddrPort,g' $(git grep -l -F netaddr. ) perl -i -npe 's,netaddr.IP\b,netip.Addr,g' $(git grep -l -F netaddr. ) perl -i -npe 's,netaddr.IPv6Raw\b,netip.AddrFrom16,g' $(git grep -l -F netaddr. ) goimports -w . Then delete some stuff from the net/netaddr shim package which is no longer neeed. Updates #5162 Change-Id: Ia7a86893fe21c7e3ee1ec823e8aba288d4566cd8 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-07-25net/netaddr: start migrating to net/netip via new netaddr adapter packageBrad Fitzpatrick2-26/+26
Updates #5162 Change-Id: Id7bdec303b25471f69d542f8ce43805328d56c12 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-07-21go.mod: bump gvisor.dev/gvisorMaisem Ali1-6/+5
Pick up https://github.com/google/gvisor/pull/7787 Signed-off-by: Maisem Ali <maisem@tailscale.com>
2022-06-28wgengine/netstack: close ipstack when netstack.Impl is closedkylecarbs1-0/+1
Fixes netstack.Impl leaking goroutines after shutdown. Signed-off-by: kylecarbs <kyle@carberry.com>
2022-06-02wgengine/netstack: replace a 1500 with a const + docBrad Fitzpatrick1-1/+6
Per post-submit code review feedback of 1336fb740b7f from @maisem. Change-Id: Ic5c16306cbdee1029518448642304981f77ea1fd Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-06-01wgengine/netstack: make netstack MTU be 1280 alsoBrad Fitzpatrick1-2/+2
Updates #3878 Change-Id: I1850085b32c8a40d85607b4ad433622c97d96a8d Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-05-20wgengine/netstack: handle multiple magicDNS queries per UDP socket (#4708)Tom1-11/+26
Fixes: #4686 Signed-off-by: Tom DNetto <tom@tailscale.com>
2022-05-06wgengine/netstack, ipn/ipnlocal: serve http://100.100.100.100/Brad Fitzpatrick1-0/+5
For future stuff. Change-Id: I64615b8b2ab50b57e4eef1ca66fa72e3458cb4a9 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-05-05net/dns, wgengine: implement DNS over TCP (#4598)Tom1-0/+18
* net/dns, wgengine: implement DNS over TCP Signed-off-by: Tom DNetto <tom@tailscale.com> * wgengine/netstack: intercept only relevant port/protocols to quad-100 Signed-off-by: Tom DNetto <tom@tailscale.com>
2022-05-04*: use WireGuard where logged, printed or namedJames Tucker1-1/+1
Signed-off-by: James Tucker <james@tailscale.com>
2022-04-30assorted: documentation and readability fixesTom DNetto1-2/+2
This were intended to be pushed to #4408, but in my excitement I forgot to git push :/ better late than never. Signed-off-by: Tom DNetto <tom@tailscale.com>
2022-04-30net/tstun,wgengine/{.,netstack}: handle UDP magicDNS traffic in netstackTom DNetto2-11/+121
This change wires netstack with a hook for traffic coming from the host into the tun, allowing interception and handling of traffic to quad-100. With this hook wired, magicDNS queries over UDP are now handled within netstack. The existing logic in wgengine to handle magicDNS remains for now, but its hook operates after the netstack hook so the netstack implementation takes precedence. This is done in case we need to support platforms with netstack longer than expected. Signed-off-by: Tom DNetto <tom@tailscale.com>
2022-04-30cmd/tailscaled,ipn/ipnlocal,wgengine/...: pass dns.Manager into netstackTom DNetto1-1/+4
Needed for a following commit which moves magicDNS handling into netstack. Signed-off-by: Tom DNetto <tom@tailscale.com>