Browse Source

net/wireguard-go: Update to 0.0.20190517

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

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

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

+ 0
- 203
net/wireguard-go/files/patch-bb42ec7d185ab5f5cd3867ac1258edff86b7f307 View File

@@ -1,204 +0,0 @@
1
-From bb42ec7d185ab5f5cd3867ac1258edff86b7f307 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 numerous kernel panics on shutdown
5
-
6
-There are numerous race conditions. But even this will crash it:
7
-
8
-while true; do ifconfig tun0 create; ifconfig tun0 destroy; done
9
-
10
-It seems like LLv6 is related, which we're not using anyway, so
11
-explicitly disable it on the interface.
12
----
13
- tun/tun_freebsd.go | 105 +++++++++++++++++++++++++++++++++++++++++------------
14
- 1 file changed, 82 insertions(+), 23 deletions(-)
15
-
16
-diff --git a/tun/tun_freebsd.go b/tun/tun_freebsd.go
17
-index 01a4348..c9c89ef 100644
18
---- tun/tun_freebsd.go
19
-+++ tun/tun_freebsd.go
20
-@@ -19,9 +19,19 @@ import (
21
- 
22
- // _TUNSIFHEAD, value derived from sys/net/{if_tun,ioccom}.h
23
- // const _TUNSIFHEAD = ((0x80000000) | (((4) & ((1 << 13) - 1) ) << 16) | (uint32(byte('t')) << 8) | (96))
24
--const _TUNSIFHEAD = 0x80047460
25
--const _TUNSIFMODE = 0x8004745e
26
--const _TUNSIFPID = 0x2000745f
27
-+const (
28
-+	_TUNSIFHEAD = 0x80047460
29
-+	_TUNSIFMODE = 0x8004745e
30
-+	_TUNSIFPID  = 0x2000745f
31
-+)
32
-+
33
-+//TODO: move into x/sys/unix
34
-+const (
35
-+	SIOCGIFINFO_IN6        = 0xc048696c
36
-+	SIOCSIFINFO_IN6        = 0xc048696d
37
-+	ND6_IFF_AUTO_LINKLOCAL = 0x20
38
-+	ND6_IFF_NO_DAD         = 0x100
39
-+)
40
- 
41
- // Iface status string max len
42
- const _IFSTATMAX = 800
43
-@@ -32,7 +42,7 @@ const SIZEOF_UINTPTR = 4 << (^uintptr(0) >> 32 & 1)
44
- type ifreq_ptr struct {
45
- 	Name [unix.IFNAMSIZ]byte
46
- 	Data uintptr
47
--	Pad0 [24 - SIZEOF_UINTPTR]byte
48
-+	Pad0 [16 - SIZEOF_UINTPTR]byte
49
- }
50
- 
51
- // Structure for iface mtu get/set ioctls
52
-@@ -48,6 +58,23 @@ type ifstat struct {
53
- 	Ascii   [_IFSTATMAX]byte
54
- }
55
- 
56
-+// Structures for nd6 flag manipulation
57
-+type in6_ndireq struct {
58
-+	Name          [unix.IFNAMSIZ]byte
59
-+	Linkmtu       uint32
60
-+	Maxmtu        uint32
61
-+	Basereachable uint32
62
-+	Reachable     uint32
63
-+	Retrans       uint32
64
-+	Flags         uint32
65
-+	Recalctm      int
66
-+	Chlim         uint8
67
-+	Initialized   uint8
68
-+	Randomseed0   [8]byte
69
-+	Randomseed1   [8]byte
70
-+	Randomid      [8]byte
71
-+}
72
-+
73
- type NativeTun struct {
74
- 	name        string
75
- 	tunFile     *os.File
76
-@@ -191,23 +218,18 @@ func tunName(fd uintptr) (string, error) {
77
- 
78
- // Destroy a named system interface
79
- func tunDestroy(name string) error {
80
--	// open control socket
81
-+	// Open control socket.
82
- 	var fd int
83
--
84
- 	fd, err := unix.Socket(
85
- 		unix.AF_INET,
86
- 		unix.SOCK_DGRAM,
87
- 		0,
88
- 	)
89
--
90
- 	if err != nil {
91
- 		return err
92
- 	}
93
--
94
- 	defer unix.Close(fd)
95
- 
96
--	// do ioctl call
97
--
98
- 	var ifr [32]byte
99
- 	copy(ifr[:], name)
100
- 	_, _, errno := unix.Syscall(
101
-@@ -216,7 +238,6 @@ func tunDestroy(name string) error {
102
- 		uintptr(unix.SIOCIFDESTROY),
103
- 		uintptr(unsafe.Pointer(&ifr[0])),
104
- 	)
105
--
106
- 	if errno != 0 {
107
- 		return fmt.Errorf("failed to destroy interface %s: %s", name, errno.Error())
108
- 	}
109
-@@ -263,33 +284,71 @@ func CreateTUN(name string, mtu int) (TUNDevice, error) {
110
- 	})
111
- 
112
- 	if errno != 0 {
113
--		return nil, fmt.Errorf("error %s", errno.Error())
114
-+		tunFile.Close()
115
-+		tunDestroy(assignedName)
116
-+		return nil, fmt.Errorf("Unable to put into IFHEAD mode: %v", errno)
117
- 	}
118
- 
119
--	// Rename tun interface
120
--
121
--	// Open control socket
122
-+	// Open control sockets
123
- 	confd, err := unix.Socket(
124
- 		unix.AF_INET,
125
- 		unix.SOCK_DGRAM,
126
- 		0,
127
- 	)
128
--
129
- 	if err != nil {
130
-+		tunFile.Close()
131
-+		tunDestroy(assignedName)
132
- 		return nil, err
133
- 	}
134
--
135
- 	defer unix.Close(confd)
136
-+	confd6, err := unix.Socket(
137
-+		unix.AF_INET6,
138
-+		unix.SOCK_DGRAM,
139
-+		0,
140
-+	)
141
-+	if err != nil {
142
-+		tunFile.Close()
143
-+		tunDestroy(assignedName)
144
-+		return nil, err
145
-+	}
146
-+	defer unix.Close(confd6)
147
- 
148
--	// set up struct for iface rename
149
-+	// Disable link-local v6, not just because WireGuard doesn't do that anyway, but
150
-+	// also because there are serious races with attaching and detaching LLv6 addresses
151
-+	// in relation to interface lifetime within the FreeBSD kernel.
152
-+	var ndireq in6_ndireq
153
-+	copy(ndireq.Name[:], assignedName)
154
-+	_, _, errno = unix.Syscall(
155
-+		unix.SYS_IOCTL,
156
-+		uintptr(confd6),
157
-+		uintptr(SIOCGIFINFO_IN6),
158
-+		uintptr(unsafe.Pointer(&ndireq)),
159
-+	)
160
-+	if errno != 0 {
161
-+		tunFile.Close()
162
-+		tunDestroy(assignedName)
163
-+		return nil, fmt.Errorf("Unable to get nd6 flags for %s: %v", assignedName, errno)
164
-+	}
165
-+	ndireq.Flags = ndireq.Flags &^ ND6_IFF_AUTO_LINKLOCAL
166
-+	ndireq.Flags = ndireq.Flags | ND6_IFF_NO_DAD
167
-+	_, _, errno = unix.Syscall(
168
-+		unix.SYS_IOCTL,
169
-+		uintptr(confd6),
170
-+		uintptr(SIOCSIFINFO_IN6),
171
-+		uintptr(unsafe.Pointer(&ndireq)),
172
-+	)
173
-+	if errno != 0 {
174
-+		tunFile.Close()
175
-+		tunDestroy(assignedName)
176
-+		return nil, fmt.Errorf("Unable to set nd6 flags for %s: %v", assignedName, errno)
177
-+	}
178
-+
179
-+	// Rename the interface
180
- 	var newnp [unix.IFNAMSIZ]byte
181
- 	copy(newnp[:], name)
182
--
183
- 	var ifr ifreq_ptr
184
- 	copy(ifr.Name[:], assignedName)
185
- 	ifr.Data = uintptr(unsafe.Pointer(&newnp[0]))
186
--
187
--	//do actual ioctl to rename iface
188
- 	_, _, errno = unix.Syscall(
189
- 		unix.SYS_IOCTL,
190
- 		uintptr(confd),
191
-@@ -298,8 +357,8 @@ func CreateTUN(name string, mtu int) (TUNDevice, error) {
192
- 	)
193
- 	if errno != 0 {
194
- 		tunFile.Close()
195
--		tunDestroy(name)
196
--		return nil, fmt.Errorf("failed to rename %s to %s: %s", assignedName, name, errno.Error())
197
-+		tunDestroy(assignedName)
198
-+		return nil, fmt.Errorf("Failed to rename %s to %s: %v", assignedName, name, errno)
199
- 	}
200
- 
201
- 	return CreateTUNFromFile(tunFile, mtu)
202
-cgit v1.2.1-20-gc37e
203
-

Loading…
Cancel
Save