From patchwork Wed Sep 23 20:44:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kristof Provost via Openvpn-devel X-Patchwork-Id: 1473 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director9.mail.ord1d.rsapps.net ([172.27.255.7]) by backend30.mail.ord1d.rsapps.net with LMTP id GIUgJNJAbF8HMgAAIUCqbw (envelope-from ) for ; Thu, 24 Sep 2020 02:46:42 -0400 Received: from proxy1.mail.iad3a.rsapps.net ([172.27.255.7]) by director9.mail.ord1d.rsapps.net with LMTP id gBAAJNJAbF8TdAAAalYnBA (envelope-from ) for ; Thu, 24 Sep 2020 02:46:42 -0400 Received: from smtp31.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 LMTPS id CEXmHNJAbF+iaAAA8TVjwQ (envelope-from ) for ; Thu, 24 Sep 2020 02:46:42 -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: smtp31.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=pass header.d=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=rozman.si; dmarc=pass (p=none; dis=none) header.from=lists.sourceforge.net X-Suspicious-Flag: NO X-Classification-ID: b3ab2dfc-fe31-11ea-af3c-5254003d9392-1-1 Received: from [216.105.38.7] ([216.105.38.7:36806] helo=lists.sourceforge.net) by smtp31.gate.iad3a.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 97/49-32532-1D04C6F5; Thu, 24 Sep 2020 02:46:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type: Reply-To:From:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Subject:MIME-Version:Message-Id:Date:To:Sender:Cc: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=iG+Z5FyKrvVlfDKcdbQop9oHGYmpJzRoGP+Q0j0Tb+w=; b=hElhhV76nwz0cggaXPZpi8Knb2 ByMuJiocBYqj6bEIkDOvL850SyaoKFkcxBu4ur9sPIKSNYZu7Q+xjvoTX3nw1fdmZ84bCUiW6Gs+9 q3oJU3JtDjOYmq058Ei4UBX2kGBnIiJxpktg1gZBnaxmbv5m7cUfHqk3siwmHWBu8D+o=; 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 1kLL0X-0006wW-U7; Thu, 24 Sep 2020 06:45:33 +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 1kLL0V-0006wN-KE for openvpn-devel@lists.sourceforge.net; Thu, 24 Sep 2020 06:45:31 +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: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:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=9EZNJxiL5QRTWoFrox9M7iRV6D6vlTHUP9JqxAHGvJk=; b=hO5GVmK86v+W8/yZE3x7tb48sk vcme77m0kZIO5+4lJtJ7DrQ2xPl8V0ZnAaiwaUvFb97xvHCBznHD63FzHS5YdcOtkvCUFxXDP0CXH dmyu/Edsx25k5dtImK7+g+NWfT0vyxnoSb3Ib9d8qs+Li7eFq7+eScEdNrIO9IVsCVbk=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version: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:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=9EZNJxiL5QRTWoFrox9M7iRV6D6vlTHUP9JqxAHGvJk=; b=U PqDPFOv+ig23nuim14d960FWFNdZkCYBxl6TQo4VEp+nfnRKs5J6jX0nV2TqcDt2Gs4qmVKkZOGiw pH75HYuT7TD268oP6gkFIXkVOerRGYvLTCnXWLQpaG5UA7RZhbV1hhwjkks1DJrCL14JvYXi4APrg F9DBJTpNqi8odYgo=; Received: from pub5.amebis.si ([213.250.55.21]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1kLL0J-005gPS-Al for openvpn-devel@lists.sourceforge.net; Thu, 24 Sep 2020 06:45:31 +0000 Received: by pub5.amebis.si (Postfix, from userid 1000) id B59841002B58; Thu, 24 Sep 2020 08:45:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rozman.si; s=default; t=1600929901; bh=9EZNJxiL5QRTWoFrox9M7iRV6D6vlTHUP9JqxAHGvJk=; h=From:To:Cc:Subject:Date:From; b=OUGulfu+VBEK7oDGDGd09yjFk1i9NZSmcJYX6Wqsshz8Va/Ujd+YezX9yV+7vtlnf qukE7qd+2LH3+f0Kvtpp2sjXgPLzKnsHsAuoc1ZmX82giq3nNCM8EYZgcUI/2zAm53 4JxaqdiTctpH93bEAaeob2Pu/f/HOt3pXYNMIGf8= X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on brana.amebis.doma X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Received: from SR6.amebis.doma (unknown [IPv6:2a00:ee2:209:164:8103:4a53:d5f0:1d48]) by pub5.amebis.si (Postfix) with ESMTP id 2F3CF1002F9B; Thu, 24 Sep 2020 08:44:59 +0200 (CEST) To: openvpn-devel@lists.sourceforge.net Date: Thu, 24 Sep 2020 08:44:50 +0200 Message-Id: <20200924064452.1001-1-simon@rozman.si> X-Mailer: git-send-email 2.28.0.windows.1 MIME-Version: 1.0 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: rozman.si] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an 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: 1kLL0J-005gPS-Al Subject: [Openvpn-devel] [PATCH 1/3] netsh: Specify interfaces by index rather than name 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: , X-Patchwork-Original-From: Simon Rozman via Openvpn-devel From: Kristof Provost via Openvpn-devel Reply-To: Simon Rozman Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox This is more efficient and less error prone. Signed-off-by: Simon Rozman Acked-by: Lev Stipakov --- src/openvpn/route.c | 26 +++++++------- src/openvpn/tun.c | 88 +++++++++++++++++++++------------------------ 2 files changed, 53 insertions(+), 61 deletions(-) diff --git a/src/openvpn/route.c b/src/openvpn/route.c index bd6b968b..d75aa5f4 100644 --- a/src/openvpn/route.c +++ b/src/openvpn/route.c @@ -1987,25 +1987,24 @@ add_route_ipv6(struct route_ipv6 *r6, const struct tuntap *tt, } else { - struct buffer out = alloc_buf_gc(64, &gc); + DWORD adapter_index; if (r6->adapter_index) /* vpn server special route */ { - buf_printf(&out, "interface=%lu", r6->adapter_index ); + adapter_index = r6->adapter_index; gateway_needed = true; } else { - buf_printf(&out, "interface=%lu", tt->adapter_index ); + adapter_index = tt->adapter_index; } - device = buf_bptr(&out); - /* netsh interface ipv6 add route 2001:db8::/32 MyTunDevice */ - argv_printf(&argv, "%s%s interface ipv6 add route %s/%d %s", + /* netsh interface ipv6 add route 2001:db8::/32 42 */ + argv_printf(&argv, "%s%s interface ipv6 add route %s/%d %lu", get_win_sys_path(), NETSH_PATH_SUFFIX, network, r6->netbits, - device); + adapter_index); /* next-hop depends on TUN or TAP mode: * - in TAP mode, we use the "real" next-hop @@ -2431,25 +2430,24 @@ delete_route_ipv6(const struct route_ipv6 *r6, const struct tuntap *tt, } else { - struct buffer out = alloc_buf_gc(64, &gc); + DWORD adapter_index; if (r6->adapter_index) /* vpn server special route */ { - buf_printf(&out, "interface=%lu", r6->adapter_index ); + adapter_index = r6->adapter_index; gateway_needed = true; } else { - buf_printf(&out, "interface=%lu", tt->adapter_index ); + adapter_index = tt->adapter_index; } - device = buf_bptr(&out); - /* netsh interface ipv6 delete route 2001:db8::/32 MyTunDevice */ - argv_printf(&argv, "%s%s interface ipv6 delete route %s/%d %s", + /* netsh interface ipv6 delete route 2001:db8::/32 42 */ + argv_printf(&argv, "%s%s interface ipv6 delete route %s/%d %lu", get_win_sys_path(), NETSH_PATH_SUFFIX, network, r6->netbits, - device); + adapter_index); /* next-hop depends on TUN or TAP mode: * - in TAP mode, we use the "real" next-hop diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index faa02504..8fd3229f 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -68,7 +68,7 @@ const static GUID GUID_DEVINTERFACE_NET = { 0xcac88484, 0x7515, 0x4c03, { 0x82, #define NI_OPTIONS (1<<2) static void netsh_ifconfig(const struct tuntap_options *to, - const char *flex_name, + DWORD adapter_index, const in_addr_t ip, const in_addr_t netmask, const unsigned int flags); @@ -79,7 +79,7 @@ static void windows_set_mtu(const int iface_index, static void netsh_set_dns6_servers(const struct in6_addr *addr_list, const int addr_len, - const char *flex_name); + DWORD adapter_index); static void netsh_command(const struct argv *a, int n, int msglevel); @@ -1103,10 +1103,9 @@ do_ifconfig_ipv6(struct tuntap *tt, const char *ifname, int tun_mtu, } else { - /* example: netsh interface ipv6 set address interface=42 + /* example: netsh interface ipv6 set address 42 * 2001:608:8003::d/bits store=active */ - char iface[64]; /* in TUN mode, we only simulate a subnet, so the interface * is configured with /128 + a route to fe80::8. In TAP mode, @@ -1114,10 +1113,8 @@ do_ifconfig_ipv6(struct tuntap *tt, const char *ifname, int tun_mtu, */ int netbits = (tt->type == DEV_TYPE_TUN) ? 128 : tt->netbits_ipv6; - openvpn_snprintf(iface, sizeof(iface), "interface=%lu", - tt->adapter_index); - argv_printf(&argv, "%s%s interface ipv6 set address %s %s/%d store=active", - get_win_sys_path(), NETSH_PATH_SUFFIX, iface, + argv_printf(&argv, "%s%s interface ipv6 set address %lu %s/%d store=active", + get_win_sys_path(), NETSH_PATH_SUFFIX, tt->adapter_index, ifconfig_ipv6_local, netbits); netsh_command(&argv, 4, M_FATAL); if (tt->type == DEV_TYPE_TUN) @@ -1125,7 +1122,7 @@ do_ifconfig_ipv6(struct tuntap *tt, const char *ifname, int tun_mtu, add_route_connected_v6_net(tt, es); } /* set ipv6 dns servers if any are specified */ - netsh_set_dns6_servers(tt->options.dns6, tt->options.dns6_len, ifname); + netsh_set_dns6_servers(tt->options.dns6, tt->options.dns6_len, tt->adapter_index); windows_set_mtu(tt->adapter_index, AF_INET6, tun_mtu); } #else /* platforms we have no IPv6 code for */ @@ -1473,8 +1470,6 @@ do_ifconfig_ipv4(struct tuntap *tt, const char *ifname, int tun_mtu, env_set_destroy(aix_es); } #elif defined (_WIN32) - ASSERT(ifname != NULL); - if (tt->options.ip_win32_type == IPW32_SET_MANUAL) { msg(M_INFO, @@ -1493,7 +1488,7 @@ do_ifconfig_ipv4(struct tuntap *tt, const char *ifname, int tun_mtu, } else if (tt->options.ip_win32_type == IPW32_SET_NETSH) { - netsh_ifconfig(&tt->options, ifname, tt->local, + netsh_ifconfig(&tt->options, tt->adapter_index, tt->local, tt->adapter_netmask, NI_IP_NETMASK|NI_OPTIONS); } if (tt->options.msg_channel) @@ -5291,7 +5286,7 @@ ip_addr_member_of(const in_addr_t addr, const IP_ADDR_STRING *ias) static void netsh_set_dns6_servers(const struct in6_addr *addr_list, const int addr_len, - const char *flex_name) + DWORD adapter_index) { struct gc_arena gc = gc_new(); struct argv argv = argv_new(); @@ -5299,10 +5294,10 @@ netsh_set_dns6_servers(const struct in6_addr *addr_list, for (int i = 0; i < addr_len; ++i) { const char *fmt = (i == 0) ? - "%s%s interface ipv6 set dns %s static %s" - : "%s%s interface ipv6 add dns %s %s"; + "%s%s interface ipv6 set dns %lu static %s" + : "%s%s interface ipv6 add dns %lu %s"; argv_printf(&argv, fmt, get_win_sys_path(), - NETSH_PATH_SUFFIX, flex_name, + NETSH_PATH_SUFFIX, adapter_index, print_in6_addr(addr_list[i], 0, &gc)); /* disable slow address validation on Windows 7 and higher */ @@ -5324,7 +5319,7 @@ netsh_ifconfig_options(const char *type, const in_addr_t *addr_list, const int addr_len, const IP_ADDR_STRING *current, - const char *flex_name, + DWORD adapter_index, const bool test_first) { struct gc_arena gc = gc_new(); @@ -5348,11 +5343,11 @@ netsh_ifconfig_options(const char *type, /* delete existing DNS/WINS settings from TAP interface */ if (delete_first) { - argv_printf(&argv, "%s%s interface ip delete %s %s all", + argv_printf(&argv, "%s%s interface ip delete %s %lu all", get_win_sys_path(), NETSH_PATH_SUFFIX, type, - flex_name); + adapter_index); netsh_command(&argv, 2, M_FATAL); } @@ -5365,14 +5360,14 @@ netsh_ifconfig_options(const char *type, if (delete_first || !test_first || !ip_addr_member_of(addr_list[i], current)) { const char *fmt = count ? - "%s%s interface ip add %s %s %s" - : "%s%s interface ip set %s %s static %s"; + "%s%s interface ip add %s %lu %s" + : "%s%s interface ip set %s %lu static %s"; argv_printf(&argv, fmt, get_win_sys_path(), NETSH_PATH_SUFFIX, type, - flex_name, + adapter_index, print_in_addr_t(addr_list[i], 0, &gc)); /* disable slow address validation on Windows 7 and higher */ @@ -5388,8 +5383,8 @@ netsh_ifconfig_options(const char *type, } else { - msg(M_INFO, "NETSH: \"%s\" %s %s [already set]", - flex_name, + msg(M_INFO, "NETSH: %lu %s %s [already set]", + adapter_index, type, print_in_addr_t(addr_list[i], 0, &gc)); } @@ -5420,7 +5415,7 @@ init_ip_addr_string2(IP_ADDR_STRING *dest, const IP_ADDR_STRING *src1, const IP_ static void netsh_ifconfig(const struct tuntap_options *to, - const char *flex_name, + DWORD adapter_index, const in_addr_t ip, const in_addr_t netmask, const unsigned int flags) @@ -5433,27 +5428,26 @@ netsh_ifconfig(const struct tuntap_options *to, if (flags & NI_TEST_FIRST) { const IP_ADAPTER_INFO *list = get_adapter_info_list(&gc); - const int index = get_adapter_index_flexible(flex_name); - ai = get_adapter(list, index); - pai = get_per_adapter_info(index, &gc); + ai = get_adapter(list, adapter_index); + pai = get_per_adapter_info(adapter_index, &gc); } if (flags & NI_IP_NETMASK) { if (test_adapter_ip_netmask(ai, ip, netmask)) { - msg(M_INFO, "NETSH: \"%s\" %s/%s [already set]", - flex_name, + msg(M_INFO, "NETSH: %lu %s/%s [already set]", + adapter_index, print_in_addr_t(ip, 0, &gc), print_in_addr_t(netmask, 0, &gc)); } else { - /* example: netsh interface ip set address my-tap static 10.3.0.1 255.255.255.0 */ - argv_printf(&argv, "%s%s interface ip set address %s static %s %s", + /* example: netsh interface ip set address 42 static 10.3.0.1 255.255.255.0 */ + argv_printf(&argv, "%s%s interface ip set address %lu static %s %s", get_win_sys_path(), NETSH_PATH_SUFFIX, - flex_name, + adapter_index, print_in_addr_t(ip, 0, &gc), print_in_addr_t(netmask, 0, &gc)); @@ -5472,7 +5466,7 @@ netsh_ifconfig(const struct tuntap_options *to, to->dns, to->dns_len, pai ? &pai->DnsServerList : NULL, - flex_name, + adapter_index, BOOL_CAST(flags & NI_TEST_FIRST)); if (ai && ai->HaveWins) { @@ -5483,7 +5477,7 @@ netsh_ifconfig(const struct tuntap_options *to, to->wins, to->wins_len, ai ? wins : NULL, - flex_name, + adapter_index, BOOL_CAST(flags & NI_TEST_FIRST)); } @@ -5492,16 +5486,16 @@ netsh_ifconfig(const struct tuntap_options *to, } static void -netsh_enable_dhcp(const char *actual_name) +netsh_enable_dhcp(DWORD adapter_index) { struct argv argv = argv_new(); - /* example: netsh interface ip set address my-tap dhcp */ + /* example: netsh interface ip set address 42 dhcp */ argv_printf(&argv, - "%s%s interface ip set address %s dhcp", + "%s%s interface ip set address %lu dhcp", get_win_sys_path(), NETSH_PATH_SUFFIX, - actual_name); + adapter_index); netsh_command(&argv, 4, M_FATAL); @@ -5647,7 +5641,7 @@ tun_standby(struct tuntap *tt) { msg(M_INFO, "NOTE: now trying netsh (this may take some time)"); netsh_ifconfig(&tt->options, - tt->actual_name, + tt->adapter_index, tt->local, tt->adapter_netmask, NI_TEST_FIRST|NI_IP_NETMASK|NI_OPTIONS); @@ -6552,7 +6546,7 @@ tuntap_set_ip_props(const struct tuntap *tt, bool *dhcp_masq, bool *dhcp_masq_po } else { - netsh_enable_dhcp(tt->actual_name); + netsh_enable_dhcp(tt->adapter_index); } } *dhcp_masq = true; @@ -6566,7 +6560,7 @@ tuntap_set_ip_props(const struct tuntap *tt, bool *dhcp_masq, bool *dhcp_masq_po if (dhcp_status(tt->adapter_index) != DHCP_STATUS_ENABLED) { netsh_ifconfig(&tt->options, - tt->actual_name, + tt->adapter_index, tt->local, tt->adapter_netmask, NI_TEST_FIRST | NI_IP_NETMASK | NI_OPTIONS); @@ -6698,11 +6692,11 @@ netsh_delete_address_dns(const struct tuntap *tt, bool ipv6, struct gc_arena *gc if (len > 0) { argv_printf(&argv, - "%s%s interface %s delete dns %s all", + "%s%s interface %s delete dns %lu all", get_win_sys_path(), NETSH_PATH_SUFFIX, ipv6 ? "ipv6" : "ipv4", - tt->actual_name); + tt->adapter_index); netsh_command(&argv, 1, M_WARN); } @@ -6715,7 +6709,7 @@ netsh_delete_address_dns(const struct tuntap *tt, bool ipv6, struct gc_arena *gc * address we added (pointed out by Cedric Tabary). */ - /* netsh interface ipvX delete address \"%s\" %s */ + /* netsh interface ipvX delete address %lu %s */ if (ipv6) { ifconfig_ip_local = print_in6_addr(tt->local_ipv6, 0, gc); @@ -6725,11 +6719,11 @@ netsh_delete_address_dns(const struct tuntap *tt, bool ipv6, struct gc_arena *gc ifconfig_ip_local = print_in_addr_t(tt->local, 0, gc); } argv_printf(&argv, - "%s%s interface %s delete address %s %s store=active", + "%s%s interface %s delete address %lu %s store=active", get_win_sys_path(), NETSH_PATH_SUFFIX, ipv6 ? "ipv6" : "ipv4", - tt->actual_name, + tt->adapter_index, ifconfig_ip_local); netsh_command(&argv, 1, M_WARN); From patchwork Wed Sep 23 20:44:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kristof Provost via Openvpn-devel X-Patchwork-Id: 1475 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director9.mail.ord1d.rsapps.net ([172.31.255.6]) by backend30.mail.ord1d.rsapps.net with LMTP id sNLeKj5DbF9rSgAAIUCqbw (envelope-from ) for ; Thu, 24 Sep 2020 02:57:02 -0400 Received: from proxy5.mail.iad3b.rsapps.net ([172.31.255.6]) by director9.mail.ord1d.rsapps.net with LMTP id YNW9Kj5DbF+9dAAAalYnBA (envelope-from ) for ; Thu, 24 Sep 2020 02:57:02 -0400 Received: from smtp36.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy5.mail.iad3b.rsapps.net with LMTPS id KCK6Iz5DbF+qYgAA13hMnw (envelope-from ) for ; Thu, 24 Sep 2020 02:57:02 -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: smtp36.gate.iad3b.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=pass header.d=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=rozman.si; dmarc=pass (p=none; dis=none) header.from=lists.sourceforge.net X-Suspicious-Flag: NO X-Classification-ID: 25a81a54-fe33-11ea-ab05-5254003a7283-1-1 Received: from [216.105.38.7] ([216.105.38.7:45678] helo=lists.sourceforge.net) by smtp36.gate.iad3b.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 9B/AD-21127-E334C6F5; Thu, 24 Sep 2020 02:57:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type: Reply-To:From:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Subject:MIME-Version:References:In-Reply-To: Message-Id:Date:To:Sender:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=QhEq00PeZi7QuI64GZufa7RZuAUpXxvrHSRSa6Oly6E=; b=iXK1l5JCK9JBBAQ0xlPC7rSAw 5T/ri6Mx/kLn/IV8agmEN5nqKcns9E452E0XVLU0th4SSTSiQWTkojKE5kd6/d1ToMdeS0BHIUeqF qbfc7Kfk3u8fFMM0nWnX2rwaycOPOp5keFjgJGeGwUO9dEiVfH61DAr4La1zxzJIPrBfg=; 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 1kLLAs-0007PF-Ka; Thu, 24 Sep 2020 06:56:14 +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 1kLLAr-0007P3-D1 for openvpn-devel@lists.sourceforge.net; Thu, 24 Sep 2020 06:56:13 +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=9y7cUumnwOx38vRA1IDnjBkaykJmRJz5oMDkc+MEFGk=; b=UUTYOsUni60AGnaNEQmFgERFQy P1GBHPmD6R8JR50wCWfe5TBAJUpxzyYepbDR5WRBheBs1Hce0PZbAEHfgzYcpCTtTlhX0UnbI82Vb O8ulFSnPo/c7e1Ueqh6eZQ0QB4A2wgRn//qQLpQooyeHdTO+BxQWnZEJk/UeyKaAmy1s=; 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=9y7cUumnwOx38vRA1IDnjBkaykJmRJz5oMDkc+MEFGk=; b=ZhGlaWsyo4iOihfqzIbf4U7dlX uncntpCr16jH6KQVuSHYxrf5yg531aJnEtl1HYTzquSlOmJtCuEyqUSWsT4kNOBecCOJ9dgJB6mQU JXNPKsNYegDJXB3pmN9gyyBGk4+Wf+kYpuw+OFJuaqiZGRCG0MF/ZFIpA/GwDVfoSdjA=; Received: from pub5.amebis.si ([213.250.55.21]) by sfi-mx-3.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1kLLAd-003ZLg-2y for openvpn-devel@lists.sourceforge.net; Thu, 24 Sep 2020 06:56:12 +0000 Received: by pub5.amebis.si (Postfix, from userid 1000) id 640A51002F9B; Thu, 24 Sep 2020 08:45:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rozman.si; s=default; t=1600929907; bh=9y7cUumnwOx38vRA1IDnjBkaykJmRJz5oMDkc+MEFGk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p6row96vBcUBZGTqlGe/FfN526BDE0yYYOWZzwWrFE54ocG63P04Va7cPgnuBaxNi Il0COwoWr05Wsj2yclnm2FF+IMCNfhICjGSD1WDzEL0pnLJXFe4y5PtOUSVdcTgQXu wEHYFnPMCLUB+7aa4Q9Z2SIazZ4z85KSkmT9/QJM= X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on brana.amebis.doma X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Received: from SR6.amebis.doma (unknown [IPv6:2a00:ee2:209:164:8103:4a53:d5f0:1d48]) by pub5.amebis.si (Postfix) with ESMTP id 223661002F9B; Thu, 24 Sep 2020 08:45:05 +0200 (CEST) To: openvpn-devel@lists.sourceforge.net Date: Thu, 24 Sep 2020 08:44:51 +0200 Message-Id: <20200924064452.1001-2-simon@rozman.si> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20200924064452.1001-1-simon@rozman.si> References: <20200924064452.1001-1-simon@rozman.si> MIME-Version: 1.0 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: rozman.si] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an 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: 1kLLAd-003ZLg-2y Subject: [Openvpn-devel] [PATCH 2/3] netsh: Clear existing IPv6 DNS servers before configuring new ones 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: , X-Patchwork-Original-From: Simon Rozman via Openvpn-devel From: Kristof Provost via Openvpn-devel Reply-To: Simon Rozman Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox When there are no IPv6 DNS published, the adapter state is not sanitized and might contain IPv6 DNS server from a previous session. netsh_ifconfig_options() clears DNS servers for IPv4 already. Signed-off-by: Simon Rozman Acked-by: Lev Stipakov Acked-by: Lev Stipakov <lstipakov@gmail.com>
--- src/openvpn/tun.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index 8fd3229f..b1cd7a1b 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -5281,7 +5281,6 @@ ip_addr_member_of(const in_addr_t addr, const IP_ADDR_STRING *ias) * Set the ipv6 dns servers on the specified interface. * The list of dns servers currently set on the interface * are cleared first. - * No action is taken if number of addresses (addr_len) < 1. */ static void netsh_set_dns6_servers(const struct in6_addr *addr_list, @@ -5291,6 +5290,13 @@ netsh_set_dns6_servers(const struct in6_addr *addr_list, struct gc_arena gc = gc_new(); struct argv argv = argv_new(); + /* delete existing DNS settings from TAP interface */ + argv_printf(&argv, "%s%s interface ipv6 delete dns %lu all", + get_win_sys_path(), + NETSH_PATH_SUFFIX, + adapter_index); + netsh_command(&argv, 2, M_FATAL); + for (int i = 0; i < addr_len; ++i) { const char *fmt = (i == 0) ? From patchwork Wed Sep 23 20:44:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kristof Provost via Openvpn-devel X-Patchwork-Id: 1472 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director11.mail.ord1d.rsapps.net ([172.27.255.52]) by backend30.mail.ord1d.rsapps.net with LMTP id MBRNI9JAbF+PAgAAIUCqbw (envelope-from ) for ; Thu, 24 Sep 2020 02:46:42 -0400 Received: from proxy2.mail.iad3a.rsapps.net ([172.27.255.52]) by director11.mail.ord1d.rsapps.net with LMTP id uPoVI9JAbF8TNAAAvGGmqA (envelope-from ) for ; Thu, 24 Sep 2020 02:46:42 -0400 Received: from smtp23.gate.iad3a ([172.27.255.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy2.mail.iad3a.rsapps.net with LMTPS id ANkTHdJAbF/6ZAAABcWvHw (envelope-from ) for ; Thu, 24 Sep 2020 02:46:42 -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: smtp23.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=pass header.d=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=rozman.si; dmarc=pass (p=none; dis=none) header.from=lists.sourceforge.net X-Suspicious-Flag: NO X-Classification-ID: b343a4de-fe31-11ea-b3d1-52540033eb40-1-1 Received: from [216.105.38.7] ([216.105.38.7:52662] helo=lists.sourceforge.net) by smtp23.gate.iad3a.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 82/F9-31091-0D04C6F5; Thu, 24 Sep 2020 02:46:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type: Reply-To:From:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Subject:MIME-Version:References:In-Reply-To: Message-Id:Date:To:Sender:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=5kfS1rPtLy43vw55FoYiNXsqU/Im9gubzInD33LbcdQ=; b=ValsT58y16cCLNZOYzNUY/u5I Kp7W04QLmtwPVl2WOHKMSKztUp9OCzORFNj44dzb/pbk/fYaAFDtw154/GsdqWNiEHNV+XkS3nbdW O8rCBUEwEgGOKxNwIMrTojEU+bE+YXYYasZSX1YBLNezBNiBdv5irgsM64NpOmlvycw2M=; 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 1kLL0a-00082Y-M1; Thu, 24 Sep 2020 06:45:36 +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 1kLL0Z-00082N-VF for openvpn-devel@lists.sourceforge.net; Thu, 24 Sep 2020 06:45:35 +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=fKABGI58ZKJFOeKm9mtKlt8j2skkgle8LeoCjBque8k=; b=FURD4DsvWbR3ShGGVpjaqmXPnw B1R/eCUT4ViLnb4oSxpIEI8ccufH04306nBLDaqAcxQYGImslYe20hw3bfLjF6OdP73N7X7LyFAoF 9CO65/jgfpSzDhXy9EJGhtqhevH9ID7+jFdhVAlPg/B3bQg59yGLvm9VApE9Ru61V7GE=; 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=fKABGI58ZKJFOeKm9mtKlt8j2skkgle8LeoCjBque8k=; b=CDQ3aGf/uHilEPLV328UpoVYeH TPYwO7RKnAke1v4+5iSMXedq87jfBEMg7fnQhF0/T3SnZecIuFu1eyrW4clHa7ac0WM6qp/tsVx/R ysryEHlmGYLOzSVBjOfyNEzkqfidqFiRcEmKSWqvj4//bphR/Ejrwt4Dz8AfamBgCZ2E=; Received: from pub5.amebis.si ([213.250.55.21]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1kLL0J-005gPU-Al for openvpn-devel@lists.sourceforge.net; Thu, 24 Sep 2020 06:45:35 +0000 Received: by pub5.amebis.si (Postfix, from userid 1000) id B449F1002FA3; Thu, 24 Sep 2020 08:45:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rozman.si; s=default; t=1600929909; bh=fKABGI58ZKJFOeKm9mtKlt8j2skkgle8LeoCjBque8k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NhwCotmP5TF3/5SXb3hvLz96gyX2KdO/glJ40ZRhVNhGJ3DNOy1aIBDMxFE+eFmmZ dqwz/6GCr3pqDVirwXp1lqU5G1uiKhTm1gC2IiiasEwxd+gHMPeP+N0VsEsgoL+y/b X0mhyRVoTpZXRFtJSBMEl6Lr3M5tvGHYKRZnC1to= X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on brana.amebis.doma X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 Received: from SR6.amebis.doma (unknown [IPv6:2a00:ee2:209:164:8103:4a53:d5f0:1d48]) by pub5.amebis.si (Postfix) with ESMTP id 7FFF4100251B; Thu, 24 Sep 2020 08:45:07 +0200 (CEST) To: openvpn-devel@lists.sourceforge.net Date: Thu, 24 Sep 2020 08:44:52 +0200 Message-Id: <20200924064452.1001-3-simon@rozman.si> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20200924064452.1001-1-simon@rozman.si> References: <20200924064452.1001-1-simon@rozman.si> MIME-Version: 1.0 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: rozman.si] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an 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 0.0 TIME_LIMIT_EXCEEDED Exceeded time limit / deadline X-Headers-End: 1kLL0J-005gPU-Al Subject: [Openvpn-devel] [PATCH 3/3] netsh: Delete WINS servers on TUN close 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: , X-Patchwork-Original-From: Simon Rozman via Openvpn-devel From: Kristof Provost via Openvpn-devel Reply-To: Simon Rozman Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox Signed-off-by: Simon Rozman Acked-by: Lev Stipakov --- src/openvpn/tun.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index b1cd7a1b..80ae6958 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -6706,6 +6706,16 @@ netsh_delete_address_dns(const struct tuntap *tt, bool ipv6, struct gc_arena *gc netsh_command(&argv, 1, M_WARN); } + if (!ipv6 && tt->options.wins_len > 0) + { + argv_printf(&argv, + "%s%s interface ipv4 delete winsservers %lu all", + get_win_sys_path(), + NETSH_PATH_SUFFIX, + tt->adapter_index); + netsh_command(&argv, 1, M_WARN); + } + if (ipv6 && tt->type == DEV_TYPE_TUN) { delete_route_connected_v6_net(tt);