Commit Graph
49 Commits
Author SHA1 Message Date
Ryan Huber f3f98e1690 tun: Add opt-in staged transmit processing
Set tun.staged.workers to a positive count on Linux, with tun.use_offloads
enabled, to move encryption off each tun reader. The reader filters and
reserves counters for a whole read, hands the batch to that many encrypt
workers, and an ordered sender flushes the batches in read order. Eight slots
per routine bound the batches in flight; a full pipeline blocks the reader.
Zero workers, the default, keeps today's inline path, as do tun queues that
cannot hand off their read buffer and builds whose AES-GCM needs nonce-ordered
encryption (BoringCrypto, FIPS).

IMPORTANT: staged senders need peers with the 8192-entry replay window of
master. Released v1.11.x peers use 1024 and will drop reordered batches. The
window is not negotiated.

Readers keep today's pinning. The sender is only pinned with an explicit
tun.cpu_affinity: sender i uses entry i+1, unless that is its reader's CPU,
so a one-entry list leaves the sender unpinned rather than sharing it: two
busy transmit threads on one CPU serialise (eight TCP streams over 100 GbE
fell from 25.9 to 22.8 Gbit/s). Without a list the sender is not pinned. Placing it by queue index on a
hybrid CPU put it on an efficiency core, and one TCP stream over 100 GbE
reached 18.6-19.6 Gbit/s pinned against 20.2-20.6 unpinned.

New API, each needed across a package boundary:
- tio.Offload.SwapRxBuf hands the buffer of the last Read to the reader and
  reads into the one given. It is a method on the concrete queue, found through
  an unexported interface in nebula, so tio.Queue and its other
  implementations are unchanged.
- batch.SendBatch.Reset drops queued packets without sending, for a sender
  whose sockets are already closed; Flush now uses it.

Metrics, registered only for active pipelines: flow.tx.batches counts reads
handed to the sender, flow.stage.{tx_read,tx_encrypt,tx_send}.q<N>.busy_ns the
elapsed busy time of each stage, to find the limiting one.

Tests cover ordering and counters under backpressure with both ciphers (AES
skipped where nonce order is required), read errors with batches in flight,
shutdown, exhaustion, relays, fallback, firewall parity, and the actual reader
and send thread affinity for every placement, with pinning on and off: the
sender is pinned only to an explicit entry other than its reader's CPU.
2026-10-16 21:21:36 +00:00
Ryan Huber 6146f3e4a6 tun: Prepare batch counter reservation for staged encryption
Build on the inside-packet filtering split with shared preparation and encryption helpers for inline and reserved sends. Reserve each batch’s per-tunnel counter range before encryption, including relay counters, without enabling staged processing yet. Test reserved encryption against a real receiver and check segmentation counts.
2026-10-16 21:21:23 +00:00
Ryan Huber 6826c04103 tun: Separate inside-packet filtering from sending 2026-10-16 21:21:03 +00:00
Ryan Huber 8a2de9b1b5 examples: set socket buffers and raise tun tx_queue (#1928)
* examples: set socket buffers and raise tun tx_queue

* examples: use the default tcp max window for socket buffers

* examples: note buffers are linux only, clarify tx_queue default

* tun: default tx_queue to 5000
2026-10-11 00:30:07 -04:00
Ryan Huber e28336c5db probes to the lh are not generally useful as recv_error should catch (#408) 2023-03-29 15:09:36 -05:00
Ryan Huber 3aaaea6309 don't allow a useless handshake with yourself (#402)
* don't allow a useless handshake with yourself

* remove helper
2021-03-15 12:58:23 -07:00
Ryan Huber 73a5ed90b2 Do not allow someone to run a nebula lighthouse with an ephemeral port (#399)
* Do not allow someone to run a nebula lighthouse with an ephemeral port

* derp - we discover the port so we have to check the config setting

* No context needed for this error

* gofmt yourself

* Revert "gofmt yourself"

This reverts commit c01423498e.

* Revert "No context needed for this error"

This reverts commit 6792af6846.

* snip snap snip snap
2021-03-08 12:42:06 -08:00
Ryan Huber 43a3988afc i don't think this is used at all anymore (#323) 2020-10-29 21:43:50 -04:00
Ryan Huber 0d6b55e495 Bring in the new version of kardianos/service and output logfiles on osx (#303)
* this brings in the new version of kardianos/service which properly
outputs logs from launchd services

* add go sum

* is it really this easy?

* Update CHANGELOG.md
2020-09-24 15:34:08 -07:00
Ryan HuberandNate Brown 1297090af3 add configurable punching delay because of race-condition-y conntracks (#210)
* add configurable punching delay because of race-condition-y conntracks

* add changelog

* fix tests

* only do one punch per query

* Coalesce punchy config

* It is not is not set

* Add tests

Co-authored-by: Nate Brown <nbrown.us@gmail.com>
2020-03-27 11:26:39 -07:00
Ryan Huber 41968551f9 clarify that lighthouse IP should be nebula range (#196) 2020-02-28 11:35:55 -08:00
Ryan Huber a91a40212d check that packet isn't bound for my vpn ip (#192) 2020-02-21 16:49:54 -08:00
Ryan Huber 25bf80d8d3 add new invite link without expiration date (#165)
merging because link doesn't work rn and this is not a code change.
2020-01-16 10:09:45 -06:00
Ryan Huber 91f7b9c049 Update README.md
fix readme
2020-01-07 12:40:25 -06:00
Ryan Huber fd8ad5d0d7 Merge pull request #133 from slackhq/interval_zero_check
if interval is 0 don't even update lh (mobile use case)
2019-12-26 15:57:01 -06:00
Ryan Huber df8e45c13b if interval is 0 don't even update lh (mobile use case) 2019-12-26 21:12:31 +00:00
Ryan Huber fe58cedd2e Merge pull request #120 from slackhq/add_slack_link
add invitation link to readme
2019-12-20 08:33:38 -08:00
Ryan Huber 7ee692663d add invitation link to readme 2019-12-20 16:28:17 +00:00
Ryan Huber 2c8b0ec7b1 Merge pull request #105 from slackhq/fix_lighthouse_check
should be break not continue
2019-12-17 09:18:57 -06:00
Ryan Huber 5d0d916fc9 should be break not continue 2019-12-17 14:43:01 +00:00
Ryan Huber a680ac29f5 Merge pull request #98 from slackhq/warn_not_error
make this a warning, even though i believe it is fundamentally an error (in judgement)
2019-12-13 16:03:36 -06:00
Ryan Huber ad7079d370 make this a warning, even though i believe it is fundamentally an error
(in judgement)
2019-12-13 21:55:01 +00:00
Ryan Huber 6a37b26f9a Merge pull request #94 from infinytum/patch-1
Fix for Issue #90
2019-12-13 10:42:59 -06:00
Ryan Huber cec698b1b3 Merge pull request #91 from slackhq/fix_examle
derp- example config is now less silly
2019-12-12 12:59:15 -06:00
Ryan Huber cedf9549a6 derp- example config is now less silly 2019-12-12 18:50:52 +00:00
Ryan Huber 5217f28264 Merge pull request #79 from slackhq/subnet_support
Subnet and routing support.
2019-12-12 12:36:56 -06:00
Ryan Huber 9981510554 new mtu setting and const for default 2019-12-12 18:01:46 +00:00
Ryan Huber f03d895ebf don't steal error 2019-12-12 17:31:22 +00:00
Ryan Huber 9333a8e3b7 subnet support 2019-12-12 16:34:17 +00:00
Ryan Huber 5c99ea26c9 Merge pull request #83 from slackhq/remove_annotations
get rid of the annotation "errors" on github actions
2019-12-11 14:28:42 -06:00
Ryan Huber 1884aec113 get rid of the annotation "errors" on github actions 2019-12-11 20:24:13 +00:00
Ryan Huber ac72d1615a Merge pull request #49 from itorres/patch-1
Fix typo in getting started
2019-12-02 13:13:13 -06:00
Ryan Huber 6039b9f80a Merge pull request #60 from slackhq/yaml_file_rename
rename file to .yml to prevent confusion with example start scripts
2019-12-02 09:37:40 -06:00
Ryan Huber 15e6e0ad30 Merge pull request #3 from slackhq/self_installing_service
make nebula a service that can install itself
2019-12-02 09:37:09 -06:00
Ryan Huber 29c0523714 rename file to .yml to prevent confusion with example start scripts 2019-12-02 15:31:53 +00:00
Ryan Huber 2bff0b266e clean up makefile per wadey comment 2019-12-02 15:26:48 +00:00
Ryan Huber 3fe99aa065 change bin target to use variable for cmd path 2019-11-28 16:20:57 +00:00
Ryan Huber 00d6973e27 remove some boilerplate + better messages 2019-11-28 16:20:57 +00:00
Ryan Huber 8ed69c8eaf make nebula a service that can install itself 2019-11-28 16:20:57 +00:00
Ryan Huber 94441789d5 Merge pull request #41 from slackhq/lighthouse_static_map_error
Add an error (non fatal) when a lighthouse host has no static entry
2019-11-23 18:24:22 -06:00
Ryan Huber 08915315ff add tests and improve error 2019-11-23 23:55:23 +00:00
Ryan Huber 83d2550b2d add an error (non fatal) when a lighthouse host has no static entry 2019-11-23 21:46:45 +00:00
Ryan Huber 72a4e71ebc Merge pull request #35 from slackhq/chachacha
add chachapoly note to example config
2019-11-23 13:36:36 -06:00
Ryan Huber b01e181704 Merge pull request #37 from slackhq/remove_deprecated_hmac
remove old hmac function. superceded by ix_psk0
2019-11-23 13:33:50 -06:00
Ryan Huber 89f0d998cf remove old debug print statements 2019-11-23 17:01:10 +00:00
Ryan Huber 6a460ba38b remove old hmac function. superceded by ix_psk0 2019-11-23 16:50:36 +00:00
Ryan Huber 1dddd370bb Add chachapoly note and HUP note at the top 2019-11-23 15:12:56 +00:00
Ryan Huber ef324bf7e3 Merge pull request #31 from philippgille/patch-1
Fix config comment
2019-11-23 09:04:37 -06:00
Ryan Huber 498e792a46 add hole punching options to example config 2019-11-20 01:24:45 +00:00