diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-03-17 17:43:55 -0600 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-03-18 09:00:52 -0600 |
commit | 3874141edd2f77e13ee78371798db225b35b7c7e (patch) | |
tree | 4dcd225bf1ceb4973264d8c01e3e285c503d7f2d /src/support.h | |
parent | if_wg: use our own taskqgroup (diff) | |
download | wireguard-freebsd-3874141edd2f77e13ee78371798db225b35b7c7e.tar.xz wireguard-freebsd-3874141edd2f77e13ee78371798db225b35b7c7e.zip |
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>
Diffstat (limited to 'src/support.h')
-rw-r--r-- | src/support.h | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/support.h b/src/support.h index c4038cf..5256e62 100644 --- a/src/support.h +++ b/src/support.h @@ -2,6 +2,9 @@ * * Copyright (C) 2021 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved. * Copyright (C) 2021 Matt Dunwoodie <ncon@noconroy.net> + * + * support.h contains functions that are either not _yet_ upstream in FreeBSD 14, or are shimmed + * from OpenBSD. It is different from compat.h, which is strictly for backports. */ #ifndef _WG_SUPPORT @@ -15,6 +18,9 @@ #include <sys/malloc.h> #include <sys/proc.h> #include <sys/lock.h> +#include <sys/socketvar.h> +#include <sys/protosw.h> +#include <net/vnet.h> #include <vm/uma.h> /* TODO the following is openbsd compat defines to allow us to copy the wg_* @@ -65,7 +71,15 @@ siphash24(const SIPHASH_KEY *key, const void *src, size_t len) #define IFT_WIREGUARD IFT_PPP #endif -int -sogetsockaddr(struct socket *so, struct sockaddr **nam); +static inline int +sogetsockaddr(struct socket *so, struct sockaddr **nam) +{ + int error; + + CURVNET_SET(so->so_vnet); + error = (*so->so_proto->pr_usrreqs->pru_sockaddr)(so, nam); + CURVNET_RESTORE(); + return (error); +} #endif |