From patchwork Mon Apr 1 00:21:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Schenk X-Patchwork-Id: 711 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director9.mail.ord1d.rsapps.net ([172.27.255.1]) by backend30.mail.ord1d.rsapps.net with LMTP id +ADVMaP0oVxeDgAAIUCqbw for ; Mon, 01 Apr 2019 07:23:15 -0400 Received: from proxy8.mail.iad3a.rsapps.net ([172.27.255.1]) by director9.mail.ord1d.rsapps.net with LMTP id AGE4L6P0oVxZRQAAalYnBA ; Mon, 01 Apr 2019 07:23:15 -0400 Received: from smtp25.gate.iad3a ([172.27.255.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy8.mail.iad3a.rsapps.net with LMTP id UEYEKaP0oVwjCgAAsBr/qg ; Mon, 01 Apr 2019 07:23:15 -0400 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp25.gate.iad3a.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dkim=fail (signature verification failed) header.d=mail.uni-paderborn.de; dmarc=fail (p=none; dis=none) header.from=mail.uni-paderborn.de X-Suspicious-Flag: YES X-Classification-ID: 89733c30-5470-11e9-aa0b-52540086a678-1-1 Received: from [216.105.38.7] ([216.105.38.7:16656] helo=lists.sourceforge.net) by smtp25.gate.iad3a.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id A2/DC-24938-1A4F1AC5; Mon, 01 Apr 2019 07:23:13 -0400 Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1hAv0x-0008C1-GL; Mon, 01 Apr 2019 11:22:07 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1hAv0t-0008Bm-Q0 for openvpn-devel@lists.sourceforge.net; Mon, 01 Apr 2019 11:22:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=UgUCAIu2U+TcTI9Dscl6zXJZX8nmKy/MwBMshEDHt8w=; b=bKjfDdmH97cXSdMQ4cK0DUJ/xn UDzjt2ALUCkfaIZH0Zbwf+VARfAq0lhXekIbvKIObAJQsoN5ItplyE7Rzf357xXoHeiIfi1Pf1+8D gxO/CzYK93sBzQ+AM+Y3EZnw2glaLW0bUSTeeKiyyKNRjEtnShfKmAyqLA1obNn/Arh0=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=UgUCAIu2U+TcTI9Dscl6zXJZX8nmKy/MwBMshEDHt8w=; b=mqtiVNxqe8r7d1UidbDCRRR4Qz r2JEByJxttGdx7QiRm1hVrx2hgfNobsCsiZVEZTGRwZrulA/ZX7wAHK5fNUzNSdM3YmM9jo2SX+Jy pGOPSWxOL1WIXjiskfsuwruVA1FAYRmiV1B5Dv8iLdfiNAe3H8FvEXNNMxwNG712rHFk=; Received: from mail.uni-paderborn.de ([131.234.142.9]) by sfi-mx-3.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) id 1hAv0r-009vxC-Rl for openvpn-devel@lists.sourceforge.net; Mon, 01 Apr 2019 11:22:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.uni-paderborn.de; s=20170601; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=UgUCAIu2U+TcTI9Dscl6zXJZX8nmKy/MwBMshEDHt8w=; b=aIWK3U/HqgNL60oYxl5FRWU91X kRbD9VnntuFrR11Os9SOgGvSQq6isPeGGZdixB9jmU560vHXnlNRiR7e1b+oU1nRul15zP3OistJj bEpEgizbKfq41156O5WmhE9x281QO2FRV1YwIv1KrpUb2ig8XrMHHhx4FuNfDgafnNdM=; From: Christopher Schenk To: openvpn-devel@lists.sourceforge.net Date: Mon, 1 Apr 2019 13:21:37 +0200 Message-Id: <20190401112140.13212-1-cschenk@mail.uni-paderborn.de> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20190329193805.GQ31008@greenie.muc.de> References: <20190329193805.GQ31008@greenie.muc.de> MIME-Version: 1.0 X-IMT-Spam-Score: 0.0 () X-PMX-Version: 6.4.6.2792898, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2019.4.1.111216, AntiVirus-Engine: 5.58.0, AntiVirus-Data: 2019.2.22.5580002 X-IMT-Authenticated-Sender: uid=cschenk,ou=People,o=upb,c=de X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-Headers-End: 1hAv0r-009vxC-Rl Subject: [Openvpn-devel] [PATCH 1/4] Setting adapter mtu on windows systems X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christopher Schenk Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox From: Christopher Schenk --- src/openvpn/tun.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index 48a8fdf7..93d028c8 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -69,6 +69,12 @@ static void netsh_ifconfig(const struct tuntap_options *to, const in_addr_t netmask, const unsigned int flags); +static void netsh_set_mtu_ipv4(const char *flex_name, + const int mtu); + +static void netsh_set_mtu_ipv6(const char *flex_name, + const int mtu); + static void netsh_set_dns6_servers(const struct in6_addr *addr_list, const int addr_len, const char *flex_name); @@ -1000,6 +1006,7 @@ do_ifconfig_ipv6(struct tuntap *tt, const char *ifname, int tun_mtu, netsh_command(&argv, 4, M_FATAL); /* set ipv6 dns servers if any are specified */ netsh_set_dns6_servers(tt->options.dns6, tt->options.dns6_len, ifname); + netsh_set_mtu_ipv6(ifname, tun_mtu); } /* explicit route needed */ @@ -1391,9 +1398,9 @@ do_ifconfig_ipv4(struct tuntap *tt, const char *ifname, int tun_mtu, case IPW32_SET_NETSH: netsh_ifconfig(&tt->options, ifname, tt->local, tt->adapter_netmask, NI_IP_NETMASK|NI_OPTIONS); - break; } + netsh_set_mtu_ipv4(ifname, tun_mtu); } #else /* if defined(TARGET_LINUX) */ @@ -5236,6 +5243,36 @@ out: return ret; } +static void +netsh_set_mtu_ipv4(const char *flex_name, + const int mtu) +{ + struct argv argv = argv_new(); + argv_printf(&argv, "%s%sc interface ipv4 set subinterface %s mtu = %d store=active", + get_win_sys_path(), + NETSH_PATH_SUFFIX, + flex_name, + mtu); + + netsh_command(&argv, 3, M_WARN); + argv_reset(&argv); +} + +static void +netsh_set_mtu_ipv6(const char *flex_name, + const int mtu) +{ + struct argv argv = argv_new(); + argv_printf(&argv, "%s%sc interface ipv6 set subinterface %s mtu = %d store=active", + get_win_sys_path(), + NETSH_PATH_SUFFIX, + flex_name, + mtu); + + netsh_command(&argv, 3, M_WARN); + argv_reset(&argv); +} + /* * Return a TAP name for netsh commands. */ From patchwork Mon Apr 1 00:21:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Schenk X-Patchwork-Id: 709 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director8.mail.ord1d.rsapps.net ([172.27.255.54]) by backend30.mail.ord1d.rsapps.net with LMTP id mA1vDp30oVwtcAAAIUCqbw for ; Mon, 01 Apr 2019 07:23:09 -0400 Received: from proxy7.mail.iad3a.rsapps.net ([172.27.255.54]) by director8.mail.ord1d.rsapps.net with LMTP id sFUbDJ30oVzeSwAAfY0hYg ; Mon, 01 Apr 2019 07:23:09 -0400 Received: from smtp13.gate.iad3a ([172.27.255.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy7.mail.iad3a.rsapps.net with LMTP id 8Mi0BZ30oVwhcwAAnPvY+A ; Mon, 01 Apr 2019 07:23:09 -0400 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp13.gate.iad3a.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dmarc=fail (p=none; dis=none) header.from=mail.uni-paderborn.de X-Suspicious-Flag: YES X-Classification-ID: 862c163c-5470-11e9-8f0a-5254004b83b1-1-1 Received: from [216.105.38.7] ([216.105.38.7:51431] helo=lists.sourceforge.net) by smtp13.gate.iad3a.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id AF/6B-27142-C94F1AC5; Mon, 01 Apr 2019 07:23:08 -0400 Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1hAv0v-000788-E3; Mon, 01 Apr 2019 11:22:05 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1hAv0u-00077p-Db for openvpn-devel@lists.sourceforge.net; Mon, 01 Apr 2019 11:22:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=WIaSfy2qTb2LRdzNMJtDw5wYpZtOSVPb2jXzdomTlIw=; b=NtLs9r9eY42Wa4sjXdMc8sbl/u 0ItUu9Xbtl8f5FzQyhucaAlV5W/d1h3qUsVwHsWT4cw5ldvS0AD8izV+xj42ISQXpvgszlr6IzgKn yt1bGs+GJh7YNTV1Q6NqOn2EkWi/hn21xgWUlAQMbVo6T64cGIf5zlCON0t2vZb8rN5Q=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=WIaSfy2qTb2LRdzNMJtDw5wYpZtOSVPb2jXzdomTlIw=; b=N6nEUT0u06T2Q9h31mv2r7yZkQ qvHyxgJ5J+1q4iKnoCsA+f8ZM2nL4xcnlYYvZ9ZOuACL+35lAMglYkEVdX3Q+0tS7flZZzFCMBSVi tpyC0FrzLojvkY3//oXkgDD4WtTO7MocOiQGIqstX5XDn5toylTMZVCDTUvp7RYsPGEc=; Received: from mail.uni-paderborn.de ([131.234.142.9]) by sfi-mx-4.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) id 1hAv0s-009TjC-Gz for openvpn-devel@lists.sourceforge.net; Mon, 01 Apr 2019 11:22:04 +0000 Received: from tweenies.uni-paderborn.de ([131.234.189.21] helo=localhost.localdomain) by mail.uni-paderborn.de with esmtp (Exim 4.89 nylar) id 1hAv0j-0001t3-OS for openvpn-devel@lists.sourceforge.net; Mon, 01 Apr 2019 13:21:53 +0200 Received: from mail.uni-paderborn.de by tweenies with queue id 3212993-4 for openvpn-devel@lists.sourceforge.net; Mon, 01 Apr 2019 11:21:52 GMT From: Christopher Schenk To: openvpn-devel@lists.sourceforge.net Date: Mon, 1 Apr 2019 13:21:38 +0200 Message-Id: <20190401112140.13212-2-cschenk@mail.uni-paderborn.de> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20190401112140.13212-1-cschenk@mail.uni-paderborn.de> References: <20190329193805.GQ31008@greenie.muc.de> <20190401112140.13212-1-cschenk@mail.uni-paderborn.de> MIME-Version: 1.0 X-PMX-Version: 6.4.6.2792898, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2019.4.1.111216, AntiVirus-Engine: 5.58.0, AntiVirus-Data: 2019.2.22.5580002 X-IMT-Spam-Score: 0.0 () X-IMT-Authenticated-Sender: X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1hAv0s-009TjC-Gz Subject: [Openvpn-devel] [PATCH 2/4] Setting MTU also via interactive service X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox --- include/openvpn-msg.h | 8 +++++ src/openvpn/tun.c | 67 ++++++++++++++++++++++++++++++++++- src/openvpnserv/interactive.c | 50 ++++++++++++++++++++++++++ 3 files changed, 124 insertions(+), 1 deletion(-) diff --git a/include/openvpn-msg.h b/include/openvpn-msg.h index 66177a21..f59c5a21 100644 --- a/include/openvpn-msg.h +++ b/include/openvpn-msg.h @@ -39,6 +39,7 @@ typedef enum { msg_del_block_dns, msg_register_dns, msg_enable_dhcp, + msg_set_mtu, } message_type_t; typedef struct { @@ -117,4 +118,11 @@ typedef struct { interface_t iface; } enable_dhcp_message_t; +typedef struct { + message_header_t header; + interface_t iface; + short family; + int mtu; +} set_mtu_message_t; + #endif /* ifndef OPENVPN_MSG_H_ */ diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index 93d028c8..b0230a7c 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -207,6 +207,63 @@ out: return ret; } +static bool +do_set_mtu_service(const struct tuntap *tt, const short family, const int mtu) +{ + DWORD len; + bool ret = false; + ack_message_t ack; + struct gc_arena gc = gc_new(); + HANDLE pipe = tt->options.msg_channel; + + set_mtu_message_t mtu_msg = { + .header = { + msg_set_mtu, + sizeof(set_mtu_message_t), + 0 + }, + .iface = {.index = tt->adapter_index,.name = tt->actual_name }, + .mtu = mtu, + .family = family + }; + + if (!send_msg_iservice(pipe, &mtu_msg, sizeof(mtu_msg), &ack, "Set_mtu")) + { + goto out; + } + + if (family == AF_INET) + { + if (ack.error_number != NO_ERROR) + { + msg(M_NONFATAL, "TUN: setting IPv4 mtu using service failed: %s [status=%u if_index=%d]", + strerror_win32(ack.error_number, &gc), ack.error_number, mtu_msg.iface.index); + } + else + { + msg(M_INFO, "IPv4 MTU set to %d on interface %d using service", mtu, mtu_msg.iface.index); + ret = true; + } + } + else if (family == AF_INET6) + { + if (ack.error_number != NO_ERROR) + { + msg(M_NONFATAL, "TUN: setting IPv6 mtu using service failed: %s [status=%u if_index=%d]", + strerror_win32(ack.error_number, &gc), ack.error_number, mtu_msg.iface.index); + } + else + { + msg(M_INFO, "IPv6 MTU set to %d on interface %d using service", mtu, mtu_msg.iface.index); + ret = true; + } + } + +out: + gc_free(&gc); + return ret; +} + #endif /* ifdef _WIN32 */ #ifdef TARGET_SOLARIS @@ -990,6 +1047,7 @@ do_ifconfig_ipv6(struct tuntap *tt, const char *ifname, int tun_mtu, { do_address_service(true, AF_INET6, tt); do_dns6_service(true, tt); + do_set_mtu_service(tt, AF_INET6, tun_mtu); } else { @@ -1400,7 +1458,14 @@ do_ifconfig_ipv4(struct tuntap *tt, const char *ifname, int tun_mtu, tt->adapter_netmask, NI_IP_NETMASK|NI_OPTIONS); break; } - netsh_set_mtu_ipv4(ifname, tun_mtu); + if (tt->options.msg_channel) + { + do_set_mtu_service(tt, AF_INET, tun_mtu); + } + else + { + netsh_set_mtu_ipv4(ifname, tun_mtu); + } } #else /* if defined(TARGET_LINUX) */ diff --git a/src/openvpnserv/interactive.c b/src/openvpnserv/interactive.c index 623c3ff7..31e4afa0 100644 --- a/src/openvpnserv/interactive.c +++ b/src/openvpnserv/interactive.c @@ -1198,6 +1198,49 @@ HandleEnableDHCPMessage(const enable_dhcp_message_t *dhcp) return err; } +static DWORD +HandleMTUMessage(const set_mtu_message_t *mtu) +{ + DWORD err = 0; + DWORD timeout = 5000; /* in milli seconds */ + wchar_t argv0[MAX_PATH]; + + /* Path of netsh */ + swprintf(argv0, _countof(argv0), L"%s\\%s", get_win_sys_path(), L"netsh.exe"); + argv0[_countof(argv0) - 1] = L'\0'; + + /* cmd template: + * netsh interface $family set subinterface "$if_name" mtu=$mtu + */ + const wchar_t *fmt; + if (mtu->family == AF_INET) + { + fmt = L"netsh interface ipv4 set subinterface \"%d\" mtu= %d"; + } + else if (mtu->family == AF_INET6) + { + fmt = L"netsh interface ipv6 set subinterface \"%d\" mtu= %d"; + } + + /* max cmdline length in wchars -- include room for if index: + * 20 chars for two 32 bit int in decimal and +1 for NUL + */ + size_t ncmdline = wcslen(fmt) + 20 + 1; + wchar_t *cmdline = malloc(ncmdline * sizeof(wchar_t)); + if (!cmdline) + { + err = ERROR_OUTOFMEMORY; + return err; + } + + openvpn_sntprintf(cmdline, ncmdline, fmt, mtu->iface.index, mtu->mtu); + + err = ExecCommand(argv0, cmdline, timeout); + + free(cmdline); + return err; +} + static VOID HandleMessage(HANDLE pipe, DWORD bytes, DWORD count, LPHANDLE events, undo_lists_t *lists) { @@ -1210,6 +1253,7 @@ HandleMessage(HANDLE pipe, DWORD bytes, DWORD count, LPHANDLE events, undo_lists block_dns_message_t block_dns; dns_cfg_message_t dns; enable_dhcp_message_t dhcp; + set_mtu_message_t mtu; } msg; ack_message_t ack = { .header = { @@ -1276,6 +1320,12 @@ HandleMessage(HANDLE pipe, DWORD bytes, DWORD count, LPHANDLE events, undo_lists ack.error_number = HandleEnableDHCPMessage(&msg.dhcp); } break; + case msg_set_mtu: + if (msg.header.size == sizeof(msg.mtu)) + { + ack.error_number = HandleMTUMessage(&msg.mtu); + } + break; default: ack.error_number = ERROR_MESSAGE_TYPE; From patchwork Mon Apr 1 00:21:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Schenk X-Patchwork-Id: 708 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director12.mail.ord1d.rsapps.net ([172.27.255.57]) by backend30.mail.ord1d.rsapps.net with LMTP id uEBZCIz0oVywEwAAIUCqbw for ; Mon, 01 Apr 2019 07:22:52 -0400 Received: from proxy12.mail.iad3a.rsapps.net ([172.27.255.57]) by director12.mail.ord1d.rsapps.net with LMTP id yIG6BYz0oVx/UwAAIasKDg ; Mon, 01 Apr 2019 07:22:52 -0400 Received: from smtp12.gate.iad3a ([172.27.255.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy12.mail.iad3a.rsapps.net with LMTP id WLJkO4v0oVztUwAAh9K5Vw ; Mon, 01 Apr 2019 07:22:51 -0400 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp12.gate.iad3a.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dmarc=fail (p=none; dis=none) header.from=mail.uni-paderborn.de X-Suspicious-Flag: YES X-Classification-ID: 7c04d928-5470-11e9-bdd8-525400068c1c-1-1 Received: from [216.105.38.7] ([216.105.38.7:47347] helo=lists.sourceforge.net) by smtp12.gate.iad3a.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 75/EF-13628-B84F1AC5; Mon, 01 Apr 2019 07:22:51 -0400 Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1hAv0x-0008CD-Ks; Mon, 01 Apr 2019 11:22:07 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1hAv0u-0008Bt-Ch for openvpn-devel@lists.sourceforge.net; Mon, 01 Apr 2019 11:22:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=0hcRVa+Oxwo+RM2uk/LNESv7p/9UzYhzlmnB1bnN8X0=; b=lQuUYirY2KrjjW7Qrutt4Br5Ba 7l8lPHQN0BrZvTBA0aFW4Smw4ysh9luJuGFcTKapf+GJN2KJ+YrNmUoNcgFJjI33UznXrSiSBN0Wl l7Buvw4BTtN6/NHZ02W9IhYXLwbnQyknr4IzFo4+JlEe5AZpFsSDmyLpd5UpZB/MIJOw=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=0hcRVa+Oxwo+RM2uk/LNESv7p/9UzYhzlmnB1bnN8X0=; b=JY7qVM10/7RRCuLxDT4YPyuDvu hAqCh8yJdm05ekpDeg8xs1tKmqiTSzJ+Y3BLvgNm7BX5W68ExO06vhNcMNMf/Nmw5umJ+VedtMHS7 DuAMyZZHSaktKz0BCc1twFss2Fbe5JeoD39FRmKgs5aHcsN5YhO7PZX5+Sp0mIWoj2v0=; Received: from mail.uni-paderborn.de ([131.234.142.9]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) id 1hAv0s-006eaw-FE for openvpn-devel@lists.sourceforge.net; Mon, 01 Apr 2019 11:22:04 +0000 Received: from wormulon.uni-paderborn.de ([131.234.189.22] helo=localhost.localdomain) by mail.uni-paderborn.de with esmtp (Exim 4.89 spheron) id 1hAv0l-0001wh-GC for openvpn-devel@lists.sourceforge.net; Mon, 01 Apr 2019 13:21:55 +0200 Received: from mail.uni-paderborn.de by wormulon with queue id 3245486-5 for openvpn-devel@lists.sourceforge.net; Mon, 01 Apr 2019 11:21:53 GMT From: Christopher Schenk To: openvpn-devel@lists.sourceforge.net Date: Mon, 1 Apr 2019 13:21:39 +0200 Message-Id: <20190401112140.13212-3-cschenk@mail.uni-paderborn.de> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20190401112140.13212-1-cschenk@mail.uni-paderborn.de> References: <20190329193805.GQ31008@greenie.muc.de> <20190401112140.13212-1-cschenk@mail.uni-paderborn.de> MIME-Version: 1.0 X-PMX-Version: 6.4.6.2792898, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2019.4.1.111516, AntiVirus-Engine: 5.58.0, AntiVirus-Data: 2019.2.22.5580002 X-IMT-Spam-Score: 0.0 () X-IMT-Authenticated-Sender: X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1hAv0s-006eaw-FE Subject: [Openvpn-devel] [PATCH 3/4] Use netioapi instead of netsh to set mtu X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox --- src/openvpn/tun.c | 68 +++++++++++++++++++---------------- src/openvpnserv/interactive.c | 44 +++++------------------ 2 files changed, 46 insertions(+), 66 deletions(-) diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index b0230a7c..9fe8444f 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -69,10 +69,8 @@ static void netsh_ifconfig(const struct tuntap_options *to, const in_addr_t netmask, const unsigned int flags); -static void netsh_set_mtu_ipv4(const char *flex_name, - const int mtu); - -static void netsh_set_mtu_ipv6(const char *flex_name, +static void windows_set_mtu(const int iface_indey, + short family, const int mtu); static void netsh_set_dns6_servers(const struct in6_addr *addr_list, @@ -1064,7 +1062,7 @@ do_ifconfig_ipv6(struct tuntap *tt, const char *ifname, int tun_mtu, netsh_command(&argv, 4, M_FATAL); /* set ipv6 dns servers if any are specified */ netsh_set_dns6_servers(tt->options.dns6, tt->options.dns6_len, ifname); - netsh_set_mtu_ipv6(ifname, tun_mtu); + windows_set_mtu(tt->adapter_index, AF_INET6, tun_mtu); } /* explicit route needed */ @@ -1464,7 +1462,7 @@ do_ifconfig_ipv4(struct tuntap *tt, const char *ifname, int tun_mtu, } else { - netsh_set_mtu_ipv4(ifname, tun_mtu); + windows_set_mtu(tt->adapter_index, AF_INET, tun_mtu); } } @@ -5309,35 +5307,45 @@ out: } static void -netsh_set_mtu_ipv4(const char *flex_name, - const int mtu) -{ - struct argv argv = argv_new(); - argv_printf(&argv, "%s%sc interface ipv4 set subinterface %s mtu = %d store=active", - get_win_sys_path(), - NETSH_PATH_SUFFIX, - flex_name, - mtu); - - netsh_command(&argv, 3, M_WARN); - argv_reset(&argv); -} - -static void -netsh_set_mtu_ipv6(const char *flex_name, +windows_set_mtu(const int iface_index, const short family, const int mtu) { - struct argv argv = argv_new(); - argv_printf(&argv, "%s%sc interface ipv6 set subinterface %s mtu = %d store=active", - get_win_sys_path(), - NETSH_PATH_SUFFIX, - flex_name, - mtu); + DWORD err = 0; + struct gc_arena gc = gc_new(); + MIB_IPINTERFACE_ROW row; + InitializeIpInterfaceEntry(&row); + row.Family = family; + row.InterfaceIndex = iface_index; + row.NlMtu = mtu; - netsh_command(&argv, 3, M_WARN); - argv_reset(&argv); + err = SetIpInterfaceEntry(&row); + if (family == AF_INET) + { + if (err != NO_ERROR) + { + msg(M_WARN, "TUN: Setting IPv4 mtu failed: %s [status=%u if_index=%d]", + strerror_win32(err, &gc), err, iface_index); + } + else + { + msg(M_INFO, "Successfully set IPv4 mtu on interface %d", iface_index); + } + } + else if (family == AF_INET6) + { + if (err != NO_ERROR) + { + msg(M_WARN, "TUN: Setting IPv6 mtu failed: %s [status=%u if_index=%d]", + strerror_win32(err, &gc), err, iface_index); + } + else + { + msg(M_INFO, "Successfully set IPv6 mtu on interface %d", iface_index); + } + } } + /* * Return a TAP name for netsh commands. */ diff --git a/src/openvpnserv/interactive.c b/src/openvpnserv/interactive.c index 31e4afa0..6e6a63fe 100644 --- a/src/openvpnserv/interactive.c +++ b/src/openvpnserv/interactive.c @@ -33,6 +33,7 @@ #include #include #include +#include #ifdef HAVE_VERSIONHELPERS_H #include @@ -1202,42 +1203,13 @@ static DWORD HandleMTUMessage(const set_mtu_message_t *mtu) { DWORD err = 0; - DWORD timeout = 5000; /* in milli seconds */ - wchar_t argv0[MAX_PATH]; - - /* Path of netsh */ - swprintf(argv0, _countof(argv0), L"%s\\%s", get_win_sys_path(), L"netsh.exe"); - argv0[_countof(argv0) - 1] = L'\0'; - - /* cmd template: - * netsh interface $family set subinterface "$if_name" mtu=$mtu - */ - const wchar_t *fmt; - if (mtu->family == AF_INET) - { - fmt = L"netsh interface ipv4 set subinterface \"%d\" mtu= %d"; - } - else if (mtu->family == AF_INET6) - { - fmt = L"netsh interface ipv6 set subinterface \"%d\" mtu= %d"; - } - - /* max cmdline length in wchars -- include room for if index: - * 20 chars for two 32 bit int in decimal and +1 for NUL - */ - size_t ncmdline = wcslen(fmt) + 20 + 1; - wchar_t *cmdline = malloc(ncmdline * sizeof(wchar_t)); - if (!cmdline) - { - err = ERROR_OUTOFMEMORY; - return err; - } - - openvpn_sntprintf(cmdline, ncmdline, fmt, mtu->iface.index, mtu->mtu); - - err = ExecCommand(argv0, cmdline, timeout); - - free(cmdline); + MIB_IPINTERFACE_ROW row; + InitializeIpInterfaceEntry(&row); + row.Family = mtu->family; + row.InterfaceIndex = mtu->iface.index; + row.NlMtu = mtu->mtu; + + err = SetIpInterfaceEntry(&row); return err; } From patchwork Mon Apr 1 00:21:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Schenk X-Patchwork-Id: 710 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director10.mail.ord1d.rsapps.net ([172.27.255.7]) by backend30.mail.ord1d.rsapps.net with LMTP id aLgEA570oVxeDgAAIUCqbw for ; Mon, 01 Apr 2019 07:23:10 -0400 Received: from proxy1.mail.iad3a.rsapps.net ([172.27.255.7]) by director10.mail.ord1d.rsapps.net with LMTP id oHiqAJ70oVzsUwAApN4f7A ; Mon, 01 Apr 2019 07:23:10 -0400 Received: from smtp30.gate.iad3a ([172.27.255.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy1.mail.iad3a.rsapps.net with LMTP id 2DRONp30oVxsXAAA8TVjwQ ; Mon, 01 Apr 2019 07:23:09 -0400 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp30.gate.iad3a.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dmarc=fail (p=none; dis=none) header.from=mail.uni-paderborn.de X-Suspicious-Flag: YES X-Classification-ID: 86e6a880-5470-11e9-8971-525400089674-1-1 Received: from [216.105.38.7] ([216.105.38.7:39504] helo=lists.sourceforge.net) by smtp30.gate.iad3a.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id C9/76-09420-D94F1AC5; Mon, 01 Apr 2019 07:23:09 -0400 Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1hAv0w-0002MG-1A; Mon, 01 Apr 2019 11:22:06 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1hAv0u-0002M6-II for openvpn-devel@lists.sourceforge.net; Mon, 01 Apr 2019 11:22:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=shQVOUOe2lWWt5bRuVkkTuNxK7dXnqjzodrMuZ2s6ak=; b=PA0syLQ7H33Zqhtv+JnxwIKAGg eoCpGfowF03+g4dA2eAksAoyaLoXbLd1QnOTUBWwKaLS+9PLxPkXM9PElhcorEMvIbVBoeZ9H2RWt mTiKXGdHrbWCAU5MsZO1TcenkY3qPvrPu4JUi12Q3PGLSNPHtYPN+cv/+hHxFtO2Kud0=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=shQVOUOe2lWWt5bRuVkkTuNxK7dXnqjzodrMuZ2s6ak=; b=aU8ashNGCAixkCNoPF37JVVfG6 ab5u6b1nGE3eDALVoISmtCN699smyGsf0prCT/Qjc7Rohs9d8xtQvSn+5gXPGXJZ16SyV/pCsygIh vnZCjz5QPrpusg6UEtQE1K2MfqQkfWnILaF8mzV4vd6hxwZcMDfkxAkqjLWbTu/Bplyo=; Received: from mail.uni-paderborn.de ([131.234.142.9]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) id 1hAv0t-006eb0-1I for openvpn-devel@lists.sourceforge.net; Mon, 01 Apr 2019 11:22:04 +0000 Received: from tweenies.uni-paderborn.de ([131.234.189.21] helo=localhost.localdomain) by mail.uni-paderborn.de with esmtp (Exim 4.89 hoth) id 1hAv0m-0000Gp-Qb for openvpn-devel@lists.sourceforge.net; Mon, 01 Apr 2019 13:21:56 +0200 Received: from mail.uni-paderborn.de by tweenies with queue id 3212994-4 for openvpn-devel@lists.sourceforge.net; Mon, 01 Apr 2019 11:21:55 GMT From: Christopher Schenk To: openvpn-devel@lists.sourceforge.net Date: Mon, 1 Apr 2019 13:21:40 +0200 Message-Id: <20190401112140.13212-4-cschenk@mail.uni-paderborn.de> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20190401112140.13212-1-cschenk@mail.uni-paderborn.de> References: <20190329193805.GQ31008@greenie.muc.de> <20190401112140.13212-1-cschenk@mail.uni-paderborn.de> MIME-Version: 1.0 X-PMX-Version: 6.4.6.2792898, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2019.4.1.111216, AntiVirus-Engine: 5.58.0, AntiVirus-Data: 2019.2.22.5580002 X-IMT-Spam-Score: 0.0 () X-IMT-Authenticated-Sender: X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1hAv0t-006eb0-1I Subject: [Openvpn-devel] [PATCH 4/4] Simplified if statements for better readability X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox --- src/openvpn/tun.c | 58 ++++++++++++----------------------------------- 1 file changed, 14 insertions(+), 44 deletions(-) diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index 9fe8444f..20e661a7 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -69,7 +69,7 @@ static void netsh_ifconfig(const struct tuntap_options *to, const in_addr_t netmask, const unsigned int flags); -static void windows_set_mtu(const int iface_indey, +static void windows_set_mtu(const int iface_index, short family, const int mtu); @@ -213,7 +213,7 @@ do_set_mtu_service(const struct tuntap *tt, const short family, const int mtu) ack_message_t ack; struct gc_arena gc = gc_new(); HANDLE pipe = tt->options.msg_channel; - + char *family_name = (family == AF_INET6) ? "IPv6" : "IPv4"; set_mtu_message_t mtu_msg = { .header = { msg_set_mtu, @@ -230,31 +230,15 @@ do_set_mtu_service(const struct tuntap *tt, const short family, const int mtu) goto out; } - if (family == AF_INET) + if (ack.error_number != NO_ERROR) { - if (ack.error_number != NO_ERROR) - { - msg(M_NONFATAL, "TUN: setting IPv4 mtu using service failed: %s [status=%u if_index=%d]", - strerror_win32(ack.error_number, &gc), ack.error_number, mtu_msg.iface.index); - } - else - { - msg(M_INFO, "IPv4 MTU set to %d on interface %d using service", mtu, mtu_msg.iface.index); - ret = true; - } + msg(M_NONFATAL, "TUN: setting %s mtu using service failed: %s [status=%u if_index=%d]", + family_name, strerror_win32(ack.error_number, &gc), ack.error_number, mtu_msg.iface.index); } - else if (family == AF_INET6) + else { - if (ack.error_number != NO_ERROR) - { - msg(M_NONFATAL, "TUN: setting IPv6 mtu using service failed: %s [status=%u if_index=%d]", - strerror_win32(ack.error_number, &gc), ack.error_number, mtu_msg.iface.index); - } - else - { - msg(M_INFO, "IPv6 MTU set to %d on interface %d using service", mtu, mtu_msg.iface.index); - ret = true; - } + msg(M_INFO, "%s MTU set to %d on interface %d using service", family_name, mtu, mtu_msg.iface.index); + ret = true; } out: @@ -5313,35 +5297,21 @@ windows_set_mtu(const int iface_index, const short family, DWORD err = 0; struct gc_arena gc = gc_new(); MIB_IPINTERFACE_ROW row; + char *family_name = (family == AF_INET6) ? "IPv6" : "IPv4"; InitializeIpInterfaceEntry(&row); row.Family = family; row.InterfaceIndex = iface_index; row.NlMtu = mtu; err = SetIpInterfaceEntry(&row); - if (family == AF_INET) + if (err != NO_ERROR) { - if (err != NO_ERROR) - { - msg(M_WARN, "TUN: Setting IPv4 mtu failed: %s [status=%u if_index=%d]", - strerror_win32(err, &gc), err, iface_index); - } - else - { - msg(M_INFO, "Successfully set IPv4 mtu on interface %d", iface_index); - } + msg(M_WARN, "TUN: Setting %s mtu failed: %s [status=%u if_index=%d]", + family_name, strerror_win32(err, &gc), err, iface_index); } - else if (family == AF_INET6) + else { - if (err != NO_ERROR) - { - msg(M_WARN, "TUN: Setting IPv6 mtu failed: %s [status=%u if_index=%d]", - strerror_win32(err, &gc), err, iface_index); - } - else - { - msg(M_INFO, "Successfully set IPv6 mtu on interface %d", iface_index); - } + msg(M_INFO, "Successfully set %s mtu on interface %d", family_name, iface_index); } }