wireguard-go-bridge: update to Go 1.12
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
a389bd93cb
commit
b1dabf5a00
|
@ -1 +1 @@
|
||||||
Subproject commit f7170e5de2065f37bac647484b34711db4797394
|
Subproject commit 88ff67fb6f55456e46877b71aa5d33060468f95e
|
|
@ -28,7 +28,7 @@ version-header: $(DESTDIR)/wireguard-go-version.h
|
||||||
|
|
||||||
GOBUILDARCH := $(GOARCH_$(shell uname -m))
|
GOBUILDARCH := $(GOARCH_$(shell uname -m))
|
||||||
GOBUILDOS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
|
GOBUILDOS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
|
||||||
GOBUILDVERSION := 1.11.5
|
GOBUILDVERSION := 1.12
|
||||||
GOBUILDTARBALL := go$(GOBUILDVERSION).$(GOBUILDOS)-$(GOBUILDARCH).tar.gz
|
GOBUILDTARBALL := go$(GOBUILDVERSION).$(GOBUILDOS)-$(GOBUILDARCH).tar.gz
|
||||||
GOBUILDTARBALLURL := https://dl.google.com/go/$(GOBUILDTARBALL)
|
GOBUILDTARBALLURL := https://dl.google.com/go/$(GOBUILDTARBALL)
|
||||||
GOBUILDVERSION_NEEDED := go version go$(GOBUILDVERSION) $(GOBUILDOS)/$(GOBUILDARCH)
|
GOBUILDVERSION_NEEDED := go version go$(GOBUILDVERSION) $(GOBUILDOS)/$(GOBUILDARCH)
|
||||||
|
|
|
@ -1,55 +1,27 @@
|
||||||
diff -r -u go/src/runtime/sys_darwin_386.s go-modified/src/runtime/sys_darwin_386.s
|
From 74523c5a12d37fa792e77a252bcc569484c3d41a Mon Sep 17 00:00:00 2001
|
||||||
--- go/src/runtime/sys_darwin_386.s 2018-10-01 23:02:54.000000000 +0200
|
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
|
||||||
+++ go-modified/src/runtime/sys_darwin_386.s 2018-11-01 23:18:04.383055355 +0100
|
Date: Wed, 27 Feb 2019 05:33:01 +0100
|
||||||
@@ -184,7 +184,7 @@
|
Subject: [PATCH] runtime: use libc_mach_continuous_time in nanotime on Darwin
|
||||||
PUSHL BP
|
|
||||||
MOVL SP, BP
|
This makes timers account for having expired while a computer was
|
||||||
SUBL $8+(machTimebaseInfo__size+15)/16*16, SP
|
asleep, which is quite common on mobile devices. Note that
|
||||||
- CALL libc_mach_absolute_time(SB)
|
continuous_time absolute_time, except that it takes into account
|
||||||
+ CALL libc_mach_continuous_time(SB)
|
time spent in suspend.
|
||||||
MOVL 16+(machTimebaseInfo__size+15)/16*16(SP), CX
|
|
||||||
MOVL AX, 0(CX)
|
Fixes #24595
|
||||||
MOVL DX, 4(CX)
|
---
|
||||||
diff -r -u go/src/runtime/sys_darwin_amd64.s go-modified/src/runtime/sys_darwin_amd64.s
|
src/runtime/sys_darwin.go | 2 +-
|
||||||
--- go/src/runtime/sys_darwin_amd64.s 2018-10-01 23:02:54.000000000 +0200
|
src/runtime/sys_darwin_386.s | 2 +-
|
||||||
+++ go-modified/src/runtime/sys_darwin_amd64.s 2018-11-01 23:18:04.382055360 +0100
|
src/runtime/sys_darwin_amd64.s | 2 +-
|
||||||
@@ -85,7 +85,7 @@
|
src/runtime/sys_darwin_arm.s | 2 +-
|
||||||
PUSHQ BP
|
src/runtime/sys_darwin_arm64.s | 2 +-
|
||||||
MOVQ SP, BP
|
5 files changed, 5 insertions(+), 5 deletions(-)
|
||||||
MOVQ DI, BX
|
|
||||||
- CALL libc_mach_absolute_time(SB)
|
diff --git a/src/runtime/sys_darwin.go b/src/runtime/sys_darwin.go
|
||||||
+ CALL libc_mach_continuous_time(SB)
|
index f34ac88352..416fcb673f 100644
|
||||||
MOVQ AX, 0(BX)
|
--- a/src/runtime/sys_darwin.go
|
||||||
MOVL timebase<>+machTimebaseInfo_numer(SB), SI
|
+++ b/src/runtime/sys_darwin.go
|
||||||
MOVL timebase<>+machTimebaseInfo_denom(SB), DI // atomic read
|
@@ -403,7 +403,7 @@ func closeonexec(fd int32) {
|
||||||
diff -r -u go/src/runtime/sys_darwin_arm64.s go-modified/src/runtime/sys_darwin_arm64.s
|
|
||||||
--- go/src/runtime/sys_darwin_arm64.s 2018-10-01 23:02:54.000000000 +0200
|
|
||||||
+++ go-modified/src/runtime/sys_darwin_arm64.s 2018-11-01 23:18:04.380055369 +0100
|
|
||||||
@@ -110,7 +110,7 @@
|
|
||||||
|
|
||||||
TEXT runtime·nanotime_trampoline(SB),NOSPLIT,$40
|
|
||||||
MOVD R0, R19
|
|
||||||
- BL libc_mach_absolute_time(SB)
|
|
||||||
+ BL libc_mach_continuous_time(SB)
|
|
||||||
MOVD R0, 0(R19)
|
|
||||||
MOVW timebase<>+machTimebaseInfo_numer(SB), R20
|
|
||||||
MOVD $timebase<>+machTimebaseInfo_denom(SB), R21
|
|
||||||
diff -r -u go/src/runtime/sys_darwin_arm.s go-modified/src/runtime/sys_darwin_arm.s
|
|
||||||
--- go/src/runtime/sys_darwin_arm.s 2018-10-01 23:02:54.000000000 +0200
|
|
||||||
+++ go-modified/src/runtime/sys_darwin_arm.s 2018-11-01 23:18:04.381055364 +0100
|
|
||||||
@@ -118,7 +118,7 @@
|
|
||||||
|
|
||||||
TEXT runtime·nanotime_trampoline(SB),NOSPLIT,$0
|
|
||||||
MOVW R0, R8
|
|
||||||
- BL libc_mach_absolute_time(SB)
|
|
||||||
+ BL libc_mach_continuous_time(SB)
|
|
||||||
MOVW R0, 0(R8)
|
|
||||||
MOVW R1, 4(R8)
|
|
||||||
MOVW timebase<>+machTimebaseInfo_numer(SB), R6
|
|
||||||
diff -r -u go/src/runtime/sys_darwin.go go-modified/src/runtime/sys_darwin.go
|
|
||||||
--- go/src/runtime/sys_darwin.go 2018-10-01 23:02:54.000000000 +0200
|
|
||||||
+++ go-modified/src/runtime/sys_darwin.go 2018-11-01 23:18:04.384055350 +0100
|
|
||||||
@@ -348,7 +348,7 @@
|
|
||||||
//go:cgo_import_dynamic libc_usleep usleep "/usr/lib/libSystem.B.dylib"
|
//go:cgo_import_dynamic libc_usleep usleep "/usr/lib/libSystem.B.dylib"
|
||||||
|
|
||||||
//go:cgo_import_dynamic libc_mach_timebase_info mach_timebase_info "/usr/lib/libSystem.B.dylib"
|
//go:cgo_import_dynamic libc_mach_timebase_info mach_timebase_info "/usr/lib/libSystem.B.dylib"
|
||||||
|
@ -58,3 +30,58 @@ diff -r -u go/src/runtime/sys_darwin.go go-modified/src/runtime/sys_darwin.go
|
||||||
//go:cgo_import_dynamic libc_gettimeofday gettimeofday "/usr/lib/libSystem.B.dylib"
|
//go:cgo_import_dynamic libc_gettimeofday gettimeofday "/usr/lib/libSystem.B.dylib"
|
||||||
//go:cgo_import_dynamic libc_sigaction sigaction "/usr/lib/libSystem.B.dylib"
|
//go:cgo_import_dynamic libc_sigaction sigaction "/usr/lib/libSystem.B.dylib"
|
||||||
//go:cgo_import_dynamic libc_pthread_sigmask pthread_sigmask "/usr/lib/libSystem.B.dylib"
|
//go:cgo_import_dynamic libc_pthread_sigmask pthread_sigmask "/usr/lib/libSystem.B.dylib"
|
||||||
|
diff --git a/src/runtime/sys_darwin_386.s b/src/runtime/sys_darwin_386.s
|
||||||
|
index 1bc1a63c28..34a3561350 100644
|
||||||
|
--- a/src/runtime/sys_darwin_386.s
|
||||||
|
+++ b/src/runtime/sys_darwin_386.s
|
||||||
|
@@ -184,7 +184,7 @@ TEXT runtime·nanotime_trampoline(SB),NOSPLIT,$0
|
||||||
|
PUSHL BP
|
||||||
|
MOVL SP, BP
|
||||||
|
SUBL $8+(machTimebaseInfo__size+15)/16*16, SP
|
||||||
|
- CALL libc_mach_absolute_time(SB)
|
||||||
|
+ CALL libc_mach_continuous_time(SB)
|
||||||
|
MOVL 16+(machTimebaseInfo__size+15)/16*16(SP), CX
|
||||||
|
MOVL AX, 0(CX)
|
||||||
|
MOVL DX, 4(CX)
|
||||||
|
diff --git a/src/runtime/sys_darwin_amd64.s b/src/runtime/sys_darwin_amd64.s
|
||||||
|
index f99cb00ab8..8b99316983 100644
|
||||||
|
--- a/src/runtime/sys_darwin_amd64.s
|
||||||
|
+++ b/src/runtime/sys_darwin_amd64.s
|
||||||
|
@@ -86,7 +86,7 @@ TEXT runtime·nanotime_trampoline(SB),NOSPLIT,$0
|
||||||
|
PUSHQ BP
|
||||||
|
MOVQ SP, BP
|
||||||
|
MOVQ DI, BX
|
||||||
|
- CALL libc_mach_absolute_time(SB)
|
||||||
|
+ CALL libc_mach_continuous_time(SB)
|
||||||
|
MOVQ AX, 0(BX)
|
||||||
|
MOVL timebase<>+machTimebaseInfo_numer(SB), SI
|
||||||
|
MOVL timebase<>+machTimebaseInfo_denom(SB), DI // atomic read
|
||||||
|
diff --git a/src/runtime/sys_darwin_arm.s b/src/runtime/sys_darwin_arm.s
|
||||||
|
index 54c7afbf34..a4f06fdb85 100644
|
||||||
|
--- a/src/runtime/sys_darwin_arm.s
|
||||||
|
+++ b/src/runtime/sys_darwin_arm.s
|
||||||
|
@@ -118,7 +118,7 @@ GLOBL timebase<>(SB),NOPTR,$(machTimebaseInfo__size)
|
||||||
|
|
||||||
|
TEXT runtime·nanotime_trampoline(SB),NOSPLIT,$0
|
||||||
|
MOVW R0, R8
|
||||||
|
- BL libc_mach_absolute_time(SB)
|
||||||
|
+ BL libc_mach_continuous_time(SB)
|
||||||
|
MOVW R0, 0(R8)
|
||||||
|
MOVW R1, 4(R8)
|
||||||
|
MOVW timebase<>+machTimebaseInfo_numer(SB), R6
|
||||||
|
diff --git a/src/runtime/sys_darwin_arm64.s b/src/runtime/sys_darwin_arm64.s
|
||||||
|
index 29951d8ad7..cdaf0a630e 100644
|
||||||
|
--- a/src/runtime/sys_darwin_arm64.s
|
||||||
|
+++ b/src/runtime/sys_darwin_arm64.s
|
||||||
|
@@ -113,7 +113,7 @@ GLOBL timebase<>(SB),NOPTR,$(machTimebaseInfo__size)
|
||||||
|
|
||||||
|
TEXT runtime·nanotime_trampoline(SB),NOSPLIT,$40
|
||||||
|
MOVD R0, R19
|
||||||
|
- BL libc_mach_absolute_time(SB)
|
||||||
|
+ BL libc_mach_continuous_time(SB)
|
||||||
|
MOVD R0, 0(R19)
|
||||||
|
MOVW timebase<>+machTimebaseInfo_numer(SB), R20
|
||||||
|
MOVD $timebase<>+machTimebaseInfo_denom(SB), R21
|
||||||
|
--
|
||||||
|
2.20.1
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,8 @@ import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"git.zx2c4.com/wireguard-go/tun"
|
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
|
"golang.zx2c4.com/wireguard/tun"
|
||||||
"log"
|
"log"
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
|
@ -61,7 +61,7 @@ func init() {
|
||||||
n := runtime.Stack(buf, true)
|
n := runtime.Stack(buf, true)
|
||||||
buf[n] = 0
|
buf[n] = 0
|
||||||
if uintptr(loggerFunc) != 0 {
|
if uintptr(loggerFunc) != 0 {
|
||||||
C.callLogger(loggerFunc, 0, (*_Ctype_char)(unsafe.Pointer(&buf[0])))
|
C.callLogger(loggerFunc, 0, (*C.char)(unsafe.Pointer(&buf[0])))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,28 +6,24 @@
|
||||||
package tun
|
package tun
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.zx2c4.com/wireguard-go/rwcancel"
|
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
func CreateTUNFromFD(tunFd int) (TUNDevice, string, error) {
|
func CreateTUNFromFD(tunFd int) (TUNDevice, string, error) {
|
||||||
file := os.NewFile(uintptr(tunFd), "/dev/tun")
|
err := unix.SetNonblock(tunFd, true)
|
||||||
tun := &nativeTun{
|
|
||||||
tunFile: file,
|
|
||||||
fd: file.Fd(),
|
|
||||||
events: make(chan TUNEvent, 5),
|
|
||||||
errors: make(chan error, 5),
|
|
||||||
}
|
|
||||||
var err error
|
|
||||||
tun.rwcancel, err = rwcancel.NewRWCancel(tunFd)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, "", err
|
return nil, "", err
|
||||||
}
|
}
|
||||||
|
file := os.NewFile(uintptr(tunFd), "/dev/tun")
|
||||||
|
tun := &nativeTun{
|
||||||
|
tunFile: file,
|
||||||
|
events: make(chan TUNEvent, 5),
|
||||||
|
errors: make(chan error, 5),
|
||||||
|
}
|
||||||
name, err := tun.Name()
|
name, err := tun.Name()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tun.rwcancel.Cancel()
|
|
||||||
return nil, "", err
|
return nil, "", err
|
||||||
}
|
}
|
||||||
tunIfindex, err := func() (int, error) {
|
tunIfindex, err := func() (int, error) {
|
||||||
|
@ -38,12 +34,10 @@ func CreateTUNFromFD(tunFd int) (TUNDevice, string, error) {
|
||||||
return iface.Index, nil
|
return iface.Index, nil
|
||||||
}()
|
}()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tun.tunFile.Close()
|
|
||||||
return nil, "", err
|
return nil, "", err
|
||||||
}
|
}
|
||||||
tun.routeSocket, err = unix.Socket(unix.AF_ROUTE, unix.SOCK_RAW, unix.AF_UNSPEC)
|
tun.routeSocket, err = unix.Socket(unix.AF_ROUTE, unix.SOCK_RAW, unix.AF_UNSPEC)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tun.tunFile.Close()
|
|
||||||
return nil, "", err
|
return nil, "", err
|
||||||
}
|
}
|
||||||
go tun.routineRouteListener(tunIfindex)
|
go tun.routineRouteListener(tunIfindex)
|
||||||
|
|
Loading…
Reference in New Issue