tun: openbsd: Don't change MTU when it's already the expected size
PATCH 1/1 tun: openbsd: Don't change MTU when it's already the expected size
Allows for running wireguard-go as non-root user
--- tun/tun_openbsd.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
tun/tun_openbsd.go +10 -1
@@ -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 }
Signature · 6 lines
2.21.0 _______________________________________________ WireGuard mailing list [email protected] https://lists.zx2c4.com/mailman/listinfo/wireguard
Thanks! I rewrote and merged a variant of this.
Jason
_______________________________________________
WireGuard mailing list
[email protected]
https://lists.zx2c4.com/mailman/listinfo/wireguard