Commit Graph

178 Commits

Author SHA1 Message Date
Jason A. Donenfeld 1a3412f78d version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-04-12 21:05:12 -06:00
Jason A. Donenfeld cdb18ebf44 if_wg: set user cookie and fib through proper sockopts
By taking shortcuts we were circumventing important hooks.

Reported-by: Frank Behrens <frank@harz.behrens.de>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-04-12 20:52:55 -06:00
Jason A. Donenfeld a62c0f787d TODO: initial dump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-03-31 16:12:37 -06:00
Jason A. Donenfeld c3a6672207 if_wg: allow getting tunnelfib to race
It's word-sized, anyway, and taking the lock means crashes when moving
around vnets.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-03-24 12:45:48 -06:00
Jason A. Donenfeld 1f6818b7e4 if_wg: simplify jail exit logic
We already handle vnet stuff on wg_reassign, and handling it here means
that everytime we toggle any jail that shares the vnet, we render the
link useless.

Reported-by: Matt Smith <matt.r.smith@bt.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-03-24 12:03:58 -06:00
Jason A. Donenfeld a4741c838b if_wg: remove old link state check
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-03-24 10:42:10 -06:00
Jason A. Donenfeld 5bd562e699 if_wg: set persistent keepalive even if interface is down
Reported-by: Raúl Munoz <raul.munoz@custos.es>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-03-24 10:39:25 -06:00
Jason A. Donenfeld 5e9180cc5c version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-03-23 13:01:05 -06:00
Jason A. Donenfeld 3d79697665 if_wg: disable llv6
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-03-23 12:55:03 -06:00
Jason A. Donenfeld 8801509656 if_wg: drop pointtopoint flag
We'll try to work around this in wg-quick(8) and see what happens.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-03-23 12:24:42 -06:00
Jason A. Donenfeld 7d1aadc881 README: separate build stage
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-03-23 12:23:11 -06:00
Jason A. Donenfeld dfb1aa3251 if_wg: fix decryption failures on jumbo ingress
All of this allocation_order and copying garbage needs to go away by
making the crypto take scatter gather lists.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-03-23 11:51:00 -06:00
Frank Behrens 0a5c6abdfa if_wg: implement selection of FIB (routing table) for tunneled packets
The outgoing, encrypted packets can use a specified FIB and therefore
utilize specific (default) routes. The implementation follows the
existing convention for other tunnel interfaces and reuses some code
from gre(4) implementation.

The FIB for wg(4) interface is set by standard ifconfig(8) with
parameter "tunnelfib", e.g. "ifconfig wg0 tunnelfib 1".

Signed-off-by: Frank Behrens <frank@harz.behrens.de>
[Jason: rewritten to avoid sosockopt and simplify]
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-03-22 12:08:49 -06:00
Matt Dunwoodie fbf76929c0 wg_noise: ensure non-zero'd handshakes have a valid local index
As reported by: https://marc.info/?l=openbsd-bugs&m=161618496905444&w=2

In particular, when consuming an initiation, we don't generate the
index until creating the response (which is incorrect). If we attempt
to create an initiation between these processes, we drop any
outstanding handshake which in this case has index 0 as set when
consuming the initiation.

The fix attached is to generate the index when consuming the initiation
so that any spurious initiation creation can drop a valid index. The
patch also consolidates setting fields on the handshake.

Signed-off-by: Matt Dunwoodie <ncon@noconroy.net>
2021-03-22 11:46:02 -06:00
Jason A. Donenfeld 895a85337e compat: backport callout_func_t to 12.1
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-03-19 13:41:38 -06:00
Jason A. Donenfeld e8d9d54999 if_wg: do not check for null M_NOWAIT return
Reported-by: Kyle Evans <kevans@freebsd.org>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-03-19 13:08:42 -06:00
Jason A. Donenfeld cff0b4a210 version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-03-19 12:43:29 -06:00
Jason A. Donenfeld e59c33252e compat: backport properly to 13
Turns out that taskqgroup_drain_all is new in 14.

Reported-by: Evilham <contact@evilham.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-03-19 11:32:30 -06:00
Jason A. Donenfeld 6f1c5f3860 if_wg: cleanup timeout_t usage
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-03-19 10:55:14 -06:00
Jason A. Donenfeld bb59a61785 if_wg: mark as point to point
It's technically point to multipoint. Also, clear the multicast and
broadcast flags. This _could_ cause problems, but hopefully not.

This should fix issues with receiving incoming connections.

Reported-by: Ashish <ashish.is@lostca.se>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-03-19 10:46:49 -06:00
Jason A. Donenfeld ea256bde03 if_wg: dispatch packets using netisr
Nothing else uses ip_input directly.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-03-19 10:38:03 -06:00
Jason A. Donenfeld e99179b648 if_wg: fix malloc overflows
These should have been fixed during our initial pass but somehow
weren't. Good thing we have more time to work on this.

Note that all the exporting and marshalling intermediate structs are
going to have to be thrown out at some point, as this whole dance here
still allocates tons of kernel memory needlessly.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-03-19 10:06:09 -06:00
Jason A. Donenfeld 367c27cb02 compat: backport to FreeBSD 12.1
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-03-18 11:28:01 -06:00
Jason A. Donenfeld 3874141edd compat: backport to FreeBSD 12.2
This should allow us to get more testing coverage earlier.

This port here is also a bit janky. I really don't like the taskqgroup
business, having to copy and paste those structs. And this isn't well
tested, either. But, it's a start.

This distinguishes between compat.h and support.h, though both header
files are intended to operate in more or less the same way.  It's
important to keep some discipline between things that we're backporting
and things that aren't _yet_ upstream or are shims for OpenBSD.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-03-18 09:00:52 -06:00
Jason A. Donenfeld 39c05742f1 if_wg: use our own taskqgroup
Rather than relying on the iflib one, which not everyone has available,
define our own.

Reported-by: Frank Behrens <frank@harz.behrens.de>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-03-17 16:16:33 -06:00
Jason A. Donenfeld 57e37ff404 version: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-03-17 10:18:27 -06:00
Jason A. Donenfeld 8e0470dabb support: prepare for out of tree builds
This involves weird backporting things. Hopefully support.c here is not
as bad as compat.h on Linux.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-03-17 10:13:22 -06:00
Jason A. Donenfeld 362884e650 Initial import
There's still more to do with wiring this up properly.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-03-17 09:35:54 -06:00