tailscale/wgengine
Dmytro Shynkevych 33b2f30cea
wgengine: wrap tun.Device to support filtering and packet injection (#358)
Right now, filtering and packet injection in wgengine depend
on a patch to wireguard-go that probably isn't suitable for upstreaming.

This need not be the case: wireguard-go/tun.Device is an interface.
For example, faketun.go implements it to mock a TUN device for testing.

This patch implements the same interface to provide filtering
and packet injection at the tunnel device level,
at which point the wireguard-go patch should no longer be necessary.

This patch has the following performance impact on i7-7500U @ 2.70GHz,
tested in the following namespace configuration:
┌────────────────┐    ┌─────────────────────────────────┐     ┌────────────────┐
│      $ns1      │    │               $ns0              │     │      $ns2      │
│    client0     │    │      tailcontrol, logcatcher    │     │     client1    │
│  ┌─────┐       │    │  ┌──────┐         ┌──────┐      │     │  ┌─────┐       │
│  │vethc│───────┼────┼──│vethrc│         │vethrs│──────┼─────┼──│veths│       │
│  ├─────┴─────┐ │    │  ├──────┴────┐    ├──────┴────┐ │     │  ├─────┴─────┐ │
│  │10.0.0.2/24│ │    │  │10.0.0.1/24│    │10.0.1.1/24│ │     │  │10.0.1.2/24│ │
│  └───────────┘ │    │  └───────────┘    └───────────┘ │     │  └───────────┘ │
└────────────────┘    └─────────────────────────────────┘     └────────────────┘
Before:
---------------------------------------------------
| TCP send               | UDP send               |
|------------------------|------------------------|
| 557.0 (±8.5) Mbits/sec | 3.03 (±0.02) Gbits/sec |
---------------------------------------------------
After:
---------------------------------------------------
| TCP send               | UDP send               |
|------------------------|------------------------|
| 544.8 (±1.6) Mbits/sec | 3.13 (±0.02) Gbits/sec |
---------------------------------------------------
The impact on receive performance is similar.

Signed-off-by: Dmytro Shynkevych <dmytro@tailscale.com>
2020-05-13 09:16:17 -04:00
..
filter ipn, wgengine/filter: remove exported type aliases 2020-05-11 07:19:17 -07:00
magicsock wgengine: wrap tun.Device to support filtering and packet injection (#358) 2020-05-13 09:16:17 -04:00
monitor wgengine/monitor: disable monitor on Android 2020-04-24 06:35:31 -07:00
packet wgengine/filter: support subnet mask rules, not just /32 IPs. 2020-04-30 04:56:43 -04:00
router wgengine/router: rename config.Settings to config.Config, make pointer. 2020-05-12 15:58:33 -07:00
tstun wgengine: wrap tun.Device to support filtering and packet injection (#358) 2020-05-13 09:16:17 -04:00
winnet Move Linux client & common packages into a public repo. 2020-02-09 09:32:57 -08:00
rusage.go Move "logger" package to under types, now that we have it. 2020-02-14 20:23:05 -08:00
rusage_nowindows.go wgengine: flesh out some docs 2020-02-12 13:37:45 -08:00
rusage_windows.go Move Linux client & common packages into a public repo. 2020-02-09 09:32:57 -08:00
userspace.go wgengine: wrap tun.Device to support filtering and packet injection (#358) 2020-05-13 09:16:17 -04:00
watchdog.go wgengine/router: rename config.Settings to config.Config, make pointer. 2020-05-12 15:58:33 -07:00
watchdog_test.go wgengine: wrap tun.Device to support filtering and packet injection (#358) 2020-05-13 09:16:17 -04:00
wgengine.go wgengine/router: rename config.Settings to config.Config, make pointer. 2020-05-12 15:58:33 -07:00