From: Arne S. <ar...@rf...> - 2020-07-31 10:06:51
|
This avoids the error messages trying to open already used utuns. Signed-off-by: Arne Schwabe <ar...@rf...> --- 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 |