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

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>

Reviewed by:	ivy (previous version), Jason A. Donenfeld, jhb
Differential Revision:	https://reviews.freebsd.org/D50450
This commit is contained in:
Kyle Evans 2025-06-25 21:57:03 -05:00
parent d15d610fac
commit f6d9e22982

View file

@ -307,11 +307,8 @@ static int kernel_set_device(struct wgdevice *dev)
nvl_aips[j] = nvlist_create(0);
if (!nvl_aips[j])
goto err_peer;
if (aip->flags) {
//TODO: implement me
ret = -EOPNOTSUPP;
goto err_peer;
}
if (aip->flags)
nvlist_add_number(nvl_aips[j], "flags", aip->flags);
nvlist_add_number(nvl_aips[j], "cidr", aip->cidr);
if (aip->family == AF_INET)
nvlist_add_binary(nvl_aips[j], "ipv4", &aip->ip4, sizeof(aip->ip4));