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>
const DefaultMTU = 1420
func (device *Device) RoutineTUNEventReader() {
- setUp := false
device.log.Verbosef("Routine: event worker - started")
for event := range device.tun.device.Events() {
}
}
- 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()
}
}