From: "cron2 (Code Review)" Date: Wed, 1 May 2024 20:13:10 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <59df77c56417ff628031c26f35ede0bc5045f56e-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="1fTnk+iAkfM="; charset=UTF-8 Subject: [Openvpn-devel] [M] Change in openvpn[master]: Use topology default of "subnet" only for server mode List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld , plaisthos Cc: openvpn-devel --1fTnk+iAkfM= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#2) to the change originally created by= flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/554?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by plaisthos Change subject: Use topology default of "subnet" only for server mode ...................................................................... Use topology default of "subnet" only for server mode The setting of --topology changes the syntax of --ifconfig. So changing the default of --topology breaks all existing configs that use --ifconfig but not --topology. For P2P setups that is probably a signification percentage. For server setups the percentage is hopefully lower since --ifconfig is implicitly set by --server. Also more people might have set their topology explicitly since it makes a much bigger difference. Clients will usually get the topology and the IP config pushed by the server. So we decided to not switch the default for everyone to not affect P2P setups. What we care about is to change the default for --mode server, so we only do that now. For people using --server this should be transparent except for a pool reset. Github: Openvpn/openvpn#529 Change-Id: Iefd209c0856ef395ab74055496130de00b86ead0 Signed-off-by: Frank Lichtenheld Acked-by: Arne Schwabe Message-Id: <20240501124254.29114-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg28= 592.html Signed-off-by: Gert Doering --- M Changes.rst M src/openvpn/helper.c M src/openvpn/helper.h M src/openvpn/options.c 4 files changed, 49 insertions(+), 16 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/54/554/2 diff --git a/Changes.rst b/Changes.rst index b2278ab..fa0fb22 100644 --- a/Changes.rst +++ b/Changes.rst @@ -23,11 +23,12 @@ ``persist-key`` option has been enabled by default. All the keys will be kept in memory across restart. -Default for ``--topology`` changed to ``subnet`` - Previous releases used ``net30`` as default. This only affects - configs with ``--dev tun`` and only IPv4. Note that this - changes the semantics of ``--ifconfig``, so if you have manual - settings for that in your config but not set ``--topology`` +Default for ``--topology`` changed to ``subnet`` for ``--mode server`` + Previous releases always used ``net30`` as default. This only affects + configs with ``--mode server`` or ``--server`` (the latter implies the + former), and ``--dev tun``, and only if IPv4 is enabled. + Note that this changes the semantics of ``--ifconfig``, so if you have + manual settings for that in your config but not set ``--topology`` your config might fail to parse with the new version. Just adding ``--topology net30`` to the config should fix the problem. By default ``--topology`` is pushed from server to client. diff --git a/src/openvpn/helper.c b/src/openvpn/helper.c index 1bab84c..5681718 100644 --- a/src/openvpn/helper.c +++ b/src/openvpn/helper.c @@ -137,6 +137,32 @@ } +/** + * Set --topology default depending on --mode + */ +void +helper_setdefault_topology(struct options *o) +{ + if (o->topology !=3D TOP_UNDEF) + { + return; + } + int dev =3D dev_type_enum(o->dev, o->dev_type); + if (dev !=3D DEV_TYPE_TUN) + { + return; + } + if (o->mode =3D=3D MODE_SERVER) + { + o->topology =3D TOP_SUBNET; + } + else + { + o->topology =3D TOP_NET30; + } +} + + /* * Process server, server-bridge, and client helper * directives after the parameters themselves have been @@ -151,7 +177,6 @@ * Get tun/tap/null device type */ const int dev =3D dev_type_enum(o->dev, o->dev_type); - const int topology =3D o->topology; /* * @@ -177,11 +202,11 @@ if (o->server_flags & SF_NOPOOL) { - msg( M_USAGE, "--server-ipv6 is incompatible with 'nopool' opt= ion" ); + msg(M_USAGE, "--server-ipv6 is incompatible with 'nopool' opti= on"); } if (o->ifconfig_ipv6_pool_defined) { - msg( M_USAGE, "--server-ipv6 already defines an ifconfig-ipv6-= pool, so you can't also specify --ifconfig-pool explicitly"); + msg(M_USAGE, "--server-ipv6 already defines an ifconfig-ipv6-p= ool, so you can't also specify --ifconfig-pool explicitly"); } o->mode =3D MODE_SERVER; @@ -207,7 +232,7 @@ o->server_netbits_ipv6 <= 112 ? 0x1000 : 2); o->ifconfig_ipv6_pool_netbits =3D o->server_netbits_ipv6; - push_option( o, "tun-ipv6", M_USAGE ); + push_option(o, "tun-ipv6", M_USAGE); } /* @@ -305,8 +330,10 @@ o->mode =3D MODE_SERVER; o->tls_server =3D true; + /* Need to know topology now */ + helper_setdefault_topology(o); - if (topology =3D=3D TOP_NET30 || topology =3D=3D TOP_P2P) + if (o->topology =3D=3D TOP_NET30 || o->topology =3D=3D TOP_P2P) { o->ifconfig_local =3D print_in_addr_t(o->server_network + = 1, 0, &o->gc); o->ifconfig_remote_netmask =3D print_in_addr_t(o->server_n= etwork + 2, 0, &o->gc); @@ -324,12 +351,12 @@ { push_option(o, print_opt_route(o->server_network, o->s= erver_netmask, &o->gc), M_USAGE); } - else if (topology =3D=3D TOP_NET30) + else if (o->topology =3D=3D TOP_NET30) { push_option(o, print_opt_route(o->server_network + 1, = 0, &o->gc), M_USAGE); } } - else if (topology =3D=3D TOP_SUBNET) + else if (o->topology =3D=3D TOP_SUBNET) { o->ifconfig_local =3D print_in_addr_t(o->server_network + = 1, 0, &o->gc); o->ifconfig_remote_netmask =3D print_in_addr_t(o->server_n= etmask, 0, &o->gc); @@ -354,9 +381,9 @@ ASSERT(0); } =20 - push_option(o, print_opt_topology(topology, &o->gc), M_USAGE); + push_option(o, print_opt_topology(o->topology, &o->gc), M_USAG= E); - if (topology =3D=3D TOP_NET30 && !(o->server_flags & SF_NOPOOL= )) + if (o->topology =3D=3D TOP_NET30 && !(o->server_flags & SF_NOP= OOL)) { msg(M_WARN, "WARNING: --topology net30 support for server " "configs with IPv4 pools will be removed in a future " @@ -394,7 +421,7 @@ } /* set push-ifconfig-constraint directive */ - if ((dev =3D=3D DEV_TYPE_TAP || topology =3D=3D TOP_SUBNET)) + if ((dev =3D=3D DEV_TYPE_TAP || o->topology =3D=3D TOP_SUBNET)) { o->push_ifconfig_constraint_defined =3D true; o->push_ifconfig_constraint_network =3D o->server_network; diff --git a/src/openvpn/helper.h b/src/openvpn/helper.h index d0fd17d..6b42e13 100644 --- a/src/openvpn/helper.h +++ b/src/openvpn/helper.h @@ -30,6 +30,8 @@ #include "options.h" +void helper_setdefault_topology(struct options *o); + void helper_keepalive(struct options *o); void helper_client_server(struct options *o); diff --git a/src/openvpn/options.c b/src/openvpn/options.c index e2bfe0e..07387cd 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -796,7 +796,7 @@ o->gc_owned =3D true; } o->mode =3D MODE_POINT_TO_POINT; - o->topology =3D TOP_SUBNET; + o->topology =3D TOP_UNDEF; o->ce.proto =3D PROTO_UDP; o->ce.af =3D AF_UNSPEC; o->ce.bind_ipv6_only =3D false; @@ -3478,6 +3478,7 @@ } } + /** * Checks for availibility of Chacha20-Poly1305 and sets * the ncp_cipher to either AES-256-GCM:AES-128-GCM or @@ -3680,6 +3681,8 @@ * sequences of options. */ helper_client_server(o); + /* must be called after helpers that might set --mode */ + helper_setdefault_topology(o); helper_keepalive(o); helper_tcp_nodelay(o); -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/554?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: Iefd209c0856ef395ab74055496130de00b86ead0 Gerrit-Change-Number: 554 Gerrit-PatchSet: 2 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-MessageType: newpatchset --1fTnk+iAkfM= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

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

View Change

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

Use topology default of "subnet" only =
for server mode

The setting of --topology changes the syntax of --if= config.
So changing the default of --topology breaks all existing
con= figs that use --ifconfig but not --topology.

For P2P setups that is = probably a signification percentage.
For server setups the percentage is= hopefully lower since
--ifconfig is implicitly set by --server. Also mo= re people
might have set their topology explicitly since it makes a
m= uch bigger difference. Clients will usually get the
topology and the IP = config pushed by the server.

So we decided to not switch the default= for everyone to
not affect P2P setups. What we care about is to change<= br>the default for --mode server, so we only do that now. For
people usi= ng --server this should be transparent except
for a pool reset.

G= ithub: Openvpn/openvpn#529
Change-Id: Iefd209c0856ef395ab74055496130de00= b86ead0
Signed-off-by: Frank Lichtenheld <frank@...2641...>
Ack= ed-by: Arne Schwabe <arne-openvpn@...1227...>
Message-Id: <2024= 0501124254.29114-1-gert@...1296...>
URL: https://www.mail-archive.com= /openvpn-devel@lists.sourceforge.net/msg28592.html
Signed-off-by: Gert D= oering <gert@...1296...>
---
M Changes.rst
M src/openvpn/hel= per.c
M src/openvpn/helper.h
M src/openvpn/options.c
4 files chang= ed, 49 insertions(+), 16 deletions(-)

git pull ssh://gerrit.openv=
pn.net:29418/openvpn refs/changes/54/554/2
diff --git a/Changes.rst=
 b/Changes.rst
index b2278ab..fa0fb22 100644
--- a/Changes.rst
+++ b/Changes.rst
@@ -2= 3,11 +23,12 @@
``persist-key`` option has been enabled by = default.
All the keys will be kept in memory across re= start.

- Previous releases used ``net30`` as def= ault. This only affects
- configs with ``--dev tun`` and only IPv4. Note that this
- changes the semantics of ``--i= fconfig``, so if you have manual
- settings for that in your config but not set ``--topology``<= /span>
+Default for ``--topo= logy`` changed to ``subnet`` for ``--mode server``
+ Previous releases always used ``net30`` = as default. This only affects
+ configs with ``--mode server`` or ``--server`` (the latter im= plies the
+ former= ), and ``--dev tun``, and only if IPv4 is enabled.
+ Note that this changes the semantics of = ``--ifconfig``, so if you have
+ manual settings for that in your config but not set ``--topo= logy``
your config might fail to parse with the new ve= rsion. Just adding
``--topology net30`` to the config = should fix the problem.
By default ``--topology`` is p= ushed from server to client.
diff --git a/src/openvpn/helpe= r.c b/src/openvpn/helper.c
index 1bab84c..5681718 100644

--- a/src/openvpn/helper.c
+++ b/src/openvpn/= helper.c
@@ -137,6 +137,32 @@
}
=

+/**
+ * Set --t= opology default depending on --mode
+ */
+= void
+helper_setdefau= lt_topology(struct options *o)
+{
+ if = (o->topology !=3D TOP_UNDEF)
+ {
+ = return;
+ }<= /span>
+ int dev =3D dev_= type_enum(o->dev, o->dev_type);
+ if (dev !=3D DEV_TYPE_TUN)
+ {
+ return;
+ }
+ = if (o->mode =3D=3D MODE_SERVER)
+ {
+ o->topology =3D TOP_SUBNET;
+ }
+ else
+ = {
+ o->topo= logy =3D TOP_NET30;
+= }
+}
+

+
/*
* Process se= rver, server-bridge, and client helper
* directives after= the parameters themselves have been
@@ -151,7 +177,6 @@
* Get tun/tap/null device type
*/=
const int dev =3D dev_type_enum(o->dev, o->dev_= type);
- const int t= opology =3D o->topology;

/*
*
@@ -177,11 +202,11 @@
<= /span>
if (o->server_flags & SF_NOPOOL)
= {
- = msg( M_USAGE, "--server-ipv6 is incompatible with 'nopool&#= 39; option" );
+= msg(M_USAGE, "--server-ipv6 is incompatible with 'nopo= ol' option");
}
= if (o->ifconfig_ipv6_pool_defined)
{
= - msg( M_USAGE, "= --server-ipv6 already defines an ifconfig-ipv6-pool, so you can't also = specify --ifconfig-pool explicitly");
+ msg(M_USAGE, "--server-ipv6 already= defines an ifconfig-ipv6-pool, so you can't also specify --ifconfig-po= ol explicitly");
}
o->mode =3D MODE_SERVER;
@@ -207,7 +232= ,7 @@
o-= >server_netbits_ipv6 < 112 ? 0x1000 : 2);
o-= >ifconfig_ipv6_pool_netbits =3D o->server_netbits_ipv6;

- push_opti= on( o, "tun-ipv6", M_USAGE );
+ push_option(o, "tun-ipv6", M_USAGE);<= /span>
}

/*
= @@ -305,8 +330,10 @@

o= ->mode =3D MODE_SERVER;
o->tls_server = =3D true;
+ = /* Need to know topology now */
+ helper_setdefault_topology(o);
<= /span>
- if (topolo= gy =3D=3D TOP_NET30 || topology =3D=3D TOP_P2P)
+ if (o->topology =3D=3D TOP_NET30= || o->topology =3D=3D TOP_P2P)
{ o->ifconfig_local =3D print_in_addr_t(o->serv= er_network + 1, 0, &o->gc);
o->i= fconfig_remote_netmask =3D print_in_addr_t(o->server_network + 2, 0, &am= p;o->gc);
@@ -324,12 +351,12 @@
= {
push_option(o, print_opt_ro= ute(o->server_network, o->server_netmask, &o->gc), M_USAGE);
}
- else if (topology =3D=3D TOP_NET30)
<= span style=3D"color: hsl(120, 100%, 40%);">+ else if (o->= topology =3D=3D TOP_NET30)

{
push_option(o, print_opt_route(o->server_network= + 1, 0, &o->gc), M_USAGE);

}
}
- else if (topology =3D=3D TOP_SUBNET)
+ else if (o->topology =3D= =3D TOP_SUBNET)
{
= o->ifconfig_local =3D print_in_addr_t(o->server_network + 1, 0, = &o->gc);
o->ifconfig_remote_netm= ask =3D print_in_addr_t(o->server_netmask, 0, &o->gc);
= @@ -354,9 +381,9 @@
ASSERT(0);
}

- push_option(o, print_opt_topology(topolog= y, &o->gc), M_USAGE);
+ push_option(o, print_opt_topology(o->topology, &= ;o->gc), M_USAGE);

- if (topology =3D=3D TOP_NET30 && !(o-= >server_flags & SF_NOPOOL))
+ if (o->topology =3D=3D TOP_NET30 && != (o->server_flags & SF_NOPOOL))
{=
msg(M_WARN, "WARNING: --topology net30 supp= ort for server "
"configs wi= th IPv4 pools will be removed in a future "
@@ -394,7 = +421,7 @@
}

= /* set push-ifconfig-constraint directive */
- if ((dev =3D=3D DEV_TYPE_TAP || topolog= y =3D=3D TOP_SUBNET))
+ if ((dev =3D=3D DEV_TYPE_TAP || o->topology =3D=3D TOP_SUBNET)= )
{
o->push_ifconf= ig_constraint_defined =3D true;
o->push_ifc= onfig_constraint_network =3D o->server_network;
diff --g= it a/src/openvpn/helper.h b/src/openvpn/helper.h
index d0fd= 17d..6b42e13 100644
--- a/src/openvpn/helper.h
+++ b/src/openvpn/helper.h

@@ -30,6 +30,8 @@
=
#include "options.h"

+void helper_setdefaul= t_topology(struct options *o);
+
void helper_keepalive(struct options *o);


void helper_client_server(struct options *o)= ;
diff --git a/src/openvpn/options.c b/src/openvpn/options.= c
index e2bfe0e..07387cd 100644
--- a/src/o= penvpn/options.c
+++ b/src/openvpn/options.c
@@ -796,7 +796,7 @@
o->gc_owned =3D true;
}
o->mode =3D MODE_POINT_TO_POINT= ;
- o->topology = =3D TOP_SUBNET;
+ = o->topology =3D TOP_UNDEF;
o->ce.proto =3D PROTO= _UDP;
o->ce.af =3D AF_UNSPEC;
= o->ce.bind_ipv6_only =3D false;
@@ -3478,6 +3478,7 @@
}
}

+
/**
* Checks for availibility of Chacha20-Poly1305 and sets

= * the ncp_cipher to either AES-256-GCM:AES-128-GCM or
@@ = -3680,6 +3681,8 @@
* sequences of options.
= */
helper_client_server(o);
+ /* must be called after helper= s that might set --mode */

+ helper_setdefault_topology(o);
helper_keepa= live(o);
helper_tcp_nodelay(o);


To view, visit change 554. To unsubscribe, or fo= r help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Iefd209c0856ef395ab740554961= 30de00b86ead0
Gerrit-Change-Number: 554
Gerrit-PatchSet: 2
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
--1fTnk+iAkfM=--