Browse Source

net/wireguard-go: tun: freebsd: work around kernel panic on shutdown

master
Bernhard Fröhlich 2 months ago
parent
commit
aab5032753
Signed by: Bernhard Froehlich <decke@bluelife.at> GPG Key ID: 4DD88C3F9F3B8333

+ 1
- 0
net/wireguard-go/Makefile View File

@@ -2,6 +2,7 @@
2 2
 
3 3
 PORTNAME=	wireguard-go
4 4
 PORTVERSION=	0.0.20190409
5
+PORTREVISION=	1
5 6
 CATEGORIES=	net
6 7
 MASTER_SITES=	https://git.zx2c4.com/wireguard-go/snapshot/
7 8
 DISTFILES=	${PORTNAME}-${PORTVERSION}${EXTRACT_SUFX}

+ 57
- 0
net/wireguard-go/files/patch-4287e060dd6e173e452fae41a636bda9be6e240d View File

@@ -0,0 +1,57 @@
1
+From 4287e060dd6e173e452fae41a636bda9be6e240d Mon Sep 17 00:00:00 2001
2
+From: "Jason A. Donenfeld" <Jason@zx2c4.com>
3
+Date: Sat, 20 Apr 2019 11:29:07 +0900
4
+Subject: tun: freebsd: work around kernel panic on shutdown
5
+
6
+---
7
+ tun/tun_freebsd.go | 33 +++++++++++++++++++++++----------
8
+ 1 file changed, 23 insertions(+), 10 deletions(-)
9
+
10
+diff --git a/tun/tun_freebsd.go b/tun/tun_freebsd.go
11
+index 01a4348..91d2397 100644
12
+--- tun/tun_freebsd.go
13
++++ tun/tun_freebsd.go
14
+@@ -206,17 +206,30 @@ func tunDestroy(name string) error {
15
+ 
16
+ 	defer unix.Close(fd)
17
+ 
18
+-	// do ioctl call
19
+-
20
+-	var ifr [32]byte
21
+-	copy(ifr[:], name)
22
+-	_, _, errno := unix.Syscall(
23
+-		unix.SYS_IOCTL,
24
+-		uintptr(fd),
25
+-		uintptr(unix.SIOCIFDESTROY),
26
+-		uintptr(unsafe.Pointer(&ifr[0])),
27
+-	)
28
++	// First we set down the interface (no ifr flags), to work around FreeBSD kernel bug.
29
++	func() {
30
++		var ifr [1024]byte
31
++		copy(ifr[:], name)
32
++		unix.Syscall(
33
++			unix.SYS_IOCTL,
34
++			uintptr(fd),
35
++			uintptr(unix.SIOCSIFFLAGS),
36
++			uintptr(unsafe.Pointer(&ifr[0])),
37
++		)
38
++	}()
39
+ 
40
++	// Only after can we then destroy the interface.
41
++	errno := func() syscall.Errno {
42
++		var ifr [32]byte
43
++		copy(ifr[:], name)
44
++		_, _, errno := unix.Syscall(
45
++			unix.SYS_IOCTL,
46
++			uintptr(fd),
47
++			uintptr(unix.SIOCIFDESTROY),
48
++			uintptr(unsafe.Pointer(&ifr[0])),
49
++		)
50
++		return errno
51
++	}()
52
+ 	if errno != 0 {
53
+ 		return fmt.Errorf("failed to destroy interface %s: %s", name, errno.Error())
54
+ 	}
55
+-- 
56
+cgit v1.2.1-20-gc37e
57
+

Loading…
Cancel
Save