summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-05-24 18:00:45 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-05-24 18:21:14 +0200
commit4365b4583fa32b1b77d33f5074da9c165a28f824 (patch)
tree56c9017b0a050f0c6b2167688bbb122dc6be69bf
parentbbf320c477ea10a28c2199187f6f29b3dcb07bcb (diff)
Trick for being extra sensitive to route changes
-rw-r--r--conn_linux.go21
1 files changed, 16 insertions, 5 deletions
diff --git a/conn_linux.go b/conn_linux.go
index bde4416..396c403 100644
--- a/conn_linux.go
+++ b/conn_linux.go
@@ -58,11 +58,12 @@ func (endpoint *NativeEndpoint) dst6() *unix.SockaddrInet6 {
}
type NativeBind struct {
- sock4 int
- sock6 int
- netlinkSock int
- netlinkCancel *rwcancel.RWCancel
- lastMark uint32
+ sock4 int
+ sock6 int
+ netlinkSock int
+ netlinkCancel *rwcancel.RWCancel
+ lastMark uint32
+ clearSourceOnAllRouteChanges bool
}
var _ Endpoint = (*NativeEndpoint)(nil)
@@ -582,6 +583,16 @@ func (bind *NativeBind) routineRouteListener(device *Device) {
switch hdr.Type {
case unix.RTM_NEWROUTE, unix.RTM_DELROUTE:
+ if bind.clearSourceOnAllRouteChanges {
+ for _, peer := range device.peers.keyMap {
+ peer.mutex.Lock()
+ if peer.endpoint != nil && peer.endpoint.(*NativeEndpoint) != nil {
+ peer.endpoint.(*NativeEndpoint).ClearSrc()
+ }
+ peer.mutex.Unlock()
+ }
+ break
+ }
if hdr.Seq <= MaxPeers && hdr.Seq > 0 {
if uint(len(remain)) < uint(hdr.Len) {
break