]> git.ipfire.org Git - thirdparty/wireguard-go.git/commitdiff
device: don't track device interface state in RoutineTUNEventReader
authorJosh Bleecher Snyder <josh@tailscale.com>
Thu, 21 Jan 2021 17:26:14 +0000 (09:26 -0800)
committerJosh Bleecher Snyder <josh@tailscale.com>
Mon, 8 Feb 2021 18:32:07 +0000 (10:32 -0800)
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>
device/tun.go

index 17c2493e2689e28ef6154d1898956d8965deb7b7..4af9548218f981064913c55507185667c13f8098 100644 (file)
@@ -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()
                }
        }