* [PATCH] tun: openbsd: Don't change MTU when it's already the expected size
@ 2019-07-15 23:46 Michael Zeltner
2019-07-17 21:04 ` Jason A. Donenfeld
0 siblings, 1 reply; 2+ messages in thread
From: Michael Zeltner @ 2019-07-15 23:46 UTC (permalink / raw)
To: wireguard; +Cc: Michael Zeltner
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
_______________________________________________
WireGuard mailing list
WireGuard@lists.zx2c4.com
https://lists.zx2c4.com/mailman/listinfo/wireguard
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-07-17 21:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-15 23:46 [PATCH] tun: openbsd: Don't change MTU when it's already the expected size Michael Zeltner
2019-07-17 21:04 ` Jason A. Donenfeld
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).