Page MenuHomeFreeBSD

wg: ipc: add allowed-ip flags support for FreeBSD
ClosedPublic

Authored by kevans on May 21 2025, 4:00 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Jul 14, 5:02 AM
Unknown Object (File)
Mon, Jul 14, 2:57 AM
Unknown Object (File)
Sat, Jul 12, 8:00 PM
Unknown Object (File)
Mon, Jul 7, 10:46 AM
Unknown Object (File)
Mon, Jul 7, 7:45 AM
Unknown Object (File)
Wed, Jul 2, 2:42 PM
Unknown Object (File)
Tue, Jul 1, 7:24 PM
Unknown Object (File)
Mon, Jun 30, 7:33 AM

Details

Summary

For $reasons, we can't rely on flags in wireguard-tools for the kernel
side of WireGuard. Provide a mapping function that uses flags from the
kernel that we're building against and fail the operation if we made it
to the end without turning some wg(8) flag off.

Signed-off-by: Kyle Evans <kevans@FreeBSD.org>

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This revision is now accepted and ready to land.May 23 2025, 7:48 PM

For $reasons

Specifically, for the sake of out-of-tree builds of the wireguard tools on older FreeBSD? Or something else?

contrib/wireguard-tools/ipc-freebsd.h
24

Make this const and allowedip_flagp a pointer to const?

contrib/wireguard-tools/ipc-freebsd.h
26

Can we not just choose to make the flag you add in the kernel use the same constant value and name as the existing flag?

For $reasons

Specifically, for the sake of out-of-tree builds of the wireguard tools on older FreeBSD? Or something else?

Right; I've since chatted with @jason_zx2c4.com a bit and he pointed out that the linux/uap version won't bother validating beforehand, so I think it makes sense to just keep the flag bits in sync, pass them through and let the kernel complain (or not).

contrib/wireguard-tools/ipc-freebsd.h
26

I went ahead and ripped all of this out, renamed the flag and noted to keep it in sync with containers.h.

Rip out everything existing, let's just assume FreeBSD's kernel module syncs
the flag bits appropriately and will reject flags it doesn't know about yet.

Also note that this fixes a Coverity report after the last wireguard-tools
import, but I don't have the CID on-hand. The assignment to ret in the
EOPNOTSUPP path is immediately made redundant as the first instruction after
the err_peer label is to re-assign ret.

This revision now requires review to proceed.Jun 12 2025, 1:00 AM
This revision is now accepted and ready to land.Jun 17 2025, 5:05 PM