Commit Graph

814 Commits

Author SHA1 Message Date
JackDoan 809d8baf47 batch: back SendBatch with Arena instead of a hand-rolled slab
SendBatch.Reserve duplicated Arena's grow-on-demand logic byte for byte.
Use an Arena for the slot backing so the borrow/grow/recycle semantics
live in one place.
2026-07-17 15:40:07 -05:00
JackDoan 327c8218e3 batch: move shared-arena Reset ownership from lanes to their owner 2026-07-17 15:40:07 -05:00
JackDoan b83893bad7 re-align to master 2026-07-17 15:40:07 -05:00
JackDoan 879f036e1f some tests 2026-07-17 15:40:07 -05:00
JackDoan 40b7d48868 simplify making new Queues 2026-07-17 15:40:07 -05:00
JackDoan 284c90c20e make service test less annoying 2026-07-17 15:40:07 -05:00
JackDoan e310292f76 checkpt 2026-07-17 15:40:07 -05:00
JackDoan 89850185f0 checkpt 2026-07-17 15:40:07 -05:00
JackDoan 1c9d8bcceb more ram -> more speed 2026-07-17 15:40:07 -05:00
JackDoan 7896f2093b more fixes! 2026-07-17 15:40:07 -05:00
JackDoan ee7d6cf90c more fixes! 2026-07-17 15:40:07 -05:00
JackDoan 7138a05f9b lint 2026-07-17 15:40:07 -05:00
JackDoan aacb4e2334 datapath: fix 12 correctness findings from tun/UDP offload review
Multi-disciplinary correctness review of the batched tun / GSO-GRO / sendmmsg
rework. Each fix has a regression test; the merged tree builds on
linux/darwin/openbsd/windows/freebsd/netbsd, vets clean, passes the unit and
e2e suites, and is -race clean.

Critical:
- C1 zero-length inner UDP datagram no longer panics the process (remote DoS):
  the UDP coalescer routes payLen==0 to passthrough instead of seeding a GSO
  slot, and WriteGSO skips empty payload iovecs as defense in depth.
- C2 segmenter no longer corrupts inner headers when gsoSize < headerLen: the
  L3+L4 header is snapshotted once and each segment stamped from the copy,
  replacing the destructive overlapping in-place slide (SegmentTCP + SegmentUDP).

High:
- H1 applyOuterECN updates the IPv4 header checksum (RFC 1624 incremental) when
  folding outer CE into the inner ToS, so passthrough packets are no longer
  dropped by the peer stack.
- H2 the GRO reject path caps the borrowed RX segment ([:n:n]) so a reject can
  no longer overrun into the next coalesced segment's Nebula header. Note:
  oversized ICMPv6 rejects that need >16B beyond the segment are now refused
  rather than sent under GRO (safe; see TOFIX.md for the scratch-buffer follow-up).
- H3 WriteBatch falls back to per-packet WriteTo for a chunk when writeSockaddr
  fails, so one bad-family destination costs only its own packet, not the batch.
- H4 UserDevice.Readers returns N distinct queue wrappers with private buffers
  (sharing the pipes) so concurrent readers no longer race/overwrite borrowed
  packet bytes.
- H5 Poll.Close / Offload.Close no longer null t.fd (matching master's
  tunFile.Close), removing the data race with a concurrent readOne load.

Medium/Low:
- M1 the UDP GSO 127-segment gate moved from kernel >=5.5 to >=6.9 (the real
  UDP_MAX_SEGMENTS 64->128 threshold), avoiding EINVAL + per-packet fallback on
  5.5-6.8 kernels.
- M2 NewMultiQueueReader replays the offload mask newTun actually negotiated
  instead of the TSO-only mask, so adding a queue no longer disables USO
  device-wide; the advertised USO capability derives from the same mask.
- M3 the shutdown eventfd is closed in pollQueueSet.Close / offloadQueueSet.Close
  (double-close guarded), fixing the per-lifecycle fd leak.
- M4 dual-stack ECN selects the cmsg by address family, not socket family: RX
  parseRecvCmsg reads both IP_TOS and IPV6_TCLASS; TX writeEntryCmsg stamps
  IP_TOS for v4/v4-mapped dests and IPV6_TCLASS for v6 (on-host verified).
- L1 newPoll no longer closes the fd on failure (matching newOffload), removing
  the double-close on QueueSet.Add error.
2026-07-17 15:40:07 -05:00
JackDoan 83a0a99f3f make mobile happy 2026-07-17 15:40:07 -05:00
JackDoan 6eda8f1594 correctly shutdown the pprofserver 2026-07-17 15:40:07 -05:00
JackDoan 46a5c56802 SendVia: don't emit a zero-length packet when prepareSendVia fails 2026-07-17 15:40:07 -05:00
JackDoan bd7ec8ab17 adapt Control lifecycle tests to the batched tio.Queue Device interface 2026-07-17 15:40:07 -05:00
JackDoan c185a661d0 udp setsockopt correctness fixes 2026-07-17 15:40:07 -05:00
JackDoan b263c42007 use less ram pls 2026-07-17 15:40:07 -05:00
JackDoan ab89e713fe clean up a comment a bit 2026-07-17 15:40:07 -05:00
JackDoan 4cd62302f5 drop in a logger 2026-07-17 15:40:07 -05:00
JackDoan dd30af2523 go mod tidy 2026-07-17 15:40:07 -05:00
JackDoan 5b1a182548 lint 2026-07-17 15:40:07 -05:00
JackDoan 4e5df42a76 fix 2026-07-17 15:40:07 -05:00
JackDoan 2caabe2453 faster
grr heap usage!
2026-07-17 15:40:07 -05:00
JackDoan 92df52a068 no 2026-07-17 15:40:07 -05:00
JackDoan 03fbdfee6e use clear() 2026-07-17 15:40:07 -05:00
JackDoan 3a9d8bca38 remove udp-level RX reorder buf 2026-07-17 15:40:07 -05:00
JackDoan f54922f134 make relays take the fast path maybe 2026-07-17 15:40:07 -05:00
JackDoan 866ee3798a scoot pinning around 2026-07-17 15:40:07 -05:00
JackDoan b3086ec9b6 scoot stuff around for e2e 2026-07-17 15:40:07 -05:00
JackDoan bed2840376 disable sort-on-RX, CPU pinning seems to work for now 2026-07-17 15:40:07 -05:00
JackDoan e56b92aef8 switch to ASM vector checksum 2026-07-17 15:40:07 -05:00
JackDoan a7740f5b64 GSO/GRO offloads, with TCP+ECN and UDP support 2026-07-17 15:40:07 -05:00
JackDoan 58b204407f better and batched tun interface 2026-07-17 15:40:07 -05:00
Nate Brown 147c202c27 Swap back to a blocking udp socket, test shutdown(2) (#1806)
Co-authored-by: Jack Doan <me@jackdoan.com>
2026-07-17 15:16:45 -05:00
John Maguire e290a6892f Fix relay re-establishment for handshake on Disestablised entry (#1805)
handleOutsideRelayPacket filled ViaSender.remoteIdx with relay.RemoteIndex,
an index from the relay peer's index space, but the rescue in
sendHandshakeResponse looks that value up in relayForByIdx, which is keyed
by local index. The lookup could never hit, so a terminal relay entry left
Disestablished by a one-sided teardown stayed Disestablished even after a
valid handshake arrived over it. The responder's first transmit then failed
to find an Established relay, deleted its only relay entry, and every
subsequent send was silently dropped until dead-tunnel detection forced a
re-handshake.
2026-07-17 11:57:47 -04:00
Nate Brown 6c3972f464 code-sign: default the S3 key-prefix to the calling repo (#1799) 2026-07-13 11:49:59 -05:00
Jack Doan 861d3aabd7 correct directionality of firewall.inbound_action and firewall.outbound_action (#1798) 2026-07-13 08:40:42 -05:00
Jack Doan 86733864fe don't make new relay state on a just-discarded tunnel (#1796) 2026-07-10 12:02:17 -05:00
Nate Brown ab736e4c6b Make Control safe to stop and wait on from any lifecycle state (#1794) 2026-07-10 10:35:17 -05:00
Nate Brown 5ecdd4eaa9 Fix e2e test races when looking at hostmap counts (#1795) 2026-07-09 18:48:14 -05:00
Nate Brown 1b84bd0050 Remove dev fmt.Println (#1793) 2026-07-09 11:04:25 -05:00
Nate Brown 384610f81a hostmap: replace the shared next/prev hostinfo chain with independent per-address lists so divergent or overlapping vpnAddr sets cannot corrupt the map (#1790) 2026-07-09 09:34:30 -05:00
Nate Brown c1eea118f4 fix firewall port/proto bypass in parseV6 from uint8 extension-header length overflow (#1789) 2026-07-07 20:43:26 -05:00
Nate Brown 1e66c0d3ee hostmap: unlink a multi-vpnAddr hostinfo from the shared chain exactly once on delete (#1788) 2026-07-07 17:32:25 -05:00
Nate Brown e5c0fdad8d Darwin and openbsd in line with the other bsds for tun support (#1703) 2026-07-07 17:05:12 -05:00
Nate Brown 7bd0bc285a sshd: guard trustedKeys/trustedCAs with a mutex to fix a concurrent map crash on reload (#1787) 2026-07-07 15:50:06 -05:00
Nate Brown 942ee522e0 lighthouse: unmap 4-in-6 addresses in protoV6AddrPortToNetAddrPort so remote_allow_list v4 rules apply (#1786) 2026-07-07 15:23:39 -05:00
dependabot[bot] 32149f3a93 Bump github.com/kardianos/service from 1.2.4 to 1.3.0 (#1782)
Bumps [github.com/kardianos/service](https://github.com/kardianos/service) from 1.2.4 to 1.3.0.
- [Commits](https://github.com/kardianos/service/compare/v1.2.4...v1.3.0)

---
updated-dependencies:
- dependency-name: github.com/kardianos/service
  dependency-version: 1.3.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-07-07 14:42:33 -05:00