Repository navigation
fix: FreeBSD and NetBSD build support - #76
Merged
Merged
Conversation
Apply the FreeBSD patches from #70 and the NetBSD patches from #73: - CMakeLists.txt: recognize NetBSD (VDE_NETBSD) and check net/if.h;net/if_tun.h together for the TAP interface on both BSDs - Macros.cmake: use check_include_files() so multi-header checks work - dpipe.c: setpgrp() with no args is System V style; use setpgid(0,0) on FreeBSD and NetBSD - vde_pcapplug.c: include net/bpf.h before pcap.h on the BSDs - vde_plug2tap.c, vde_switch/tuntap.c, vde_switch/datasock.c, vde_router/vde_headers.h, wirefilter.c: extend the existing VDE_FREEBSD conditionals to VDE_NETBSD - vde_router/vder_icmp.c: fall back to ICMP_UNREACH_ADMIN_PROHIBIT when ICMP_UNREACH_FILTER_PROHIB is not defined - vde_router/vder_packet.h: forward-declare struct iphdr - vde_vxlan/vxlan.c: include sys/socket.h - libvdehist.c, vde_plug.c, vde_switch/port.c: pass unsigned char to the ctype functions Fixes #70, fixes #73.
Closed
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The BSD fallback can fail compilation, and newly enabled NetBSD TAP error paths contain use-after-free behavior.
Review effort: Balanced
Findings: 1
Open (6)
NetBSD funopen fallback generates invalid empty preprocessor macro · New Management line scan can read past the terminating NUL · New Relative-device error path uses freed path memory · New Relative-device error path uses freed path memory · New NetBSD warning incorrectly identifies the system as FreeBSD · New setpgid failure is incorrectly reported as setpgrp · New
What changed in this PR
Adds FreeBSD and NetBSD build portability across configuration, TAP, pcap, router, and utility code.
Changes:
- Adds NetBSD platform detection and BSD header checks.
- Extends BSD-specific implementations to NetBSD.
- Fixes portability issues involving headers, process groups, and
ctype.
| File | Description |
|---|---|
CMakeLists.txt |
Detects NetBSD and BSD TAP headers. |
Macros.cmake |
Supports dependent header checks. |
src/dpipe.c |
Uses setpgid on BSD. |
src/lib/libvdehist.c |
Corrects isdigit arguments. |
src/vde_pcapplug.c |
Adjusts BSD pcap include ordering. |
src/vde_plug.c |
Corrects isspace argument. |
src/vde_plug2tap.c |
Enables NetBSD TAP handling. |
src/vde_router/vde_headers.h |
Adds NetBSD IP header compatibility. |
src/vde_router/vder_icmp.c |
Adds ICMP constant compatibility. |
src/vde_router/vder_packet.h |
Forward-declares struct iphdr. |
src/vde_switch/datasock.c |
Handles NetBSD socket-buffer exhaustion. |
src/vde_switch/port.c |
Corrects numeric identifier checks. |
src/vde_switch/tuntap.c |
Enables NetBSD TAP handling. |
src/vde_vxlan/vxlan.c |
Includes socket declarations. |
src/wirefilter.c |
Enables NetBSD path-limit headers. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- open_memstream.c: #ifdef HAVE_FUNOPEN - cm_check_function emits a bare #cmakedefine, so '#if HAVE_FUNOPEN' is an invalid preprocessor expression and the funopen fallback could never compile. - libvdehist.c: bound the management-line digit scan by the remaining string length; a short line previously read message[1..3] past the terminating NUL. - vde_plug2tap.c, vde_switch/tuntap.c: open_tap freed path before the failure printlog used it (use-after-free); also covered the malloc failure case where path is NULL. - CMakeLists.txt: report CMAKE_SYSTEM_NAME in the TunTap warning (branch covers FreeBSD and NetBSD). - dpipe.c: perror the call that actually failed (setpgid on BSD, setpgrp elsewhere). Addresses the Copilot review on PR #76.
rd235
approved these changes
Oct 4, 2026
rd235
left a comment
Member
There was a problem hiding this comment.
fix signedness inconsistencies of variables
add VDE_NETBSD tag
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #70, #73
Verified: host build passes; BSD builds untested locally (no BSD runner).