[PATCH] tun: openbsd: Don't change MTU when it's already the expected size
Michael Zeltner
m at niij.org
Tue Jul 16 01:46:35 CEST 2019
Allows for running wireguard-go as non-root user
---
tun/tun_openbsd.go | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/tun/tun_openbsd.go b/tun/tun_openbsd.go
index 1e6191f..bdca231 100644
--- a/tun/tun_openbsd.go
+++ b/tun/tun_openbsd.go
@@ -173,12 +173,21 @@ func CreateTUNFromFile(file *os.File, mtu int) (Device, error) {
go tun.routineRouteListener(tunIfindex)
- err = tun.setMTU(mtu)
+ var cur_mtu int
+ cur_mtu, err = tun.MTU()
if err != nil {
tun.Close()
return nil, err
}
+ if cur_mtu != mtu {
+ err = tun.setMTU(mtu)
+ if err != nil {
+ tun.Close()
+ return nil, err
+ }
+ }
+
return tun, nil
}
--
2.21.0
More information about the WireGuard
mailing list