pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
wireguard-go: Use multi-af mode for NetBSD tun(4)
Module Name: pkgsrc-wip
Committed By: snow flurry <snow%datagirl.xyz@localhost>
Pushed By: flurry
Date: Mon Jul 3 19:39:28 2023 +0000
Changeset: d314da09a8ef045da91fd0d66246fbd6d7c2c511
Modified Files:
wireguard-go/Makefile
wireguard-go/distinfo
Added Files:
wireguard-go/patches/patch-tun_tun__netbsd.go
Log Message:
wireguard-go: Use multi-af mode for NetBSD tun(4)
OpenBSD only provides "multi-af" mode in tun(4). To make porting to
NetBSD easier, we can enable "multi-af" mode after creating the tun
device.
To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=d314da09a8ef045da91fd0d66246fbd6d7c2c511
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
wireguard-go/Makefile | 4 +--
wireguard-go/distinfo | 1 +
wireguard-go/patches/patch-tun_tun__netbsd.go | 38 +++++++++++++++++++++++++++
3 files changed, 41 insertions(+), 2 deletions(-)
diffs:
diff --git a/wireguard-go/Makefile b/wireguard-go/Makefile
index 85212de1d2..31387107f7 100644
--- a/wireguard-go/Makefile
+++ b/wireguard-go/Makefile
@@ -18,8 +18,8 @@ do-install:
GO_BUILD_PATTERN= .
-post-patch:
- cd ${WRKSRC}/tun && ${LN} -sf tun_openbsd.go tun_netbsd.go
+pre-patch:
+ cd ${WRKSRC}/tun && ${CP} tun_openbsd.go tun_netbsd.go
.include "go-modules.mk"
diff --git a/wireguard-go/distinfo b/wireguard-go/distinfo
index 22cec0bb32..5777c63470 100644
--- a/wireguard-go/distinfo
+++ b/wireguard-go/distinfo
@@ -29,3 +29,4 @@ SHA512 (wireguard-go-0.0.20220316.tar.xz) = 82b53210502e01d454a62a1a7694f57b2f72
Size (wireguard-go-0.0.20220316.tar.xz) = 110444 bytes
SHA1 (patch-ipc_uapi__bsd.go) = 028dd8415c52abb844ee1e8b234cc13872e697e3
SHA1 (patch-ipc_uapi__unix.go) = 8b0c917db05bfb94f446cf6b68b5c4ac655ebd9f
+SHA1 (patch-tun_tun__netbsd.go) = 0a9b925b520f7b6169e37dd8afa42c04ab2b0b6e
diff --git a/wireguard-go/patches/patch-tun_tun__netbsd.go b/wireguard-go/patches/patch-tun_tun__netbsd.go
new file mode 100644
index 0000000000..3266c14a35
--- /dev/null
+++ b/wireguard-go/patches/patch-tun_tun__netbsd.go
@@ -0,0 +1,38 @@
+$NetBSD$
+
+Enables multi-af mode for NetBSD tun(4).
+
+--- tun/tun_netbsd.go.orig 2023-07-03 19:33:35.358738005 +0000
++++ tun/tun_netbsd.go
+@@ -25,7 +25,7 @@ type ifreq_mtu struct {
+ Pad0 [12]byte
+ }
+
+-const _TUNSIFMODE = 0x8004745d
++const _TUNSIFHEAD = 0x80047442
+
+ type NativeTun struct {
+ name string
+@@ -130,6 +130,22 @@ func CreateTUN(name string, mtu int) (De
+
+ tun, err := CreateTUNFromFile(tunfile, mtu)
+
++ // set multi-af mode
++ ifheadmode := 1
++ var errno syscall.Errno
++ _, _, errno = unix.Syscall(
++ unix.SYS_IOCTL,
++ tunfile.Fd(),
++ uintptr(_TUNSIFHEAD),
++ uintptr(unsafe.Pointer(&ifheadmode)),
++ )
++
++ if errno != 0 {
++ tunfile.Close()
++ return nil, fmt.Errorf("Unable to put into multi-af mode: %v", errno)
++ }
++
++
+ if err == nil && name == "tun" {
+ fname := os.Getenv("WG_TUN_NAME_FILE")
+ if fname != "" {
Home |
Main Index |
Thread Index |
Old Index