From e94caa9e587e02314c52cfa56540feeb41340b77 Mon Sep 17 00:00:00 2001 From: Nate Brown Date: Thu, 21 Nov 2019 21:31:12 -0800 Subject: [PATCH 1/7] Initial attempt at mips64 --- Makefile | 8 +++++++- udp_linux_mips64.go | 50 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 udp_linux_mips64.go diff --git a/Makefile b/Makefile index 7a85625..91e6fce 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ BUILD_NUMBER ?= dev+$(shell date -u '+%Y%m%d%H%M%S') GO111MODULE = on export GO111MODULE -all: bin-linux bin-arm bin-arm6 bin-arm64 bin-darwin bin-windows +all: bin-linux bin-arm bin-arm6 bin-arm64 bin-darwin bin-windows bin-mips64 bin: go build -ldflags "-X main.Build=$(BUILD_NUMBER)" -o ./nebula ${NEBULA_CMD_PATH} @@ -47,6 +47,11 @@ bin-linux: GOARCH=amd64 GOOS=linux go build -o build/linux/nebula -ldflags "-X main.Build=$(BUILD_NUMBER)" ${NEBULA_CMD_PATH} GOARCH=amd64 GOOS=linux go build -o build/linux/nebula-cert -ldflags "-X main.Build=$(BUILD_NUMBER)" ./cmd/nebula-cert +bin-mips64: + mkdir -p build/mips64 + GOARCH=mips64 GOOS=linux go build -o build/mips64/nebula -ldflags "-X main.Build=$(BUILD_NUMBER)" ./cmd/nebula + GOARCH=mips64 GOOS=linux go build -o build/mips64/nebula-cert -ldflags "-X main.Build=$(BUILD_NUMBER)" ./cmd/nebula-cert + release: all tar -zcv -C build/arm/ -f nebula-linux-arm.tar.gz nebula nebula-cert tar -zcv -C build/arm6/ -f nebula-linux-arm6.tar.gz nebula nebula-cert @@ -54,6 +59,7 @@ release: all tar -zcv -C build/darwin/ -f nebula-darwin-amd64.tar.gz nebula nebula-cert tar -zcv -C build/windows/ -f nebula-windows-amd64.tar.gz nebula.exe nebula-cert.exe tar -zcv -C build/linux/ -f nebula-linux-amd64.tar.gz nebula nebula-cert + tar -zcv -C build/mips64/ -f nebula-linux-mips64.tar.gz nebula nebula-cert vet: go vet -v ./... diff --git a/udp_linux_mips64.go b/udp_linux_mips64.go new file mode 100644 index 0000000..a61e0c8 --- /dev/null +++ b/udp_linux_mips64.go @@ -0,0 +1,50 @@ +package nebula + +import "unsafe" + +type iovec struct { + Base *byte + Len uint64 +} + +type msghdr struct { + Name *byte + Namelen uint32 + Pad0 [4]byte + Iov *iovec + Iovlen uint64 + Control *byte + Controllen uint64 + Flags int32 + Pad1 [4]byte +} + +type rawMessage struct { + Hdr msghdr + Len uint32 + Pad0 [4]byte +} + +func (u *udpConn) PrepareRawMessages(n int) ([]rawMessage, [][]byte, [][]byte) { + msgs := make([]rawMessage, n) + buffers := make([][]byte, n) + names := make([][]byte, n) + + for i := range msgs { + buffers[i] = make([]byte, mtu) + names[i] = make([]byte, 0x1c) //TODO = sizeofSockaddrInet6 + + //TODO: this is still silly, no need for an array + vs := []iovec{ + {Base: (*byte)(unsafe.Pointer(&buffers[i][0])), Len: uint64(len(buffers[i]))}, + } + + msgs[i].Hdr.Iov = &vs[0] + msgs[i].Hdr.Iovlen = uint64(len(vs)) + + msgs[i].Hdr.Name = (*byte)(unsafe.Pointer(&names[i][0])) + msgs[i].Hdr.Namelen = uint32(len(names[i])) + } + + return msgs, buffers, names +} From ec63d0d2850e4294430643d343ccc6049f201624 Mon Sep 17 00:00:00 2001 From: Nate Brown Date: Fri, 22 Nov 2019 15:22:31 -0800 Subject: [PATCH 2/7] Remove magic numbers, support mips64le --- Makefile | 8 ++++++- udp_linux.go | 15 ++++--------- udp_linux_mips64le.go | 50 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 12 deletions(-) create mode 100644 udp_linux_mips64le.go diff --git a/Makefile b/Makefile index 91e6fce..aca5e54 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ BUILD_NUMBER ?= dev+$(shell date -u '+%Y%m%d%H%M%S') GO111MODULE = on export GO111MODULE -all: bin-linux bin-arm bin-arm6 bin-arm64 bin-darwin bin-windows bin-mips64 +all: bin-linux bin-arm bin-arm6 bin-arm64 bin-darwin bin-windows bin-mips64 bin-mips64le bin: go build -ldflags "-X main.Build=$(BUILD_NUMBER)" -o ./nebula ${NEBULA_CMD_PATH} @@ -52,6 +52,11 @@ bin-mips64: GOARCH=mips64 GOOS=linux go build -o build/mips64/nebula -ldflags "-X main.Build=$(BUILD_NUMBER)" ./cmd/nebula GOARCH=mips64 GOOS=linux go build -o build/mips64/nebula-cert -ldflags "-X main.Build=$(BUILD_NUMBER)" ./cmd/nebula-cert +bin-mips64le: + mkdir -p build/mips64le + GOARCH=mips64le GOOS=linux go build -o build/mips64le/nebula -ldflags "-X main.Build=$(BUILD_NUMBER)" ./cmd/nebula + GOARCH=mips64le GOOS=linux go build -o build/mips64le/nebula-cert -ldflags "-X main.Build=$(BUILD_NUMBER)" ./cmd/nebula-cert + release: all tar -zcv -C build/arm/ -f nebula-linux-arm.tar.gz nebula nebula-cert tar -zcv -C build/arm6/ -f nebula-linux-arm6.tar.gz nebula nebula-cert @@ -60,6 +65,7 @@ release: all tar -zcv -C build/windows/ -f nebula-windows-amd64.tar.gz nebula.exe nebula-cert.exe tar -zcv -C build/linux/ -f nebula-linux-amd64.tar.gz nebula nebula-cert tar -zcv -C build/mips64/ -f nebula-linux-mips64.tar.gz nebula nebula-cert + tar -zcv -C build/mips64le/ -f nebula-linux-mips64le.tar.gz nebula nebula-cert vet: go vet -v ./... diff --git a/udp_linux.go b/udp_linux.go index 593b896..2a1b0d0 100644 --- a/udp_linux.go +++ b/udp_linux.go @@ -63,25 +63,18 @@ func NewListener(ip string, port int, multi bool) (*udpConn, error) { if err != nil { syscall.Close(fd) - return nil, err + return nil, fmt.Errorf("unable to open socket: %s", err) } var lip [4]byte copy(lip[:], net.ParseIP(ip).To4()) - if err = syscall.SetsockoptInt(fd, syscall.SOL_SOCKET, 0x0F, 1); err != nil { - return nil, err + if err = syscall.SetsockoptInt(fd, syscall.SOL_SOCKET, unix.SO_REUSEPORT, 1); err != nil { + return nil, fmt.Errorf("unable to set SO_REUSEPORT: %s", err) } if err = syscall.Bind(fd, &syscall.SockaddrInet4{Port: port}); err != nil { - return nil, err - } - - // SO_REUSEADDR does not load balance so we use PORT - if multi { - if err = syscall.SetsockoptInt(fd, syscall.SOL_SOCKET, unix.SO_REUSEPORT, 1); err != nil { - return nil, err - } + return nil, fmt.Errorf("unable to bind to socket: %s", err) } //TODO: this may be useful for forcing threads into specific cores diff --git a/udp_linux_mips64le.go b/udp_linux_mips64le.go new file mode 100644 index 0000000..a61e0c8 --- /dev/null +++ b/udp_linux_mips64le.go @@ -0,0 +1,50 @@ +package nebula + +import "unsafe" + +type iovec struct { + Base *byte + Len uint64 +} + +type msghdr struct { + Name *byte + Namelen uint32 + Pad0 [4]byte + Iov *iovec + Iovlen uint64 + Control *byte + Controllen uint64 + Flags int32 + Pad1 [4]byte +} + +type rawMessage struct { + Hdr msghdr + Len uint32 + Pad0 [4]byte +} + +func (u *udpConn) PrepareRawMessages(n int) ([]rawMessage, [][]byte, [][]byte) { + msgs := make([]rawMessage, n) + buffers := make([][]byte, n) + names := make([][]byte, n) + + for i := range msgs { + buffers[i] = make([]byte, mtu) + names[i] = make([]byte, 0x1c) //TODO = sizeofSockaddrInet6 + + //TODO: this is still silly, no need for an array + vs := []iovec{ + {Base: (*byte)(unsafe.Pointer(&buffers[i][0])), Len: uint64(len(buffers[i]))}, + } + + msgs[i].Hdr.Iov = &vs[0] + msgs[i].Hdr.Iovlen = uint64(len(vs)) + + msgs[i].Hdr.Name = (*byte)(unsafe.Pointer(&names[i][0])) + msgs[i].Hdr.Namelen = uint32(len(names[i])) + } + + return msgs, buffers, names +} From 9bd8cd2c1100f51b6d3fdfa7d7e6a0e80e274e17 Mon Sep 17 00:00:00 2001 From: Nate Brown Date: Sat, 23 Nov 2019 11:28:40 -0800 Subject: [PATCH 3/7] Rebase on master, improve other fatal error messages --- main.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index 2fd6f83..5a99e88 100644 --- a/main.go +++ b/main.go @@ -59,20 +59,20 @@ func Main(configPath string, configTest bool, buildVersion string) { trustedCAs, err = loadCAFromConfig(config) if err != nil { //The errors coming out of loadCA are already nicely formatted - l.Fatal(err) + l.WithError(err).Fatal("Failed to load ca from config") } l.WithField("fingerprints", trustedCAs.GetFingerprints()).Debug("Trusted CA fingerprints") cs, err := NewCertStateFromConfig(config) if err != nil { //The errors coming out of NewCertStateFromConfig are already nicely formatted - l.Fatal(err) + l.WithError(err).Fatal("Failed to load certificate from config") } l.WithField("cert", cs.certificate).Debug("Client nebula certificate") fw, err := NewFirewallFromConfig(cs.certificate, config) if err != nil { - l.Fatal("Error while loading firewall rules: ", err) + l.WithError(err).Fatal("Error while loading firewall rules") } l.WithField("firewallHash", fw.GetRuleHash()).Info("Firewall started") @@ -131,7 +131,7 @@ func Main(configPath string, configTest bool, buildVersion string) { for _, rawPreferredRange := range rawPreferredRanges { _, preferredRange, err := net.ParseCIDR(rawPreferredRange) if err != nil { - l.Fatal(err) + l.WithError(err).Fatal("Failed to parse preferred ranges") } preferredRanges = append(preferredRanges, preferredRange) } @@ -144,7 +144,7 @@ func Main(configPath string, configTest bool, buildVersion string) { if rawLocalRange != "" { _, localRange, err := net.ParseCIDR(rawLocalRange) if err != nil { - l.Fatal(err) + l.WithError(err).Fatal("Failed to parse local range") } // Check if the entry for local_range was already specified in @@ -294,7 +294,7 @@ func Main(configPath string, configTest bool, buildVersion string) { ifce, err := NewInterface(ifConfig) if err != nil { - l.Fatal(err) + l.WithError(err).Fatal("Failed to initialize interface") } ifce.RegisterConfigChangeCallbacks(config) @@ -304,7 +304,7 @@ func Main(configPath string, configTest bool, buildVersion string) { err = startStats(config) if err != nil { - l.Fatal(err) + l.WithError(err).Fatal("Failed to start stats emitter") } //TODO: check if we _should_ be emitting stats From 5cad6a2ce3a7724659d189331e6486682b7ef01c Mon Sep 17 00:00:00 2001 From: Nate Brown Date: Sat, 23 Nov 2019 23:18:03 -0800 Subject: [PATCH 4/7] Improve tun activation error messages --- tun_linux.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tun_linux.go b/tun_linux.go index 2a1a197..a5c7ebb 100644 --- a/tun_linux.go +++ b/tun_linux.go @@ -168,43 +168,43 @@ func (c Tun) Activate() error { // Set the device ip address if err = ioctl(fd, syscall.SIOCSIFADDR, uintptr(unsafe.Pointer(&ifra))); err != nil { - return err + return fmt.Errorf("failed to set tun address: %s", err) } // Set the device network ifra.Addr.Addr = mask if err = ioctl(fd, syscall.SIOCSIFNETMASK, uintptr(unsafe.Pointer(&ifra))); err != nil { - return err + return fmt.Errorf("failed to set tun netmask: %s", err) } // Set the device name ifrf := ifReq{Name: devName} if err = ioctl(fd, syscall.SIOCGIFFLAGS, uintptr(unsafe.Pointer(&ifrf))); err != nil { - return err + return fmt.Errorf("failed to set tun device name: %s", err) } // Set the MTU on the device ifm := ifreqMTU{Name: devName, MTU: c.MaxMTU} if err = ioctl(fd, syscall.SIOCSIFMTU, uintptr(unsafe.Pointer(&ifm))); err != nil { - return err + return fmt.Errorf("failed to set tun mtu: %s", err) } // Set the transmit queue length ifrq := ifreqQLEN{Name: devName, Value: c.TXQueueLen} if err = ioctl(fd, syscall.SIOCSIFTXQLEN, uintptr(unsafe.Pointer(&ifrq))); err != nil { - return err + return fmt.Errorf("failed to set tun tx queue length: %s", err) } // Bring up the interface ifrf.Flags = ifrf.Flags | syscall.IFF_UP if err = ioctl(fd, syscall.SIOCSIFFLAGS, uintptr(unsafe.Pointer(&ifrf))); err != nil { - return err + return fmt.Errorf("failed to bring the tun device up: %s", err) } // Set the routes link, err := netlink.LinkByName(c.Device) if err != nil { - return err + return fmt.Errorf("failed to get tun device link: %s", err) } // Default route @@ -242,7 +242,7 @@ func (c Tun) Activate() error { // Run the interface ifrf.Flags = ifrf.Flags | syscall.IFF_UP | syscall.IFF_RUNNING if err = ioctl(fd, syscall.SIOCSIFFLAGS, uintptr(unsafe.Pointer(&ifrf))); err != nil { - return err + return fmt.Errorf("failed to run tun device: %s", err) } return nil From d62bb8b13c9ba9c5617d8a8f5f173a4e286ee522 Mon Sep 17 00:00:00 2001 From: Nate Brown Date: Mon, 25 Nov 2019 11:21:48 -0800 Subject: [PATCH 5/7] Force mtu to int32 --- tun_linux.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tun_linux.go b/tun_linux.go index a5c7ebb..ed4585c 100644 --- a/tun_linux.go +++ b/tun_linux.go @@ -65,7 +65,7 @@ type ifreqAddr struct { type ifreqMTU struct { Name [16]byte - MTU int + MTU int32 pad [8]byte } @@ -184,7 +184,7 @@ func (c Tun) Activate() error { } // Set the MTU on the device - ifm := ifreqMTU{Name: devName, MTU: c.MaxMTU} + ifm := ifreqMTU{Name: devName, MTU: int32(c.MaxMTU)} if err = ioctl(fd, syscall.SIOCSIFMTU, uintptr(unsafe.Pointer(&ifm))); err != nil { return fmt.Errorf("failed to set tun mtu: %s", err) } From 4bbf6dc29c452faff77a6dfcbdd3db1d9846c843 Mon Sep 17 00:00:00 2001 From: Nate Brown Date: Wed, 11 Dec 2019 10:38:45 -0800 Subject: [PATCH 6/7] Rework udp for linux into just 2 files, add more mips targets --- Makefile | 16 ++++++++- udp_linux_arm.go => udp_linux_32.go | 3 ++ udp_linux_amd64.go => udp_linux_64.go | 3 ++ udp_linux_arm64.go | 50 --------------------------- udp_linux_mips64.go | 50 --------------------------- udp_linux_mips64le.go | 50 --------------------------- 6 files changed, 21 insertions(+), 151 deletions(-) rename udp_linux_arm.go => udp_linux_32.go (94%) rename udp_linux_amd64.go => udp_linux_64.go (92%) delete mode 100644 udp_linux_arm64.go delete mode 100644 udp_linux_mips64.go delete mode 100644 udp_linux_mips64le.go diff --git a/Makefile b/Makefile index aca5e54..e566c7f 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ BUILD_NUMBER ?= dev+$(shell date -u '+%Y%m%d%H%M%S') GO111MODULE = on export GO111MODULE -all: bin-linux bin-arm bin-arm6 bin-arm64 bin-darwin bin-windows bin-mips64 bin-mips64le +all: bin-linux bin-arm bin-arm6 bin-arm64 bin-darwin bin-windows bin-mips bin-mipsle bin-mips64 bin-mips64le bin: go build -ldflags "-X main.Build=$(BUILD_NUMBER)" -o ./nebula ${NEBULA_CMD_PATH} @@ -47,6 +47,18 @@ bin-linux: GOARCH=amd64 GOOS=linux go build -o build/linux/nebula -ldflags "-X main.Build=$(BUILD_NUMBER)" ${NEBULA_CMD_PATH} GOARCH=amd64 GOOS=linux go build -o build/linux/nebula-cert -ldflags "-X main.Build=$(BUILD_NUMBER)" ./cmd/nebula-cert + +bin-mips: + mkdir -p build/mips + GOARCH=mips GOOS=linux go build -o build/mips/nebula -ldflags "-X main.Build=$(BUILD_NUMBER)" ./cmd/nebula + GOARCH=mips GOOS=linux go build -o build/mips/nebula-cert -ldflags "-X main.Build=$(BUILD_NUMBER)" ./cmd/nebula-cert + + +bin-mipsle: + mkdir -p build/mipsle + GOARCH=mipsle GOOS=linux go build -o build/mipsle/nebula -ldflags "-X main.Build=$(BUILD_NUMBER)" ./cmd/nebula + GOARCH=mipsle GOOS=linux go build -o build/mipsle/nebula-cert -ldflags "-X main.Build=$(BUILD_NUMBER)" ./cmd/nebula-cert + bin-mips64: mkdir -p build/mips64 GOARCH=mips64 GOOS=linux go build -o build/mips64/nebula -ldflags "-X main.Build=$(BUILD_NUMBER)" ./cmd/nebula @@ -64,6 +76,8 @@ release: all tar -zcv -C build/darwin/ -f nebula-darwin-amd64.tar.gz nebula nebula-cert tar -zcv -C build/windows/ -f nebula-windows-amd64.tar.gz nebula.exe nebula-cert.exe tar -zcv -C build/linux/ -f nebula-linux-amd64.tar.gz nebula nebula-cert + tar -zcv -C build/mips/ -f nebula-linux-mips.tar.gz nebula nebula-cert + tar -zcv -C build/mipsle/ -f nebula-linux-mipsle.tar.gz nebula nebula-cert tar -zcv -C build/mips64/ -f nebula-linux-mips64.tar.gz nebula nebula-cert tar -zcv -C build/mips64le/ -f nebula-linux-mips64le.tar.gz nebula nebula-cert diff --git a/udp_linux_arm.go b/udp_linux_32.go similarity index 94% rename from udp_linux_arm.go rename to udp_linux_32.go index 2641b2c..cb8233f 100644 --- a/udp_linux_arm.go +++ b/udp_linux_32.go @@ -1,3 +1,6 @@ +// +build linux +// +build 386 amd64p32 arm mips mipsle + package nebula import "unsafe" diff --git a/udp_linux_amd64.go b/udp_linux_64.go similarity index 92% rename from udp_linux_amd64.go rename to udp_linux_64.go index a61e0c8..bd5e3dc 100644 --- a/udp_linux_amd64.go +++ b/udp_linux_64.go @@ -1,3 +1,6 @@ +// +build linux +// +build amd64 arm64 ppc64 ppc64le mips64 mips64le s390x + package nebula import "unsafe" diff --git a/udp_linux_arm64.go b/udp_linux_arm64.go deleted file mode 100644 index a61e0c8..0000000 --- a/udp_linux_arm64.go +++ /dev/null @@ -1,50 +0,0 @@ -package nebula - -import "unsafe" - -type iovec struct { - Base *byte - Len uint64 -} - -type msghdr struct { - Name *byte - Namelen uint32 - Pad0 [4]byte - Iov *iovec - Iovlen uint64 - Control *byte - Controllen uint64 - Flags int32 - Pad1 [4]byte -} - -type rawMessage struct { - Hdr msghdr - Len uint32 - Pad0 [4]byte -} - -func (u *udpConn) PrepareRawMessages(n int) ([]rawMessage, [][]byte, [][]byte) { - msgs := make([]rawMessage, n) - buffers := make([][]byte, n) - names := make([][]byte, n) - - for i := range msgs { - buffers[i] = make([]byte, mtu) - names[i] = make([]byte, 0x1c) //TODO = sizeofSockaddrInet6 - - //TODO: this is still silly, no need for an array - vs := []iovec{ - {Base: (*byte)(unsafe.Pointer(&buffers[i][0])), Len: uint64(len(buffers[i]))}, - } - - msgs[i].Hdr.Iov = &vs[0] - msgs[i].Hdr.Iovlen = uint64(len(vs)) - - msgs[i].Hdr.Name = (*byte)(unsafe.Pointer(&names[i][0])) - msgs[i].Hdr.Namelen = uint32(len(names[i])) - } - - return msgs, buffers, names -} diff --git a/udp_linux_mips64.go b/udp_linux_mips64.go deleted file mode 100644 index a61e0c8..0000000 --- a/udp_linux_mips64.go +++ /dev/null @@ -1,50 +0,0 @@ -package nebula - -import "unsafe" - -type iovec struct { - Base *byte - Len uint64 -} - -type msghdr struct { - Name *byte - Namelen uint32 - Pad0 [4]byte - Iov *iovec - Iovlen uint64 - Control *byte - Controllen uint64 - Flags int32 - Pad1 [4]byte -} - -type rawMessage struct { - Hdr msghdr - Len uint32 - Pad0 [4]byte -} - -func (u *udpConn) PrepareRawMessages(n int) ([]rawMessage, [][]byte, [][]byte) { - msgs := make([]rawMessage, n) - buffers := make([][]byte, n) - names := make([][]byte, n) - - for i := range msgs { - buffers[i] = make([]byte, mtu) - names[i] = make([]byte, 0x1c) //TODO = sizeofSockaddrInet6 - - //TODO: this is still silly, no need for an array - vs := []iovec{ - {Base: (*byte)(unsafe.Pointer(&buffers[i][0])), Len: uint64(len(buffers[i]))}, - } - - msgs[i].Hdr.Iov = &vs[0] - msgs[i].Hdr.Iovlen = uint64(len(vs)) - - msgs[i].Hdr.Name = (*byte)(unsafe.Pointer(&names[i][0])) - msgs[i].Hdr.Namelen = uint32(len(names[i])) - } - - return msgs, buffers, names -} diff --git a/udp_linux_mips64le.go b/udp_linux_mips64le.go deleted file mode 100644 index a61e0c8..0000000 --- a/udp_linux_mips64le.go +++ /dev/null @@ -1,50 +0,0 @@ -package nebula - -import "unsafe" - -type iovec struct { - Base *byte - Len uint64 -} - -type msghdr struct { - Name *byte - Namelen uint32 - Pad0 [4]byte - Iov *iovec - Iovlen uint64 - Control *byte - Controllen uint64 - Flags int32 - Pad1 [4]byte -} - -type rawMessage struct { - Hdr msghdr - Len uint32 - Pad0 [4]byte -} - -func (u *udpConn) PrepareRawMessages(n int) ([]rawMessage, [][]byte, [][]byte) { - msgs := make([]rawMessage, n) - buffers := make([][]byte, n) - names := make([][]byte, n) - - for i := range msgs { - buffers[i] = make([]byte, mtu) - names[i] = make([]byte, 0x1c) //TODO = sizeofSockaddrInet6 - - //TODO: this is still silly, no need for an array - vs := []iovec{ - {Base: (*byte)(unsafe.Pointer(&buffers[i][0])), Len: uint64(len(buffers[i]))}, - } - - msgs[i].Hdr.Iov = &vs[0] - msgs[i].Hdr.Iovlen = uint64(len(vs)) - - msgs[i].Hdr.Name = (*byte)(unsafe.Pointer(&names[i][0])) - msgs[i].Hdr.Namelen = uint32(len(names[i])) - } - - return msgs, buffers, names -} From 38dc2ab3476802c141c029ce26706af1c484db07 Mon Sep 17 00:00:00 2001 From: Nate Brown Date: Wed, 11 Dec 2019 12:02:57 -0800 Subject: [PATCH 7/7] Same story for txqueuelen --- tun_linux.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tun_linux.go b/tun_linux.go index ed4585c..1099f5e 100644 --- a/tun_linux.go +++ b/tun_linux.go @@ -71,7 +71,7 @@ type ifreqMTU struct { type ifreqQLEN struct { Name [16]byte - Value int + Value int32 pad [8]byte } @@ -190,7 +190,7 @@ func (c Tun) Activate() error { } // Set the transmit queue length - ifrq := ifreqQLEN{Name: devName, Value: c.TXQueueLen} + ifrq := ifreqQLEN{Name: devName, Value: int32(c.TXQueueLen)} if err = ioctl(fd, syscall.SIOCSIFTXQLEN, uintptr(unsafe.Pointer(&ifrq))); err != nil { return fmt.Errorf("failed to set tun tx queue length: %s", err) }