From patchwork Mon Nov 6 17:32:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "its_Giaan (Code Review)" X-Patchwork-Id: 3416 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7300:8e12:b0:f2:62eb:61c1 with SMTP id j18csp3244734dys; Mon, 6 Nov 2023 09:34:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IFOnhhR1cVwBYF1a37DExWY57dJ1QsGBfxDi+eR8F171cMApt9gX4g3XVWb78H6maUV8zDE X-Received: by 2002:a17:90b:3597:b0:274:60c7:e15a with SMTP id mm23-20020a17090b359700b0027460c7e15amr29111656pjb.4.1699292040923; Mon, 06 Nov 2023 09:34:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699292040; cv=none; d=google.com; s=arc-20160816; b=DOzgUm1rl8Bvk3Kiq7tB1wOdDu1U6sbpQyaon7QtwcoHWU+u4ZGx2K3CE69WolW9mE NhJRmRuR2Eoe5KBdTr9U+dEFZkNuyFyaeAvE0+KFsaJ43hMyU4ceWHb1GybTbc9e+Tz5 T9bIHS9cPusBsHWUhqcDQoiPyTa6ILLhzYCIMYo9on8OCZPGCTOugvrUlzxZhweTV+oJ OeGc1Mck6Tca5EU1k/4G/kGNNohRPP15iZtb+JVDi8GBu6OgOvdnZ2FATGJQGt8K462N HN3hB1wUqCuPsPSN3Hx67ju2dIqbAfmhyLxbVLRC23S8bZ6kJ2w8pSA0g8togeslYkw7 tS1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:cc:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:user-agent :mime-version:message-id:references:auto-submitted:to:date:from :dkim-signature:dkim-signature:dkim-signature; bh=8Iv3/FcdXVbECiSaJhSOx+dHbg6LGEnqPv5CSWx8VmI=; fh=GFP4qDxgyJ2WEPo/oeLZg3Mj4NqvY1j2nTvTt7psNwg=; b=gmNJGq8oX/whJMlRqbZVYKXYmyf6KVl6iNQen2aWtYONIEO9qLF5faPWsifP/YjczM ZCzNkv7OvZiBjIl1t0kOMUVffGUEpcQ7vpFSs3oxcO9xH364NnsDkA+s5cF2Jq0N+5f5 ycgCdvzx5OcEsHownXgZ35vvWe/Uar9k0IiBB7dMvjGa/lIV/GnY4DTMDNMvx0VduL8o TCZkGkC87Ic2Fx2e/7JCynTQkkIoGTszYb/AMKlY2L34rjo7OQnzwb5fGYDe6zQhcvxO r8xwdox/NSAMk1gWcu0Q6Zw5UlQxY0s9+I/kt1kRrJIxkJj9f4KULKLv8pvcraTftQue 5AWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=i7qefYfG; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=af8PhGDm; dkim=neutral (body hash did not verify) header.i=@openvpn.net header.s=google header.b=Tw2wBSlR; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=openvpn.net Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id z11-20020a17090a1fcb00b0027d097b9c36si2352525pjz.75.2023.11.06.09.34.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Nov 2023 09:34:00 -0800 (PST) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=i7qefYfG; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=af8PhGDm; dkim=neutral (body hash did not verify) header.i=@openvpn.net header.s=google header.b=Tw2wBSlR; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=openvpn.net Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1r03TI-0004iK-Ct; Mon, 06 Nov 2023 17:33:06 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1r03TH-0004iD-9k for openvpn-devel@lists.sourceforge.net; Mon, 06 Nov 2023 17:33:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:Content-Transfer-Encoding:MIME-Version :Message-ID:Reply-To:References:Subject:List-Unsubscribe:List-Id:Cc:To:Date: From:Sender:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:List-Help: List-Subscribe:List-Post:List-Owner:List-Archive; bh=6Zfl/4vJRgaE9Xlxy8G0H8t1LVuW0q2suU03jNJ/ibc=; b=i7qefYfGgstlXJaph4ErCO2duw Nvpo/eTA0mBtkRPCOc767lInYS8sPPV0WRiH/PfmaWXRcaKsbcN2qJUOkTgZgoQswqF6+FXdJSVMS qLZ36NVA+OrtSt+di+X/kNlMm19Yojh/n9NWBToTA+0wo6WVqfUMveZB4kk1cnqmxsSk=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:Content-Transfer-Encoding:MIME-Version:Message-ID:Reply-To: References:Subject:List-Unsubscribe:List-Id:Cc:To:Date:From:Sender:Content-ID :Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To: Resent-Cc:Resent-Message-ID:In-Reply-To:List-Help:List-Subscribe:List-Post: List-Owner:List-Archive; bh=6Zfl/4vJRgaE9Xlxy8G0H8t1LVuW0q2suU03jNJ/ibc=; b=a f8PhGDmsd4C6yHBedjpfUGRTu6qhznJ/L+TIWlCH57TITAJeTgQvjmvqcV6RTupn5JbBAxjHM1Fs5 XDa2xxVnzWuGaKRDb3kKK5SVM6aPeF1yPGxWmENTkL5AWsuFxf4xSnoRf35uLtU4eVSN02Rbalk8D i8x5wagLGjvvtE24=; Received: from mail-wr1-f50.google.com ([209.85.221.50]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1r03T9-004mq0-4t for openvpn-devel@lists.sourceforge.net; Mon, 06 Nov 2023 17:33:05 +0000 Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-32f8441dfb5so3284151f8f.0 for ; Mon, 06 Nov 2023 09:32:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvpn.net; s=google; t=1699291972; x=1699896772; darn=lists.sourceforge.net; h=user-agent:content-disposition:content-transfer-encoding :mime-version:message-id:reply-to:references:subject :list-unsubscribe:list-id:auto-submitted:cc:to:date:from:from:to:cc :subject:date:message-id:reply-to; bh=6Zfl/4vJRgaE9Xlxy8G0H8t1LVuW0q2suU03jNJ/ibc=; b=Tw2wBSlRnFzO9ChJAAhLVXmPzR8f0JS1ixM3tSf5z6rvfFfhZBuQqALCxTNFTp2tOe kJYpe6kfU5dYajq8zgiMGeJOm7f+seVRgILDu/VpbWLCwHSjVzqiN/NS5jkwOdW0/V84 ve7nIA/4mGqYVjlRz7bSQTed+H/nhOHtMM5OcQ1ikmipboxuOqkOGt04qKInc9x+AbnD RUgVNG/lc1dQ4axA6I0he8MabaTd9zj6sUTzWaUa96u3FpqmORuj/NVKSGQpaBd/wFKv A+L8nE9Zr3RJ48feJBHWwUp9/eCiBaEbPp5vkcA/Pk05duMlCR+qrNPfBbbSO2pZkQYr aodQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699291972; x=1699896772; h=user-agent:content-disposition:content-transfer-encoding :mime-version:message-id:reply-to:references:subject :list-unsubscribe:list-id:auto-submitted:cc:to:date:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6Zfl/4vJRgaE9Xlxy8G0H8t1LVuW0q2suU03jNJ/ibc=; b=ku/yAcFaIEo4LAelPUnFTnm0lCRpTf+tqJMw54TQHErZZ4elnDgT8Ee4v/Ta97nQr3 vWRVugpHMcBviwFBO5b1da8DwQxUqjxSE386QX1ZLnhzT0eMhAg8XC28Gg5rq7RN5QIK Pd7aS+BiiOaaF+QL9xFGzR42PnKk62DfRlRt/hWQxFDsGjrZcveCB5ucqDASl5giPdGT PZkveoRNyPGIdpnoA+JKtZWk+jIKY9M0+pSJdTbbg1U3hb+WHd0ZZOJFPq9tj2uu0G6U y/y8XZ3IuFsJm1OGRp0Y4cFc+8578WYwXWnj5YyQYvSWKE68cL2LdOMg5keyUKZwsxb6 1NXw== X-Gm-Message-State: AOJu0Yx8fWS2XVwUwZrF28DVn5Q5lLsUFaOviks2EfqwgNF0gcwa+47j v4PWYeGlvys+QGCWp0hiOLYZcbhvTViQk+LfuIo= X-Received: by 2002:adf:ef02:0:b0:32d:8220:8991 with SMTP id e2-20020adfef02000000b0032d82208991mr26014029wro.8.1699291972319; Mon, 06 Nov 2023 09:32:52 -0800 (PST) Received: from gerrit.openvpn.in (ec2-18-159-0-78.eu-central-1.compute.amazonaws.com. [18.159.0.78]) by smtp.gmail.com with ESMTPSA id o12-20020a5d4a8c000000b0032fbd0c7d04sm153073wrq.55.2023.11.06.09.32.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 09:32:51 -0800 (PST) From: "flichtenheld (Code Review)" X-Google-Original-From: "flichtenheld (Code Review)" X-Gerrit-PatchSet: 1 Date: Mon, 6 Nov 2023 17:32:51 +0000 To: plaisthos Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange X-Gerrit-Change-Id: Ice8b95f953c3f7e71657a78ea12b02a08c60aa67 X-Gerrit-Change-Number: 380 X-Gerrit-Project: openvpn X-Gerrit-ChangeURL: X-Gerrit-Commit: c8b27859d488fdcb0a887175f075b4a2875f81e9 References: Message-ID: <7c3726a795f0379b5b9c8617e6411a9b6636d3fe-HTML@gerrit.openvpn.net> MIME-Version: 1.0 User-Agent: Gerrit/3.8.2 X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "util-spamd-2.v13.lw.sourceforge.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Attention is currently required from: plaisthos. Hello plaisthos, I'd like you to do a code review. Please visit Content analysis details: (-0.2 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.221.50 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.221.50 listed in wl.mailspike.net] 0.0 WEIRD_PORT URI: Uses non-standard port number for HTTP 0.0 HTML_MESSAGE BODY: HTML included in message 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 T_SCC_BODY_TEXT_LINE No description available. 0.0 T_KAM_HTML_FONT_INVALID Test for Invalidly Named or Formatted Colors in HTML X-Headers-End: 1r03T9-004mq0-4t Subject: [Openvpn-devel] [M] Change in openvpn[master]: tun: use is_tun_p2p more consistently 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: , Reply-To: frank@lichtenheld.com, arne-openvpn@rfc2549.org, openvpn-devel@lists.sourceforge.net Cc: openvpn-devel Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1781836851164656109?= X-GMAIL-MSGID: =?utf-8?q?1781836851164656109?= X-getmail-filter-classifier: gerrit message type newchange Attention is currently required from: plaisthos. Hello plaisthos, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/380?usp=email to review the following change. Change subject: tun: use is_tun_p2p more consistently ...................................................................... tun: use is_tun_p2p more consistently Using "tun" as the variable name for the return of is_tun_p2p is probably a historical accident. But it has actual consequences in that the other code often seems to assume that it does less checks than it actually does. Use "tun_p2p" as the variable name and remove checks that are not required. Also use is_tun_p2p in more places. Change-Id: Ice8b95f953c3f7e71657a78ea12b02a08c60aa67 Signed-off-by: Frank Lichtenheld --- M src/openvpn/tun.c 1 file changed, 48 insertions(+), 72 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/80/380/1 diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index f857ed1..45559fc 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -507,31 +507,31 @@ static const char ifconfig_warn_how_to_silence[] = "(silence this warning with --ifconfig-nowarn)"; /* - * If !tun, make sure ifconfig_remote_netmask looks + * If !tun_p2p, make sure ifconfig_remote_netmask looks * like a netmask. * - * If tun, make sure ifconfig_remote_netmask looks + * If tun_p2p, make sure ifconfig_remote_netmask looks * like an IPv4 address. */ static void -ifconfig_sanity_check(bool tun, in_addr_t addr, int topology) +ifconfig_sanity_check(bool tun_p2p, in_addr_t addr) { struct gc_arena gc = gc_new(); const bool looks_like_netmask = ((addr & 0xFF000000) == 0xFF000000); - if (tun) + if (tun_p2p) { - if (looks_like_netmask && (topology == TOP_NET30 || topology == TOP_P2P)) + if (looks_like_netmask) { msg(M_WARN, "WARNING: Since you are using --dev tun with a point-to-point topology, the second argument to --ifconfig must be an IP address. You are using something (%s) that looks more like a netmask. %s", print_in_addr_t(addr, 0, &gc), ifconfig_warn_how_to_silence); } } - else /* tap */ + else { if (!looks_like_netmask) { - msg(M_WARN, "WARNING: Since you are using --dev tap, the second argument to --ifconfig must be a netmask, for example something like 255.255.255.0. %s", + msg(M_WARN, "WARNING: Since you are using subnet topology, the second argument to --ifconfig must be a netmask, for example something like 255.255.255.0. %s", ifconfig_warn_how_to_silence); } } @@ -675,13 +675,13 @@ struct buffer out = alloc_buf_gc(256, gc); if (tt->did_ifconfig_setup && !disable) { - if (tt->type == DEV_TYPE_TAP || (tt->type == DEV_TYPE_TUN && tt->topology == TOP_SUBNET)) + if (!is_tun_p2p(tt)) { buf_printf(&out, "%s %s", print_in_addr_t(tt->local & tt->remote_netmask, 0, gc), print_in_addr_t(tt->remote_netmask, 0, gc)); } - else if (tt->type == DEV_TYPE_TUN) + else if (tt->type == DEV_TYPE_TUN) /* tun p2p topology */ { const char *l, *r; if (remote) @@ -745,24 +745,24 @@ bool is_tun_p2p(const struct tuntap *tt) { - bool tun = false; + bool tun_p2p = false; if (tt->type == DEV_TYPE_TAP || (tt->type == DEV_TYPE_TUN && tt->topology == TOP_SUBNET) || tt->type == DEV_TYPE_NULL) { - tun = false; + tun_p2p = false; } else if (tt->type == DEV_TYPE_TUN) { - tun = true; + tun_p2p = true; } else { msg(M_FATAL, "Error: problem with tun vs. tap setting"); /* JYFIXME -- needs to be caught earlier, in init_tun? */ } - return tun; + return tun_p2p; } /* @@ -839,12 +839,10 @@ if (ifconfig_local_parm && ifconfig_remote_netmask_parm) { - bool tun = false; - /* * We only handle TUN/TAP devices here, not --dev null devices. */ - tun = is_tun_p2p(tt); + bool tun_p2p = is_tun_p2p(tt); /* * Convert arguments to binary IPv4 addresses. @@ -861,7 +859,7 @@ NULL); tt->remote_netmask = getaddr( - (tun ? GETADDR_RESOLVE : 0) + (tun_p2p ? GETADDR_RESOLVE : 0) | GETADDR_HOST_ORDER | GETADDR_FATAL_ON_SIGNAL | GETADDR_FATAL, @@ -876,7 +874,7 @@ if (strict_warn) { struct addrinfo *curele; - ifconfig_sanity_check(tt->type == DEV_TYPE_TUN, tt->remote_netmask, tt->topology); + ifconfig_sanity_check(tun_p2p, tt->remote_netmask); /* * If local_public or remote_public addresses are defined, @@ -907,11 +905,11 @@ } } - if (tt->type == DEV_TYPE_TAP || (tt->type == DEV_TYPE_TUN && tt->topology == TOP_SUBNET)) + if (!tun_p2p) { check_subnet_conflict(tt->local, tt->remote_netmask, "TUN/TAP adapter"); } - else if (tt->type == DEV_TYPE_TUN) + else { check_subnet_conflict(tt->local, IPV4_NETMASK_HOST, "TUN/TAP adapter"); } @@ -922,7 +920,7 @@ * Make sure that both ifconfig addresses are part of the * same .252 subnet. */ - if (tun) + if (tun_p2p) { verify_255_255_255_252(tt->local, tt->remote_netmask); tt->adapter_netmask = ~3; @@ -1305,7 +1303,7 @@ /* * We only handle TUN/TAP devices here, not --dev null devices. */ - bool tun = is_tun_p2p(tt); + bool tun_p2p = is_tun_p2p(tt); #endif #if !defined(TARGET_LINUX) @@ -1332,7 +1330,7 @@ msg(M_FATAL, "Linux can't bring %s up", ifname); } - if (tun) + if (tun_p2p) { if (net_addr_ptp_v4_add(ctx, ifname, &tt->local, &tt->remote_netmask) < 0) @@ -1351,27 +1349,8 @@ #elif defined(TARGET_ANDROID) char out[64]; - char *top; - switch (tt->topology) - { - case TOP_NET30: - top = "net30"; - break; - - case TOP_P2P: - top = "p2p"; - break; - - case TOP_SUBNET: - top = "subnet"; - break; - - default: - top = "undef"; - } - openvpn_snprintf(out, sizeof(out), "%s %s %d %s", ifconfig_local, - ifconfig_remote_netmask, tun_mtu, top); + ifconfig_remote_netmask, tun_mtu, print_topology(tt->topology)); management_android_control(management, "IFCONFIG", out); #elif defined(TARGET_SOLARIS) @@ -1380,7 +1359,7 @@ * ifconfig tun2 10.2.0.2 10.2.0.1 mtu 1450 up * ifconfig tun2 netmask 255.255.255.255 */ - if (tun) + if (tun_p2p) { argv_printf(&argv, "%s %s %s %s mtu %d up", IFCONFIG_PATH, ifname, ifconfig_local, ifconfig_remote_netmask, tun_mtu); @@ -1394,13 +1373,13 @@ argv_printf(&argv, "%s %s netmask 255.255.255.255", IFCONFIG_PATH, ifname); } - else if (tt->type == DEV_TYPE_TUN && tt->topology == TOP_SUBNET) + else if (tt->type == DEV_TYPE_TUN) { argv_printf(&argv, "%s %s %s %s netmask %s mtu %d up", IFCONFIG_PATH, ifname, ifconfig_local, ifconfig_local, ifconfig_remote_netmask, tun_mtu); } - else + else /* tap */ { argv_printf(&argv, "%s %s %s netmask %s up", IFCONFIG_PATH, ifname, ifconfig_local, @@ -1413,7 +1392,7 @@ solaris_error_close(tt, es, ifname, false); } - if (!tun && tt->type == DEV_TYPE_TUN && tt->topology == TOP_SUBNET) + if (!tun_p2p && tt->type == DEV_TYPE_TUN) { /* Add a network route for the local tun interface */ struct route_ipv4 r; @@ -1437,14 +1416,14 @@ */ /* example: ifconfig tun2 10.2.0.2 10.2.0.1 mtu 1450 netmask 255.255.255.255 up */ - if (tun) + if (tun_p2p) { argv_printf(&argv, "%s %s %s %s mtu %d netmask 255.255.255.255 up -link0", IFCONFIG_PATH, ifname, ifconfig_local, ifconfig_remote_netmask, tun_mtu); } - else if (tt->type == DEV_TYPE_TUN && tt->topology == TOP_SUBNET) + else if (tt->type == DEV_TYPE_TUN) { remote_end = create_arbitrary_remote( tt ); argv_printf(&argv, "%s %s %s %s mtu %d netmask %s up -link0", @@ -1452,7 +1431,7 @@ print_in_addr_t(remote_end, 0, &gc), tun_mtu, ifconfig_remote_netmask); } - else + else /* tap */ { argv_printf(&argv, "%s %s %s netmask %s mtu %d link0", IFCONFIG_PATH, ifname, ifconfig_local, @@ -1462,7 +1441,7 @@ openvpn_execve_check(&argv, es, S_FATAL, "OpenBSD ifconfig failed"); /* Add a network route for the local tun interface */ - if (!tun && tt->type == DEV_TYPE_TUN && tt->topology == TOP_SUBNET) + if (!tun_p2p && tt->type == DEV_TYPE_TUN) { struct route_ipv4 r; CLEAR(r); @@ -1476,20 +1455,20 @@ #elif defined(TARGET_NETBSD) in_addr_t remote_end = INADDR_ANY; /* for "virtual" subnet topology */ - if (tun) + if (tun_p2p) { argv_printf(&argv, "%s %s %s %s mtu %d netmask 255.255.255.255 up", IFCONFIG_PATH, ifname, ifconfig_local, ifconfig_remote_netmask, tun_mtu); } - else if (tt->type == DEV_TYPE_TUN && tt->topology == TOP_SUBNET) + else if (tt->type == DEV_TYPE_TUN) { remote_end = create_arbitrary_remote(tt); argv_printf(&argv, "%s %s %s %s mtu %d netmask %s up", IFCONFIG_PATH, ifname, ifconfig_local, print_in_addr_t(remote_end, 0, &gc), tun_mtu, ifconfig_remote_netmask); } - else + else /* tap */ { /* * NetBSD has distinct tun and tap devices @@ -1504,7 +1483,7 @@ openvpn_execve_check(&argv, es, S_FATAL, "NetBSD ifconfig failed"); /* Add a network route for the local tun interface */ - if (!tun && tt->type == DEV_TYPE_TUN && tt->topology == TOP_SUBNET) + if (!tun_p2p && tt->type == DEV_TYPE_TUN) { struct route_ipv4 r; CLEAR(r); @@ -1528,33 +1507,30 @@ /* example: ifconfig tun2 10.2.0.2 10.2.0.1 mtu 1450 netmask 255.255.255.255 up */ - if (tun) + if (tun_p2p) { argv_printf(&argv, "%s %s %s %s mtu %d netmask 255.255.255.255 up", IFCONFIG_PATH, ifname, ifconfig_local, ifconfig_remote_netmask, tun_mtu); } - else + else if (tt->type == DEV_TYPE_TUN) { - if (tt->type == DEV_TYPE_TUN && tt->topology == TOP_SUBNET) - { - argv_printf(&argv, "%s %s %s %s netmask %s mtu %d up", - IFCONFIG_PATH, ifname, ifconfig_local, ifconfig_local, - ifconfig_remote_netmask, tun_mtu); - } - else - { - argv_printf(&argv, "%s %s %s netmask %s mtu %d up", IFCONFIG_PATH, - ifname, ifconfig_local, ifconfig_remote_netmask, - tun_mtu); - } + argv_printf(&argv, "%s %s %s %s netmask %s mtu %d up", + IFCONFIG_PATH, ifname, ifconfig_local, ifconfig_local, + ifconfig_remote_netmask, tun_mtu); + } + else /* tap */ + { + argv_printf(&argv, "%s %s %s netmask %s mtu %d up", IFCONFIG_PATH, + ifname, ifconfig_local, ifconfig_remote_netmask, + tun_mtu); } argv_msg(M_INFO, &argv); openvpn_execve_check(&argv, es, S_FATAL, "Mac OS X ifconfig failed"); /* Add a network route for the local tun interface */ - if (!tun && tt->type == DEV_TYPE_TUN && tt->topology == TOP_SUBNET) + if (!tun_p2p && tt->type == DEV_TYPE_TUN) { struct route_ipv4 r; CLEAR(r); @@ -1568,7 +1544,7 @@ #elif defined(TARGET_FREEBSD) || defined(TARGET_DRAGONFLY) /* example: ifconfig tun2 10.2.0.2 10.2.0.1 mtu 1450 netmask 255.255.255.255 up */ - if (tun) /* point-to-point tun */ + if (tun_p2p) /* point-to-point tun */ { argv_printf(&argv, "%s %s %s %s mtu %d netmask 255.255.255.255 up", IFCONFIG_PATH, ifname, ifconfig_local, @@ -1590,7 +1566,7 @@ struct env_set *aix_es = env_set_create(NULL); env_set_add( aix_es, "ODMDIR=/etc/objrepos" ); - if (tun) + if (tt->type == DEV_TYPE_TUN) { msg(M_FATAL, "no tun support on AIX (canthappen)"); }