[GH-ISSUE #68] ipc-freebsd.h does not compile since 3.0: still written against the old containers.h #29

Open
opened 2026-10-13 21:02:33 +00:00 by bsakaguchi · 0 comments
Owner

Originally created by @MarceloMayo74 on GitHub (Aug 17, 2026).
Original GitHub issue: https://github.com/amnezia-vpn/amneziawg-tools/issues/68

src/ipc-freebsd.h does not compile from 3.0 onwards: it is still written against the pre-3.x containers.h, so amneziawg-tools cannot be built for FreeBSD at all without disabling the kernel IPC path.

Reproduce

On FreeBSD 16.0-CURRENT amd64, from the tarball of tag v3.1.20260812:

gmake -C src PLATFORM=freebsd wg

What happens

./ipc-freebsd.h:160:14: error: no member named 'response_packet_magic_header' in 'struct wgdevice'
  160 |                 if (!dev->response_packet_magic_header) {
      |                      ~~~  ^
./ipc-freebsd.h:169:24: error: use of undeclared identifier 'MAX_AWG_STRING_LEN'
  169 |         if (binary && size < MAX_AWG_STRING_LEN)
      |                              ^~~~~~~~~~~~~~~~~~
./ipc-freebsd.h:453:44: error: no member named 'init_packet_magic_header' in 'struct wgdevice'
  453 |         nvlist_add_binary(nvl_device, "h1", dev->init_packet_magic_header, ...
      |                                             ~~~  ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

Cause

ipc-freebsd.h reads and writes H1–H4 as strings — dev->init_packet_magic_header and friends — and uses MAX_AWG_STRING_LEN to bound them. In 3.x containers.h those are ranges:

u32_range_t init_header, resp_header, cookie_header, transport_header;

and MAX_AWG_STRING_LEN is gone. The file is byte for byte identical in v3.0.20260805 and v3.1.20260812 (sha256 7ee38c20…), and both carry 21 references to identifiers that no longer exist, so this has been broken since the 3.0 line opened. The Linux and Windows paths were updated; this one was not, which is easy to miss because the release workflow builds Alpine, Ubuntu and Windows only.

Suggested fix

Port ipc-freebsd.h to the current containers.h: send H1–H4 through the nvlist as the range type the rest of the tree now uses, and drop the string bounds check. The 3.x device keys — header_protection_key, content_padding_addition, the timings, random_trailers, disable_cookies — would need adding there too if the FreeBSD kernel module is meant to reach parity.

Workaround, for anyone who lands here

Building with -DAWG_NO_KERNEL_IPC and this one-line change to ipc.c

-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) && !defined(AWG_NO_KERNEL_IPC)

leaves the file out and produces a working awg that speaks only the userspace UAPI. That is enough when the peer is amneziawg-go, which is the only option on FreeBSD-based systems that cannot load if_amn — pfSense, for instance. It is obviously not a fix for anyone using the kernel module.

Originally created by @MarceloMayo74 on GitHub (Aug 17, 2026). Original GitHub issue: https://github.com/amnezia-vpn/amneziawg-tools/issues/68 `src/ipc-freebsd.h` does not compile from 3.0 onwards: it is still written against the pre-3.x `containers.h`, so amneziawg-tools cannot be built for FreeBSD at all without disabling the kernel IPC path. ### Reproduce On FreeBSD 16.0-CURRENT amd64, from the tarball of tag `v3.1.20260812`: ```sh gmake -C src PLATFORM=freebsd wg ``` ### What happens ``` ./ipc-freebsd.h:160:14: error: no member named 'response_packet_magic_header' in 'struct wgdevice' 160 | if (!dev->response_packet_magic_header) { | ~~~ ^ ./ipc-freebsd.h:169:24: error: use of undeclared identifier 'MAX_AWG_STRING_LEN' 169 | if (binary && size < MAX_AWG_STRING_LEN) | ^~~~~~~~~~~~~~~~~~ ./ipc-freebsd.h:453:44: error: no member named 'init_packet_magic_header' in 'struct wgdevice' 453 | nvlist_add_binary(nvl_device, "h1", dev->init_packet_magic_header, ... | ~~~ ^ fatal error: too many errors emitted, stopping now [-ferror-limit=] 20 errors generated. ``` ### Cause `ipc-freebsd.h` reads and writes H1–H4 as strings — `dev->init_packet_magic_header` and friends — and uses `MAX_AWG_STRING_LEN` to bound them. In 3.x `containers.h` those are ranges: ```c u32_range_t init_header, resp_header, cookie_header, transport_header; ``` and `MAX_AWG_STRING_LEN` is gone. The file is byte for byte identical in `v3.0.20260805` and `v3.1.20260812` (sha256 `7ee38c20…`), and both carry 21 references to identifiers that no longer exist, so this has been broken since the 3.0 line opened. The Linux and Windows paths were updated; this one was not, which is easy to miss because the release workflow builds Alpine, Ubuntu and Windows only. ### Suggested fix Port `ipc-freebsd.h` to the current `containers.h`: send H1–H4 through the nvlist as the range type the rest of the tree now uses, and drop the string bounds check. The 3.x device keys — `header_protection_key`, `content_padding_addition`, the timings, `random_trailers`, `disable_cookies` — would need adding there too if the FreeBSD kernel module is meant to reach parity. ### Workaround, for anyone who lands here Building with `-DAWG_NO_KERNEL_IPC` and this one-line change to `ipc.c` ```c -#elif defined(__FreeBSD__) +#elif defined(__FreeBSD__) && !defined(AWG_NO_KERNEL_IPC) ``` leaves the file out and produces a working `awg` that speaks only the userspace UAPI. That is enough when the peer is `amneziawg-go`, which is the only option on FreeBSD-based systems that cannot load `if_amn` — pfSense, for instance. It is obviously not a fix for anyone using the kernel module.
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
amnezia-vpn/amneziawg-tools#29
No description provided.