From: "cron2 (Code Review)" Date: Mon, 9 Sep 2024 09:33:47 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <44d1adacf89cf16e94cd806e7772980101179e30-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="PCywEWw3VqE="; charset=UTF-8 Subject: [Openvpn-devel] [M] Change in openvpn[master]: tun: use is_tun_p2p more consistently List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld , plaisthos Cc: openvpn-devel --PCywEWw3VqE= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#9) to the change originally created by= flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/380?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by plaisthos 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 Acked-by: Arne Schwabe Message-Id: <20240906162514.78671-1-frank@...2641...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29= 091.html Signed-off-by: Gert Doering --- M src/openvpn/tun.c 1 file changed, 48 insertions(+), 72 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/80/380/9 diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index ce3d882..739e008 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -499,31 +499,31 @@ static const char ifconfig_warn_how_to_silence[] =3D "(silence this warnin= g 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 =3D gc_new(); const bool looks_like_netmask =3D ((addr & 0xFF000000) =3D=3D 0xFF0000= 00); - if (tun) + if (tun_p2p) { - if (looks_like_netmask && (topology =3D=3D TOP_NET30 || topology = =3D=3D TOP_P2P)) + if (looks_like_netmask) { msg(M_WARN, "WARNING: Since you are using --dev tun with a poi= nt-to-point topology, the second argument to --ifconfig must be an IP addre= ss. 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 secon= d 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 lik= e 255.255.255.0. %s", ifconfig_warn_how_to_silence); } } @@ -667,13 +667,13 @@ struct buffer out =3D alloc_buf_gc(256, gc); if (tt->did_ifconfig_setup && !disable) { - if (tt->type =3D=3D DEV_TYPE_TAP || (tt->type =3D=3D DEV_TYPE_TUN = && tt->topology =3D=3D 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 =3D=3D DEV_TYPE_TUN) + else if (tt->type =3D=3D DEV_TYPE_TUN) /* tun p2p topology */ { const char *l, *r; if (remote) @@ -737,24 +737,24 @@ bool is_tun_p2p(const struct tuntap *tt) { - bool tun =3D false; + bool tun_p2p =3D false; if (tt->type =3D=3D DEV_TYPE_TAP || (tt->type =3D=3D DEV_TYPE_TUN && tt->topology =3D=3D TOP_SUBNET) || tt->type =3D=3D DEV_TYPE_NULL) { - tun =3D false; + tun_p2p =3D false; } else if (tt->type =3D=3D DEV_TYPE_TUN) { - tun =3D true; + tun_p2p =3D true; } else { msg(M_FATAL, "Error: problem with tun vs. tap setting"); /* JYFIXM= E -- needs to be caught earlier, in init_tun? */ } - return tun; + return tun_p2p; } /* @@ -831,12 +831,10 @@ if (ifconfig_local_parm && ifconfig_remote_netmask_parm) { - bool tun =3D false; - /* * We only handle TUN/TAP devices here, not --dev null devices. */ - tun =3D is_tun_p2p(tt); + bool tun_p2p =3D is_tun_p2p(tt); /* * Convert arguments to binary IPv4 addresses. @@ -853,7 +851,7 @@ NULL); tt->remote_netmask =3D getaddr( - (tun ? GETADDR_RESOLVE : 0) + (tun_p2p ? GETADDR_RESOLVE : 0) | GETADDR_HOST_ORDER | GETADDR_FATAL_ON_SIGNAL | GETADDR_FATAL, @@ -868,7 +866,7 @@ if (strict_warn) { struct addrinfo *curele; - ifconfig_sanity_check(tt->type =3D=3D 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, @@ -899,11 +897,11 @@ } } - if (tt->type =3D=3D DEV_TYPE_TAP || (tt->type =3D=3D DEV_TYPE_= TUN && tt->topology =3D=3D TOP_SUBNET)) + if (!tun_p2p) { check_subnet_conflict(tt->local, tt->remote_netmask, "TUN/= TAP adapter"); } - else if (tt->type =3D=3D DEV_TYPE_TUN) + else { check_subnet_conflict(tt->local, IPV4_NETMASK_HOST, "TUN/T= AP adapter"); } @@ -914,7 +912,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 =3D ~3; @@ -1297,7 +1295,7 @@ /* * We only handle TUN/TAP devices here, not --dev null devices. */ - bool tun =3D is_tun_p2p(tt); + bool tun_p2p =3D is_tun_p2p(tt); #endif #if !defined(TARGET_LINUX) @@ -1324,7 +1322,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) @@ -1343,27 +1341,8 @@ #elif defined(TARGET_ANDROID) char out[64]; - char *top; - switch (tt->topology) - { - case TOP_NET30: - top =3D "net30"; - break; - - case TOP_P2P: - top =3D "p2p"; - break; - - case TOP_SUBNET: - top =3D "subnet"; - break; - - default: - top =3D "undef"; - } - 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) @@ -1372,7 +1351,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); @@ -1386,13 +1365,13 @@ argv_printf(&argv, "%s %s netmask 255.255.255.255", IFCONFIG_PATH, ifname); } - else if (tt->type =3D=3D DEV_TYPE_TUN && tt->topology =3D=3D TOP_SUBNE= T) + else if (tt->type =3D=3D DEV_TYPE_TUN) { argv_printf(&argv, "%s %s %s %s netmask %s mtu %d up", IFCONFIG_PA= TH, 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, @@ -1405,7 +1384,7 @@ solaris_error_close(tt, es, ifname, false); } - if (!tun && tt->type =3D=3D DEV_TYPE_TUN && tt->topology =3D=3D TOP_SU= BNET) + if (!tun_p2p && tt->type =3D=3D DEV_TYPE_TUN) { /* Add a network route for the local tun interface */ struct route_ipv4 r; @@ -1429,14 +1408,14 @@ */ /* example: ifconfig tun2 10.2.0.2 10.2.0.1 mtu 1450 netmask 255.255.2= 55.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 =3D=3D DEV_TYPE_TUN && tt->topology =3D=3D TOP_SUBNE= T) + else if (tt->type =3D=3D DEV_TYPE_TUN) { remote_end =3D create_arbitrary_remote( tt ); argv_printf(&argv, "%s %s %s %s mtu %d netmask %s up -link0", @@ -1444,7 +1423,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, @@ -1454,7 +1433,7 @@ openvpn_execve_check(&argv, es, S_FATAL, "OpenBSD ifconfig failed"); /* Add a network route for the local tun interface */ - if (!tun && tt->type =3D=3D DEV_TYPE_TUN && tt->topology =3D=3D TOP_SU= BNET) + if (!tun_p2p && tt->type =3D=3D DEV_TYPE_TUN) { struct route_ipv4 r; CLEAR(r); @@ -1468,20 +1447,20 @@ #elif defined(TARGET_NETBSD) in_addr_t remote_end =3D 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 =3D=3D DEV_TYPE_TUN && tt->topology =3D=3D TOP_SUBNE= T) + else if (tt->type =3D=3D DEV_TYPE_TUN) { remote_end =3D create_arbitrary_remote(tt); argv_printf(&argv, "%s %s %s %s mtu %d netmask %s up", IFCONFIG_PA= TH, 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 @@ -1496,7 +1475,7 @@ openvpn_execve_check(&argv, es, S_FATAL, "NetBSD ifconfig failed"); /* Add a network route for the local tun interface */ - if (!tun && tt->type =3D=3D DEV_TYPE_TUN && tt->topology =3D=3D TOP_SU= BNET) + if (!tun_p2p && tt->type =3D=3D DEV_TYPE_TUN) { struct route_ipv4 r; CLEAR(r); @@ -1520,33 +1499,30 @@ /* example: ifconfig tun2 10.2.0.2 10.2.0.1 mtu 1450 netmask 255.255.2= 55.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 =3D=3D DEV_TYPE_TUN) { - if (tt->type =3D=3D DEV_TYPE_TUN && tt->topology =3D=3D TOP_SUBNET) - { - argv_printf(&argv, "%s %s %s %s netmask %s mtu %d up", - IFCONFIG_PATH, ifname, ifconfig_local, ifconfig_lo= cal, - ifconfig_remote_netmask, tun_mtu); - } - else - { - argv_printf(&argv, "%s %s %s netmask %s mtu %d up", IFCONFIG_P= ATH, - 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 =3D=3D DEV_TYPE_TUN && tt->topology =3D=3D TOP_SU= BNET) + if (!tun_p2p && tt->type =3D=3D DEV_TYPE_TUN) { struct route_ipv4 r; CLEAR(r); @@ -1560,7 +1536,7 @@ #elif defined(TARGET_FREEBSD) || defined(TARGET_DRAGONFLY) /* example: ifconfig tun2 10.2.0.2 10.2.0.1 mtu 1450 netmask 255.255.2= 55.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, @@ -1582,7 +1558,7 @@ struct env_set *aix_es =3D env_set_create(NULL); env_set_add( aix_es, "ODMDIR=3D/etc/objrepos" ); - if (tun) + if (tt->type =3D=3D DEV_TYPE_TUN) { msg(M_FATAL, "no tun support on AIX (canthappen)"); } -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/380?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Ice8b95f953c3f7e71657a78ea12b02a08c60aa67 Gerrit-Change-Number: 380 Gerrit-PatchSet: 9 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-MessageType: newpatchset --PCywEWw3VqE= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 uploaded patch set #9 to the change originally cr= eated by flichtenheld.

View Change

The following approvals got outda= ted and were removed: Code-Review+2 by plaisthos

tun: use is_tun_p2p more consistently

Usi= ng "tun" as the variable name for the return of
is_tun_p2p is = probably a historical accident. But
it has actual consequences in that t= he other code
often seems to assume that it does less checks
than it = actually does.

Use "tun_p2p" as the variable name and remo= ve checks
that are not required. Also use is_tun_p2p in more
places.<= br>
Change-Id: Ice8b95f953c3f7e71657a78ea12b02a08c60aa67
Signed-off-b= y: Frank Lichtenheld <frank@...2641...>
Acked-by: Arne Schwabe <= ;arne-openvpn@...1227...>
Message-Id: <20240906162514.78671-1-fran= k@...2641...>
URL: https://www.mail-archive.com/openvpn-devel@...1096...= ourceforge.net/msg29091.html
Signed-off-by: Gert Doering <gert@...1826...= 6...>
---
M src/openvpn/tun.c
1 file changed, 48 insertions(+),= 72 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn =
refs/changes/80/380/9
diff --git a/src/openvpn/tun.c b/src/openvpn/=
tun.c
index ce3d882..739e008 100644
--- a/s= rc/openvpn/tun.c
+++ b/src/openvpn/tun.c
@@= -499,31 +499,31 @@
static const char ifconfig_warn_how_to= _silence[] =3D "(silence this warning with --ifconfig-nowarn)";

/*
- * If !tun, make sure ifconfig_remote_netmask looks+ * If !tun_p2p, make sure if= config_remote_netmask looks
* like a netmask.
= *
- * If tun, m= ake sure ifconfig_remote_netmask looks
+ * If tun_p2p, make sure ifconfig_remote_netmask looks
* like an IPv4 address.
*/
static void

-ifcon= fig_sanity_check(bool tun, in_addr_t addr, int topology)
+ifconfig_sanity_check(bool tun_p2p, in= _addr_t addr)
{
struct gc_arena gc = =3D gc_new();
const bool looks_like_netmask =3D ((addr= & 0xFF000000) =3D=3D 0xFF000000);
- if (tun)
+ if (tun_p2p)
{
- if (looks_like_netmask && (topo= logy =3D=3D TOP_NET30 || topology =3D=3D TOP_P2P))
+ if (looks_like_netmask)
{

msg(M_WARN, "WARNING: Sinc= e you are using --dev tun with a point-to-point topology, the second argume= nt 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_war= n_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.25= 5.255.0. %s",
ifconfig_warn_how_to_si= lence);
}
}
@= @ -667,13 +667,13 @@
struct buffer out =3D alloc_buf_g= c(256, gc);
if (tt->did_ifconfig_setup && != disable)
{
- if (tt->type =3D=3D DEV_TYPE_TAP || (tt->type =3D= =3D DEV_TYPE_TUN && tt->topology =3D=3D TOP_SUBNET))
<= span style=3D"color: hsl(120, 100%, 40%);">+ 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 =3D=3D DEV_TYPE_TUN)
+ else if (tt->type =3D=3D DEV_TYPE_TUN) /*= tun p2p topology */
{
= const char *l, *r;
if (remote)
@@ -737,24 +737,24 @@
bool
is_tun_p2p(= const struct tuntap *tt)
{
- bool tun =3D false;
+ bool tun_p2p =3D false;

if (tt->type =3D=3D DEV_TYPE_TAP
= || (tt->type =3D=3D DEV_TYPE_TUN && tt->topology =3D=3D T= OP_SUBNET)
|| tt->type =3D=3D DEV_TYPE_NULL)

{
- = tun =3D false;
+ tun_p2p =3D false;
}
el= se if (tt->type =3D=3D DEV_TYPE_TUN)
{
- tun =3D true;
+ tun_p2p =3D true;=
}
else
{ msg(M_FATAL, "Error: problem with tun vs. tap setting&= quot;); /* JYFIXME -- needs to be caught earlier, in init_tun? */
}
- return tun;
+ return tun_p2p;
}

/*
@@ -831,12 +831,10 @@

<= span> if (ifconfig_local_parm && ifconfig_remote_netmask_parm)<= /span>
{
= - bool tun =3D false;
-
/*
* We only han= dle TUN/TAP devices here, not --dev null devices.
= */
- tun =3D is= _tun_p2p(tt);
+ = bool tun_p2p =3D is_tun_p2p(tt);

= /*
* Convert arguments to binary IPv4 addresse= s.
@@ -853,7 +851,7 @@
NULL);<= /span>

tt->remote_netmask =3D getadd= r(
- (tun ? = GETADDR_RESOLVE : 0)
= + (tun_p2p ? GETADDR_RESOLVE : 0)
|= GETADDR_HOST_ORDER
| GETADDR_FATAL_ON_SIGNAL<= /span>
| GETADDR_FATAL,
@@ -868,7 +86= 6,7 @@
if (strict_warn)
{=
struct addrinfo *curele;
- ifconfig_sanity_check(tt->t= ype =3D=3D DEV_TYPE_TUN, tt->remote_netmask, tt->topology);+ ifconfig_sanity_c= heck(tun_p2p, tt->remote_netmask);

= /*
* If local_public or remote_publ= ic addresses are defined,
@@ -899,11 +897,11 @@
<= span> }

}

- if (tt->t= ype =3D=3D DEV_TYPE_TAP || (tt->type =3D=3D DEV_TYPE_TUN && tt-&= gt;topology =3D=3D TOP_SUBNET))
+ if (!tun_p2p)
{=
check_subnet_conflict(tt->local, tt->remot= e_netmask, "TUN/TAP adapter");
}
- else if (tt-&= gt;type =3D=3D DEV_TYPE_TUN)
+ else
{
= check_subnet_conflict(tt->local, IPV4_NETMASK_HOST, "= ;TUN/TAP adapter");
}
@@ = -914,7 +912,7 @@
* Make sure that both ifconfig a= ddresses are part of the
* same .252 subnet.
*/
+= if (tun_p2p)
{
= verify_255_255_255_252(tt->local, tt->remote_netmask);
tt->adapter_netmask =3D ~3;

@@ -1297,7 = +1295,7 @@
/*
* We only handle T= UN/TAP devices here, not --dev null devices.
*/
- bool tun =3D is_tun_p2p= (tt);
+ bool tun_p= 2p =3D is_tun_p2p(tt);
#endif

= #if !defined(TARGET_LINUX)
@@ -1324,7 +1322,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,
<= br> &tt->remote_netmask) < = 0)
@@ -1343,27 +1341,8 @@
#elif defined(TA= RGET_ANDROID)
char out[64];
- char *top;
- switch (tt->topology)
- {
- case TOP_NET30:
- top =3D "net30";
- break;<= br>-
- case TOP_P2P:
- top =3D "p2p";
- break;

-
- case TOP_SUBNET:
- top =3D "subnet";
- break;
-
- default:
- top =3D "undef";
- }
-
snprintf(out, sizeof(out), "%s %s %d %s= ", ifconfig_local,
- ifconfig_remote_netmask, tun_mtu, top);
+ ifconfig_remote_netmask, tu= n_mtu, print_topology(tt->topology));
management_an= droid_control(management, "IFCONFIG", out);

#elif defined(TARGET_SOLARIS)
@@ -1372,7 +135= 1,7 @@
* ifconfig tun2 10.2.0.2 10.2.0.1 mtu 1450 = up
* ifconfig tun2 netmask 255.255.255.255<= br> */
- = 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);

@@ -1386,13 +1365,13 @@
argv_printf(= &argv, "%s %s netmask 255.255.255.255", IFCONFIG_PATH,=
ifname);
}
- else if (tt->type =3D=3D DE= V_TYPE_TUN && tt->topology =3D=3D TOP_SUBNET)
+ else if (tt->type =3D=3D DEV_TY= PE_TUN)
{
argv_printf(&ar= gv, "%s %s %s %s netmask %s mtu %d up", IFCONFIG_PATH,
= ifname, ifconfig_local, ifconfig_local, ifconfig_remote_netmask, tun_mtu);
<= span> }
- else
+ else /* tap */

{
argv_printf(&argv, "= %s %s %s netmask %s up",
IFCONFIG= _PATH, ifname, ifconfig_local,
@@ -1405,7 +1384,7 @@=
solaris_error_close(tt, es, ifname, false);
}

- if (!tun && tt->type =3D=3D DEV_TYPE_TUN && t= t->topology =3D=3D TOP_SUBNET)
+ if (!tun_p2p && tt->type =3D=3D DEV_TYPE_TUN)<= /span>
{
/* Add a network route for = the local tun interface */
struct route_ipv4 r;

@@ -1429,14 +1408,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 m= tu %d netmask 255.255.255.255 up -link0",
= IFCONFIG_PATH, ifname, ifconfig_local,
= ifconfig_remote_netmask, tun_mtu);
}<= br>- else if (tt->type =3D= =3D DEV_TYPE_TUN && tt->topology =3D=3D TOP_SUBNET)
+ else if (tt->type =3D=3D = DEV_TYPE_TUN)
{
remote_end = =3D create_arbitrary_remote( tt );
argv_printf(&am= p;argv, "%s %s %s %s mtu %d netmask %s up -link0",
@@ -1444,7 +1423,7 @@
print_in_addr_= t(remote_end, 0, &gc), tun_mtu,
if= config_remote_netmask);
}
- else
+ else /* tap */
{
= argv_printf(&argv, "%s %s %s netmask %s mtu %d link0",<= /span>
IFCONFIG_PATH, ifname, ifconfig_local,=
@@ -1454,7 +1433,7 @@
openvpn_execve_= check(&argv, es, S_FATAL, "OpenBSD ifconfig failed");<= br>
/* Add a network route for the local tun in= terface */
- if (!tu= n && tt->type =3D=3D DEV_TYPE_TUN && tt->topology =3D= =3D TOP_SUBNET)
+ = if (!tun_p2p && tt->type =3D=3D DEV_TYPE_TUN)
= {
struct route_ipv4 r;
= CLEAR(r);
@@ -1468,20 +1447,20 @@
#elif d= efined(TARGET_NETBSD)
in_addr_t remote_end =3D 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 =3D=3D DEV_TY= PE_TUN && tt->topology =3D=3D TOP_SUBNET)
+ else if (tt->type =3D=3D DEV_TYPE_= TUN)
{
remote_end =3D 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, &a= mp;gc),
tun_mtu, ifconfig_remote_netma= sk);
}
- else
+ e= lse /* tap */
{
/*
= * NetBSD has distinct tun and tap devices
@= @ -1496,7 +1475,7 @@
openvpn_execve_check(&argv, e= s, S_FATAL, "NetBSD ifconfig failed");
/* Add a network route for the local tun interface */- if (!tun && tt->= ;type =3D=3D DEV_TYPE_TUN && tt->topology =3D=3D TOP_SUBNET)
+ if (!tun_p2p &&= amp; tt->type =3D=3D DEV_TYPE_TUN)
{
struct route_ipv4 r;

CLEAR(r);@@ -1520,33 +1499,30 @@

<= br> /* 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->ty= pe =3D=3D DEV_TYPE_TUN)
{
- if (tt->type =3D=3D DEV_TYPE_TUN &&= amp; tt->topology =3D=3D TOP_SUBNET)
- {
- argv_printf(&argv, "%s %s %s %s netmask %s mtu %= d up",
- = IFCONFIG_PATH, ifname, ifconfig_local, ifconfig_local,=
- ifco= nfig_remote_netmask, tun_mtu);
- }
- = else
- {

- argv_printf(= &argv, "%s %s %s netmask %s mtu %d up", IFCONFIG_PATH,=
- ifna= me, ifconfig_local, ifconfig_remote_netmask,
- tun_mtu);
- }
+ argv_printf(&argv, "%s %s %s %s n= etmask %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, &q= uot;Mac OS X ifconfig failed");

= /* Add a network route for the local tun interface */
- if (!tun && tt->type =3D=3D= DEV_TYPE_TUN && tt->topology =3D=3D TOP_SUBNET)
+ if (!tun_p2p && tt->= type =3D=3D DEV_TYPE_TUN)
{
s= truct route_ipv4 r;
CLEAR(r);
@@ -= 1560,7 +1536,7 @@
#elif defined(TARGET_FREEBSD) || defined= (TARGET_DRAGONFLY)

/* example: ifcon= fig 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, ifnam= e, ifconfig_local,
@@ -1582,7 +1558,7 @@
= struct env_set *aix_es =3D env_set_create(NULL);
= env_set_add( aix_es, "ODMDIR=3D/etc/objrepos" );
=
- if (tu= n)
+ if (tt-&g= t;type =3D=3D DEV_TYPE_TUN)
{
= msg(M_FATAL, "no tun support on AIX (canthappen)");

}

To view, visit <= a href=3D"http://gerrit.openvpn.net/c/openvpn/+/380?usp=3Demail">change 380= . To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ice8b95f953c3f7e71657a78ea12= b02a08c60aa67
Gerrit-Change-Number: 380
Gerrit-PatchSet: 9
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-MessageType: newpatchset
--PCywEWw3VqE=--