From: Arne Schwabe Date: Sat, 25 Jul 2020 23:50:23 +0000 (+0200) Subject: Include utun device number in utun error messages X-Git-Tag: v2.5_beta1~34 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1d86fae8740a6d025d550fdcb4aa13c755fc2e48;p=thirdparty%2Fopenvpn.git Include utun device number in utun error messages For lack of a better API (or knowledge about a better API) we try to open utun devices on macOS by trying utun0 to utun255 and use the first one that works. On my Mac I have already 4 devices that do nothing but are just there and another VPN connection resulting in a number of error messages. This explicitly shows in the log that we tried the devices instead of some unspecific error. This changes the log from: Opening utun (connect(AF_SYS_CONTROL)): Resource busy (errno=16) Opening utun (connect(AF_SYS_CONTROL)): Resource busy (errno=16) Opening utun (connect(AF_SYS_CONTROL)): Resource busy (errno=16) Opening utun (connect(AF_SYS_CONTROL)): Resource busy (errno=16) Opening utun (connect(AF_SYS_CONTROL)): Resource busy (errno=16) Opened utun device utun5 to Opening utun0 failed (connect(AF_SYS_CONTROL)): Resource busy (errno=16) Opening utun1 failed (connect(AF_SYS_CONTROL)): Resource busy (errno=16) Opening utun2 failed (connect(AF_SYS_CONTROL)): Resource busy (errno=16) Opening utun3 failed (connect(AF_SYS_CONTROL)): Resource busy (errno=16) Opening utun4 failed (connect(AF_SYS_CONTROL)): Resource busy (errno=16) Opened utun device utun5 Signed-off-by: Arne Schwabe Feature-ACK-by: "Jonathan K. Bullard" Acked-by: Gert Doering Message-Id: <20200725235023.22441-1-arne@rfc2549.org> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20590.html Signed-off-by: Gert Doering --- diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index 82d96927c..cc7b65cf4 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -2950,14 +2950,16 @@ utun_open_helper(struct ctl_info ctlInfo, int utunnum) if (fd < 0) { - msg(M_INFO | M_ERRNO, "Opening utun (socket(SYSPROTO_CONTROL))"); + msg(M_INFO | M_ERRNO, "Opening utun%d failed (socket(SYSPROTO_CONTROL))", + utunnum); return -2; } if (ioctl(fd, CTLIOCGINFO, &ctlInfo) == -1) { close(fd); - msg(M_INFO | M_ERRNO, "Opening utun (ioctl(CTLIOCGINFO))"); + msg(M_INFO | M_ERRNO, "Opening utun%d failed (ioctl(CTLIOCGINFO))", + utunnum); return -2; } @@ -2975,7 +2977,8 @@ utun_open_helper(struct ctl_info ctlInfo, int utunnum) if (connect(fd, (struct sockaddr *)&sc, sizeof(sc)) < 0) { - msg(M_INFO | M_ERRNO, "Opening utun (connect(AF_SYS_CONTROL))"); + msg(M_INFO | M_ERRNO, "Opening utun%d failed (connect(AF_SYS_CONTROL))", + utunnum); close(fd); return -1; }