aboutsummaryrefslogtreecommitdiffstats
path: root/device
diff options
context:
space:
mode:
authorJosh Bleecher Snyder <josh@tailscale.com>2021-01-21 09:26:14 -0800
committerJosh Bleecher Snyder <josh@tailscale.com>2021-02-08 10:32:07 -0800
commitd840445e9bdd4f4db3538c9caf93d797cc987fbc (patch)
tree04e37a07845829a2e1bc4dd9c757c1505e8514e1 /device
parentdevice: improve MTU change handling (diff)
downloadwireguard-go-d840445e9bdd4f4db3538c9caf93d797cc987fbc.tar.xz
wireguard-go-d840445e9bdd4f4db3538c9caf93d797cc987fbc.zip
device: don't track device interface state in RoutineTUNEventReader
We already track this state elsewhere. No need to duplicate. The cost of calling changeState is negligible. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
Diffstat (limited to 'device')
-rw-r--r--device/tun.go11
1 files changed, 4 insertions, 7 deletions
diff --git a/device/tun.go b/device/tun.go
index 17c2493..4af9548 100644
--- a/device/tun.go
+++ b/device/tun.go
@@ -15,7 +15,6 @@ import (
const DefaultMTU = 1420
func (device *Device) RoutineTUNEventReader() {
- setUp := false
device.log.Verbosef("Routine: event worker - started")
for event := range device.tun.device.Events() {
@@ -40,15 +39,13 @@ func (device *Device) RoutineTUNEventReader() {
}
}
- if event&tun.EventUp != 0 && !setUp {
- device.log.Verbosef("Interface set up")
- setUp = true
+ if event&tun.EventUp != 0 {
+ device.log.Verbosef("Interface up requested")
device.Up()
}
- if event&tun.EventDown != 0 && setUp {
- device.log.Verbosef("Interface set down")
- setUp = false
+ if event&tun.EventDown != 0 {
+ device.log.Verbosef("Interface down requested")
device.Down()
}
}