WireGuard Archive on lore.kernel.org
 help / color / Atom feed
* [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

* Re: [PATCH] tun: openbsd: Don't change MTU when it's already the expected size
  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
  0 siblings, 0 replies; 2+ messages in thread
From: Jason A. Donenfeld @ 2019-07-17 21:04 UTC (permalink / raw)
  To: Michael Zeltner; +Cc: WireGuard mailing list

Thanks! I rewrote and merged a variant of this.

Jason
_______________________________________________
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, back to index

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

WireGuard Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/wireguard/0 wireguard/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 wireguard wireguard/ https://lore.kernel.org/wireguard \
		wireguard@lists.zx2c4.com zx2c4-wireguard@archiver.kernel.org
	public-inbox-index wireguard


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/com.zx2c4.lists.wireguard


AGPL code for this site: git clone https://public-inbox.org/ public-inbox