device: combine debug and info log levels into 'verbose'
There are very few cases, if any, in which a user only wants one of these levels, so combine it into a single level. While we're at it, reduce indirection on the loggers by using an empty function rather than a nil function pointer. It's not like we have retpolines anyway, and we were always calling through a function with a branch prior, so this seems like a net gain. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
@@ -15,37 +15,37 @@ const DefaultMTU = 1420
|
||||
|
||||
func (device *Device) RoutineTUNEventReader() {
|
||||
setUp := false
|
||||
device.debugf("Routine: event worker - started")
|
||||
device.log.Verbosef("Routine: event worker - started")
|
||||
|
||||
for event := range device.tun.device.Events() {
|
||||
if event&tun.EventMTUUpdate != 0 {
|
||||
mtu, err := device.tun.device.MTU()
|
||||
old := atomic.LoadInt32(&device.tun.mtu)
|
||||
if err != nil {
|
||||
device.errorf("Failed to load updated MTU of device: %v", err)
|
||||
device.log.Errorf("Failed to load updated MTU of device: %v", err)
|
||||
} else if int(old) != mtu {
|
||||
if mtu+MessageTransportSize > MaxMessageSize {
|
||||
device.infof("MTU updated: %v (too large)", mtu)
|
||||
device.log.Verbosef("MTU updated: %v (too large)", mtu)
|
||||
} else {
|
||||
device.infof("MTU updated: %v", mtu)
|
||||
device.log.Verbosef("MTU updated: %v", mtu)
|
||||
}
|
||||
atomic.StoreInt32(&device.tun.mtu, int32(mtu))
|
||||
}
|
||||
}
|
||||
|
||||
if event&tun.EventUp != 0 && !setUp {
|
||||
device.infof("Interface set up")
|
||||
device.log.Verbosef("Interface set up")
|
||||
setUp = true
|
||||
device.Up()
|
||||
}
|
||||
|
||||
if event&tun.EventDown != 0 && setUp {
|
||||
device.infof("Interface set down")
|
||||
device.log.Verbosef("Interface set down")
|
||||
setUp = false
|
||||
device.Down()
|
||||
}
|
||||
}
|
||||
|
||||
device.debugf("Routine: event worker - stopped")
|
||||
device.log.Verbosef("Routine: event worker - stopped")
|
||||
device.state.stopping.Done()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user