Re: [Openvpn-devel] [PATCH] Skip existing interfaces on opening the first available utun on macOS
Am 05.08.20 um 11:02 schrieb Lev Stipakov: > Hi, > > +ASSERT(snprintf(ifname, sizeof(ifname), "utun%d", utunnum)); > > Not sure about ASSERT here, because according to > https://linux.die.net/man/3/snprintf > >> If an output error is encountered, a negative value is returned. > > which won't trigger assert. > > Otherwise looks good. > > Compiled and tested on macOS. > > Maybe Gert could remove ASSERT wrapping before commiting. > > Acked-by: Lev Stipakov > You are too late, there is already a v2 that fixed that problem and is merged :) Arne ___ Openvpn-devel mailing list Openvpn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Re: [Openvpn-devel] [PATCH] Skip existing interfaces on opening the first available utun on macOS
Hi, +ASSERT(snprintf(ifname, sizeof(ifname), "utun%d", utunnum)); Not sure about ASSERT here, because according to https://linux.die.net/man/3/snprintf > If an output error is encountered, a negative value is returned. which won't trigger assert. Otherwise looks good. Compiled and tested on macOS. Maybe Gert could remove ASSERT wrapping before commiting. Acked-by: Lev Stipakov ___ Openvpn-devel mailing list Openvpn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Re: [Openvpn-devel] [PATCH] Skip existing interfaces on opening the first available utun on macOS
Hi, On Fri, Jul 31, 2020 at 12:06:29PM +0200, Arne Schwabe wrote: > This avoids the error messages trying to open already used utuns. > > Signed-off-by: Arne Schwabe I think the code looks good, but I have no time right now to test it (I can build MacOS binaries but have no test environment set up "just now"). Jonathan, do you have time? gert -- "If was one thing all people took for granted, was conviction that if you feed honest figures into a computer, honest figures come out. Never doubted it myself till I met a computer with a sense of humor." Robert A. Heinlein, The Moon is a Harsh Mistress Gert Doering - Munich, Germany g...@greenie.muc.de signature.asc Description: PGP signature ___ Openvpn-devel mailing list Openvpn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-devel
[Openvpn-devel] [PATCH] Skip existing interfaces on opening the first available utun on macOS
This avoids the error messages trying to open already used utuns. Signed-off-by: Arne Schwabe --- src/openvpn/tun.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index cc7b65cf..b9e444b6 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -3023,6 +3023,13 @@ open_darwin_utun(const char *dev, const char *dev_type, const char *dev_node, st { for (utunnum = 0; utunnum<255; utunnum++) { +char ifname[20]; +/* if the interface exists silently skip it */ +ASSERT(snprintf(ifname, sizeof(ifname), "utun%d", utunnum)); +if (if_nametoindex(ifname)) +{ +continue; +} fd = utun_open_helper(ctlInfo, utunnum); /* Break if the fd is valid, * or if early initialization failed (-2) */ -- 2.26.2 ___ Openvpn-devel mailing list Openvpn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-devel