summaryrefslogtreecommitdiff
path: root/device/tun.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2021-01-26 23:05:48 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2021-01-26 23:05:48 +0100
commitd669c78c4306290963415568f4a64a1ae2b35b20 (patch)
tree189a833daf57ffded2e177bfe5a554fd1b886392 /device/tun.go
parent7139279cd0b08ebbd2c0322bc01d5678aa00cd0e (diff)
downloadwireguard-go-d669c78c4306290963415568f4a64a1ae2b35b20.tar.gz
wireguard-go-d669c78c4306290963415568f4a64a1ae2b35b20.zip
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>
Diffstat (limited to 'device/tun.go')
-rw-r--r--device/tun.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/device/tun.go b/device/tun.go
index 97f1276..ae5cae1 100644
--- a/device/tun.go
+++ b/device/tun.go
@@ -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()
}