summaryrefslogtreecommitdiffhomepage
path: root/tun
diff options
context:
space:
mode:
authorMichael Zeltner <m@niij.org>2019-07-17 23:04:01 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-07-18 10:25:20 +0200
commit4d5819183e218e040fa0a73df560b4a4a9a768d7 (patch)
tree02243d898e9f676b784c3c5bbe947d3fe2ff0c50 /tun
parent9ea9a921178fe6b0e1e823cea2cd73d654217b4c (diff)
tun: openbsd: don't change MTU when it's already the expected size
Allows for running wireguard-go as non-root user. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'tun')
-rw-r--r--tun/tun_openbsd.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/tun/tun_openbsd.go b/tun/tun_openbsd.go
index 1e6191f..bbc0432 100644
--- a/tun/tun_openbsd.go
+++ b/tun/tun_openbsd.go
@@ -173,10 +173,13 @@ func CreateTUNFromFile(file *os.File, mtu int) (Device, error) {
go tun.routineRouteListener(tunIfindex)
- err = tun.setMTU(mtu)
- if err != nil {
- tun.Close()
- return nil, err
+ currentMTU, err := tun.MTU()
+ if err != nil || currentMTU != mtu {
+ err = tun.setMTU(mtu)
+ if err != nil {
+ tun.Close()
+ return nil, err
+ }
}
return tun, nil