aboutsummaryrefslogtreecommitdiff
path: root/device/sticky_linux.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2021-02-22 02:01:50 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2021-02-23 20:00:57 +0100
commita4f8e83d5d9f477554971e90e9ab85922f506ea9 (patch)
tree5249ac2dbdc8cbb6a7d2d40814b07d7d1f38ad4d /device/sticky_linux.go
parentc69481f1b3b4b37b9c16f997a5d8d91367d9bfee (diff)
downloadwireguard-go-a4f8e83d5d9f477554971e90e9ab85922f506ea9.tar.gz
wireguard-go-a4f8e83d5d9f477554971e90e9ab85922f506ea9.zip
conn: make binds replacable
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'device/sticky_linux.go')
-rw-r--r--device/sticky_linux.go15
1 files changed, 9 insertions, 6 deletions
diff --git a/device/sticky_linux.go b/device/sticky_linux.go
index a984f24..6193ea3 100644
--- a/device/sticky_linux.go
+++ b/device/sticky_linux.go
@@ -1,5 +1,3 @@
-// +build !android
-
/* SPDX-License-Identifier: MIT
*
* Copyright (C) 2017-2021 WireGuard LLC. All Rights Reserved.
@@ -21,11 +19,16 @@ import (
"unsafe"
"golang.org/x/sys/unix"
+
"golang.zx2c4.com/wireguard/conn"
"golang.zx2c4.com/wireguard/rwcancel"
)
func (device *Device) startRouteListener(bind conn.Bind) (*rwcancel.RWCancel, error) {
+ if _, ok := bind.(*conn.LinuxSocketBind); !ok {
+ return nil, nil
+ }
+
netlinkSock, err := createNetlinkRouteSocket()
if err != nil {
return nil, err
@@ -109,11 +112,11 @@ func (device *Device) routineRouteListener(bind conn.Bind, netlinkSock int, netl
pePtr.peer.Unlock()
break
}
- if uint32(pePtr.peer.endpoint.(*conn.NativeEndpoint).Src4().Ifindex) == ifidx {
+ if uint32(pePtr.peer.endpoint.(*conn.LinuxSocketEndpoint).Src4().Ifindex) == ifidx {
pePtr.peer.Unlock()
break
}
- pePtr.peer.endpoint.(*conn.NativeEndpoint).ClearSrc()
+ pePtr.peer.endpoint.(*conn.LinuxSocketEndpoint).ClearSrc()
pePtr.peer.Unlock()
}
attr = attr[attrhdr.Len:]
@@ -133,7 +136,7 @@ func (device *Device) routineRouteListener(bind conn.Bind, netlinkSock int, netl
peer.RUnlock()
continue
}
- nativeEP, _ := peer.endpoint.(*conn.NativeEndpoint)
+ nativeEP, _ := peer.endpoint.(*conn.LinuxSocketEndpoint)
if nativeEP == nil {
peer.RUnlock()
continue
@@ -176,7 +179,7 @@ func (device *Device) routineRouteListener(bind conn.Bind, netlinkSock int, netl
Len: 8,
Type: unix.RTA_MARK,
},
- uint32(bind.LastMark()),
+ device.net.fwmark,
}
nlmsg.hdr.Len = uint32(unsafe.Sizeof(nlmsg))
reqPeerLock.Lock()