From patchwork Tue Sep 17 02:44:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lev Stipakov X-Patchwork-Id: 827 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director10.mail.ord1d.rsapps.net ([172.31.255.6]) by backend30.mail.ord1d.rsapps.net with LMTP id CO2NO5vVgF16bQAAIUCqbw for ; Tue, 17 Sep 2019 08:46:20 -0400 Received: from proxy13.mail.iad3b.rsapps.net ([172.31.255.6]) by director10.mail.ord1d.rsapps.net with LMTP id SFbnOJvVgF0LKAAApN4f7A ; Tue, 17 Sep 2019 08:46:20 -0400 Received: from smtp10.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy13.mail.iad3b.rsapps.net with LMTP id 6DhRM5vVgF08DwAAvUvv+w ; Tue, 17 Sep 2019 08:46:19 -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: smtp10.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=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dkim=fail (signature verification failed) header.d=gmail.com; dmarc=fail (p=none; dis=none) header.from=gmail.com X-Suspicious-Flag: YES X-Classification-ID: 24e88bf4-d949-11e9-9e72-52540055034d-1-1 Received: from [216.105.38.7] ([216.105.38.7:43264] helo=lists.sourceforge.net) by smtp10.gate.iad3b.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 36/CE-13182-B95D08D5; Tue, 17 Sep 2019 08:46:19 -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 1iACrM-00037i-Ap; Tue, 17 Sep 2019 12:45:32 +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 1iACrC-00037I-GV for openvpn-devel@lists.sourceforge.net; Tue, 17 Sep 2019 12:45:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=References:In-Reply-To:Message-Id:Date:Subject:To: From:Sender:Reply-To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: 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=6mJK56r5yqdFfuHyNnnEDUi1R62l/q54Kqeh4ClzDls=; b=c4uSTp56a1JGYWBi+KSmKo+T2E kIO2JeOpkIMdGJrmZipZ4ietfVu5vxMOklj5RsNgsLx/sejtY+1S1X0Z1pr8aRb5HRzP9Qpm7uTBX CIjeAdICS6a5LsUsPDUodyYrxiDs4iSZ6sYWaohffrw2voWYokJ+y2XSxghxuCz+RVpk=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc :MIME-Version:Content-Type:Content-Transfer-Encoding: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=6mJK56r5yqdFfuHyNnnEDUi1R62l/q54Kqeh4ClzDls=; b=Gur5uAv/yj9dZ2M0W5d5tiUzK9 jLrnmb2sUuEdMKZacC4h0D+xfWLFH00Wo8AEahNILe6tiU6RzzjW+w3j14gFKpGOBJUIDeAWEyrYq 95m2IdBrr3sE63JZVfHo8ItRgKFXYjFlVSchPy4jGMO2Dz8LfoJ2TsQMi/wgDUfVHTXE=; Received: from mail-ed1-f49.google.com ([209.85.208.49]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.90_1) id 1iACr8-001Fcs-Fe for openvpn-devel@lists.sourceforge.net; Tue, 17 Sep 2019 12:45:22 +0000 Received: by mail-ed1-f49.google.com with SMTP id p10so1387189edq.1 for ; Tue, 17 Sep 2019 05:45:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=6mJK56r5yqdFfuHyNnnEDUi1R62l/q54Kqeh4ClzDls=; b=fb9rIejiMmlvsXmvZ6X+TWTSvfmUVsdJUB8kkSxHuYZgV8m93Can9HPwSOXi//jihN 1AvP8rPyIp9Yok/EI9VDNpsekOsjX5ZMUJ+LE8OiRSqbsP7vK3HrGCe3mEpUcNxhAsWs 8bNntqxslyKOkEeQE+YFTFl3EZGG2SQ2AQLqyaW0Pgwwa0Q49WROeDRf10B4pxBL27mx o9sz1sxpJCW8i/LfFX8lKC3gaSsLQ/yx7Q3Cya+QQVJvfctmtVMlnof2hAq3ynk0YfSn SCydS97fcK89IqqPO2KCvzktMEeD8sSInMQDfZXsL4ymxs/pYyqNxnqNOebx34sPZd90 yhPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=6mJK56r5yqdFfuHyNnnEDUi1R62l/q54Kqeh4ClzDls=; b=dDE2gjrfkB7foKa0q53iztEs5PvozSDhq6ejoIGiFEc2rE1WxRLU+bhtLbyRPHbmaa 4j9vMHuM39w+x9pMZ8+LTcStND6ticl3jYWGyOmsh15bggd8KYOJjj5v+8qKV9Xs83DE J0z9f1GK4g2M66C2exsAFVaYjgOE5g3JxHY3mpQLq/1Ky6GPfankzAAf43L6ryC+K6nc Si6YGr5KgH4lkTukoHvnYVE+HhFaEcRaM/Pg5Xy4Ga0oTR99gQtclwN8Poi2XqRH2EPO XMaWe6/M1BUUs1f6vf5LJ77xYapBjLDEy4hKEleolNjGck0+suunhyU041li9p5oKD8K FKsg== X-Gm-Message-State: APjAAAVvgIyN9a5j1N877W0YY2K1hdQuOQKTyMzDwg/PKUordByS2N4E 9Z6/apB11Ip9Eo9DHHUGqT8c9ngq1HY3cw== X-Google-Smtp-Source: APXvYqw/go64a2fWd3YqlTqEHvAlyrZGMbhgGmnor7fcvgbWHg1BiaNfwIr3dhgo4hPZtDjUzoG5hA== X-Received: by 2002:aa7:da51:: with SMTP id w17mr4511073eds.70.1568724311447; Tue, 17 Sep 2019 05:45:11 -0700 (PDT) Received: from stipakov.fi (stipakov.fi. [128.199.52.117]) by smtp.gmail.com with ESMTPSA id j8sm326585edy.44.2019.09.17.05.45.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 17 Sep 2019 05:45:10 -0700 (PDT) From: Lev Stipakov To: openvpn-devel@lists.sourceforge.net Date: Tue, 17 Sep 2019 15:44:48 +0300 Message-Id: <1568724293-5069-2-git-send-email-lstipakov@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1568724293-5069-1-git-send-email-lstipakov@gmail.com> References: <1568724293-5069-1-git-send-email-lstipakov@gmail.com> 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: openvpn.net] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (lstipakov[at]gmail.com) -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.208.49 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.208.49 listed in list.dnswl.org] -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: 1iACr8-001Fcs-Fe Subject: [Openvpn-devel] [PATCH 2/7] wintun: add --windows-driver config option 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: , MIME-Version: 1.0 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox From: Lev Stipakov This allows to specify which tun driver openvpn should use, tap-windows6 (default) or wintun. Note than wintun support will be added in follow-up patches. Signed-off-by: Lev Stipakov --- src/openvpn/init.c | 7 +++++++ src/openvpn/options.c | 37 +++++++++++++++++++++++++++++++++++++ src/openvpn/options.h | 1 + src/openvpn/tun.h | 1 + 4 files changed, 46 insertions(+) diff --git a/src/openvpn/init.c b/src/openvpn/init.c index b5a034d..edd11c2 100644 --- a/src/openvpn/init.c +++ b/src/openvpn/init.c @@ -1727,6 +1727,10 @@ do_init_tun(struct context *c) c->c2.es, &c->net_ctx); +#ifdef _WIN32 + c->c1.tuntap->wintun = c->options.wintun; +#endif + init_tun_post(c->c1.tuntap, &c->c2.frame, &c->options.tuntap_options); @@ -1769,6 +1773,9 @@ do_open_tun(struct context *c) /* store (hide) interactive service handle in tuntap_options */ c->c1.tuntap->options.msg_channel = c->options.msg_channel; msg(D_ROUTE, "interactive service msg_channel=%u", (unsigned int) c->options.msg_channel); + + c->c1.tuntap->wintun = c->options.wintun; + #endif /* allocate route list structure */ diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 2d3865a..9f8e92b 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -744,6 +744,9 @@ static const char usage_message[] = " optional parameter controls the initial state of ex.\n" "--show-net-up : Show " PACKAGE_NAME "'s view of routing table and net adapter list\n" " after TAP adapter is up and routes have been added.\n" + "--windows-driver : Which tun driver to use?\n" + " tap-windows6 (default)\n" + " wintun\n" #ifdef _WIN32 "--block-outside-dns : Block DNS on other network adapters to prevent DNS leaks\n" #endif @@ -848,6 +851,7 @@ init_options(struct options *o, const bool init_gc) o->tuntap_options.dhcp_masq_offset = 0; /* use network address as internal DHCP server address */ o->route_method = ROUTE_METHOD_ADAPTIVE; o->block_outside_dns = false; + o->wintun = false; #endif #if P2MP_SERVER o->real_hash_size = 256; @@ -2935,6 +2939,12 @@ options_postprocess_mutate_invariant(struct options *options) options->ifconfig_noexec = false; } + /* for wintun kernel doesn't send DHCP requests, so use ipapi to set IP address and netmask */ + if (options->wintun) + { + options->tuntap_options.ip_win32_type = IPW32_SET_IPAPI; + } + remap_redirect_gateway_flags(options); #endif @@ -3980,6 +3990,26 @@ foreign_option(struct options *o, char *argv[], int len, struct env_set *es) } } +#ifdef _WIN32 +bool +parse_windows_driver(const char *str, const int msglevel) +{ + if (streq(str, "tap-windows6")) + { + return false; + } + else if (streq(str, "wintun")) + { + return true; + } + else + { + msg(msglevel, "--windows-driver must be tap-windows6 or wintun"); + return false; + } +} +#endif + /* * parse/print topology coding */ @@ -5222,6 +5252,13 @@ add_option(struct options *options, VERIFY_PERMISSION(OPT_P_GENERAL); options->dev_type = p[1]; } +#ifdef _WIN32 + else if (streq(p[0], "windows-driver") && p[1] && !p[2]) + { + VERIFY_PERMISSION(OPT_P_GENERAL); + options->wintun = parse_windows_driver(p[1], M_FATAL); + } +#endif else if (streq(p[0], "dev-node") && p[1] && !p[2]) { VERIFY_PERMISSION(OPT_P_GENERAL); diff --git a/src/openvpn/options.h b/src/openvpn/options.h index 63f0f4c..37dee71 100644 --- a/src/openvpn/options.h +++ b/src/openvpn/options.h @@ -621,6 +621,7 @@ struct options bool show_net_up; int route_method; bool block_outside_dns; + bool wintun; #endif bool use_peer_id; diff --git a/src/openvpn/tun.h b/src/openvpn/tun.h index 69831c4..a61aa22 100644 --- a/src/openvpn/tun.h +++ b/src/openvpn/tun.h @@ -175,6 +175,7 @@ struct tuntap * ~0 if undefined */ DWORD adapter_index; + bool wintun; /* true if wintun is used instead of tap-windows6 */ int standby_iter; #else /* ifdef _WIN32 */ int fd; /* file descriptor for TUN/TAP dev */