Skip to content

fix: FreeBSD and NetBSD build support - #76

Merged
rd235 merged 2 commits into
masterfrom
vde-bsd-portability
Oct 4, 2026
Merged

rd235 merged 2 commits into
masterfrom
vde-bsd-portability

Conversation

@danielinux

Copy link
Copy Markdown
Member

Fixes #70, #73

  • funopen path for BSD.
  • Include sys/sockio.h for SIOCGIFHWADDR on BSD.

Verified: host build passes; BSD builds untested locally (no BSD runner).

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.
Copilot AI balanced review requested due to automatic review settings October 3, 2026 11:37
@danielinux danielinux linked an issue Oct 3, 2026 that may be closed by this pull request

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 High severity · 3 Medium severity · 2 Low severity

Open (6)
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.

Comment thread CMakeLists.txt
Comment thread src/lib/libvdehist.c Outdated
Comment thread src/vde_plug2tap.c
Comment thread src/vde_switch/tuntap.c
Comment thread CMakeLists.txt
Comment thread src/dpipe.c
- 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.
@danielinux
danielinux requested a balanced review from Copilot October 3, 2026 11:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@rd235 rd235 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix signedness inconsistencies of variables
add VDE_NETBSD tag

@rd235
rd235 merged commit 89c8143 into master Oct 4, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for NetBSD Patches for support FreeBSD

3 participants