Since sbcreatecontrol() in sockbuf was improved on HEAD [1], the build of the port net/wireguard-kmod is broken with: cc -O2 -pipe -fno-strict-aliasing -include compat.h -Werror -D_KERNEL -DKLD_MODULE -nostdinc -include /usr/ports/net/wireguard-kmod/work/wireguard-freebsd-0.0.20211105/src/opt_global.h -I. -I/usr/src/sys -I/usr/src/sys/contrib/ck/include -fno-common -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fdebug-prefix-map=./machine=/usr/src/sys/amd64/include -fdebug-prefix-map=./x86=/usr/src/sys/x86/include -MD -MF.depend.if_wg.o -MTif_wg.o -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector -Wall -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error=tautological-compare -Wno-error=empty-body -Wno-error=parentheses-equality -Wno-error=unused-function -Wno-error=pointer-sign -Wno-error=shift-negative-value -Wno-address-of-packed-member -Wno-format-zero-length -mno-aes -mno-avx -std=iso9899:1999 -c if_wg.c -o if_wg.o if_wg.c:900:18: error: too few arguments to function call, expected 5, have 4 IPPROTO_IP); ^ /usr/src/sys/sys/sockbuf.h:161:2: note: 'sbcreatecontrol' declared here sbcreatecontrol(const void *p, u_int size, int type, int level, ^ if_wg.c:906:20: error: too few arguments to function call, expected 5, have 4 IPPROTO_IPV6); ^ /usr/src/sys/sys/sockbuf.h:161:2: note: 'sbcreatecontrol' declared here sbcreatecontrol(const void *p, u_int size, int type, int level, ^ [1] https://freshbsd.org/freebsd/src/commit/6890b588141a8298fc8a63700aeeea4ba36ca3f9
In fact, the error already occurs with the previous commit in HEAD [2], so base commit 2e5bf7c [3] is the last one to build net/wireguard-kmod with. [2] https://freshbsd.org/freebsd/src/commit/b46667c63eb7f126a56e23af1401d98d77b912e8 [3] https://freshbsd.org/freebsd/src/commit/2e5bf7c49fd2b6440ac49dbfe80d4384d3f645f1
Adding an extra M_WAITOK argument under proper #ifdef seems to be the way to go.
Created attachment 234075 [details] patch to add 'M_WAITOK' argument A probably not so elegant patch, which works for me on HEAD.
Created attachment 234232 [details] Alternative patch, using #define for sbcreatecontrol_now() I've been using this alternative patch, which uses a #define at the top of if_wg.c to go "back" to the old declaration of sbcreatecontrol_now(). This seems a bit simpler to me, and might be palatable for upstream. Talking of upstream, the kmod snapshot is ~6 months old now, isn't there any newer version?
Created attachment 234331 [details] updated port patch I'd suggest patch like Dimitry's but the opposite. Leave the function calls as in newer FreeBSD, but create a define for older FreeBSD. Here is patch-if_wg.c
(In reply to Gleb Smirnoff from comment #5) This worked for me. Thank you, Gleb. Probably the others are working too, but the maintainer should choose one of them and apply since the port is still broken on CURRENT.
Upstream has created a similar patch which is part of the next snapshot coming soon. https://git.zx2c4.com/wireguard-freebsd/commit/?id=c66627f1ea5b94925078bd972a5db648aebf90fe
Thanks all, update to 0.0.20220610 contains a fix for this build issue. https://cgit.freebsd.org/ports/commit/?id=b44715d91b98beefed44294caf090243e3ee1214