镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

tun: add DragonFly BSD support - #154

Open
sigttou wants to merge 2 commits into
WireGuard:masterfrom
sigttou:dragonfly-bsd
Open

sigttou wants to merge 2 commits into
WireGuard:masterfrom
sigttou:dragonfly-bsd

Conversation

@sigttou

@sigttou sigttou commented Sep 13, 2026

Copy link
Copy Markdown

Summary

DragonFly BSD shares FreeBSD's TUN implementation and ioctl interface almost
entirely; the only difference is the _TUNGIFNAME ioctl value
(0x40207462 on DragonFly vs 0x4020745d on FreeBSD).

Rather than duplicate the implementation (400+ lines), this change is ~27 lines:

  1. Renames tun_freebsd.go to tun_bsd.go and gives it an explicit
    //go:build freebsd || dragonfly constraint (it previously relied on the
    _freebsd.go filename suffix for its platform constraint), and
  2. Moves the single platform-specific constant into small per-OS files
    (tun_freebsd.go, tun_dragonfly.go).

It also adds dragonfly to the BSD build tags in ipc/uapi_bsd.go,
ipc/uapi_unix.go and tun/operateonfd.go.

Two commits: a pure rename, then the support change.

Testing

  • GOOS=dragonfly GOARCH=amd64 go build ./tun/... ./ipc/... — OK
  • GOOS=freebsd GOARCH=amd64 go build ./tun/... ./ipc/... — OK

Related

This is a minimal, modern alternative to the stalled DragonFly work (#49, open
since 2021 and based on the older code base).

An equivalent change is being proposed to the Tailscale fork, which Tailscale
depends on (github.com/tailscale/wireguard-go), so Tailscale can build on
DragonFly today: https://github.com/sigttou/tailscale-dragonfly

In preparation for sharing the BSD TUN implementation with DragonFly BSD.

Signed-off-by: David Bidner <david@crap.solutions>
DragonFly shares FreeBSD's TUN implementation and ioctl interface almost
entirely; the only difference is the _TUNGIFNAME ioctl value.

Add dragonfly to the shared BSD build tags and move the one platform-specific
constant into small per-OS files.

Tested with GOOS=dragonfly and GOOS=freebsd builds.

Signed-off-by: David Bidner <david@crap.solutions>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant