Change in openvpn[master]: Introduce env variables to communicate desired gateway redirection to...
A message that is not in the archive (sent off-list or not yet received): gerrit.1755980171000.I1e623b4a836f7216750867243299c7e4d0bd32d0@...2715...
Attention is currently required from: flichtenheld, plaisthos.
Hello plaisthos, flichtenheld,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/1156?usp=email
to review the following change.
Change subject: Introduce env variables to communicate desired gateway redirection to NM.
......................................................................
Introduce env variables to communicate desired gateway redirection to NM.
When run under Network Manager control, OpenVPN is not allowed to control routing. Instead, NM uses the OpenVPN-set environment variables ("route_network_1" etc) to set up routes as requested. This method never worked properly for "redirect-gateway", as the information was not made available in environment variables.
Introduce new env vars:
route_redirect_gateway_ipv4
route_redirect_gateway_ipv6
to communicate desired state:
<not set> = no gateway redirection desired
1 = "redirect-gateway for that protocol in question" 2 = "include block-local to redirect the local LAN as well"
We intentionally do not expose all the IPv4 flags ("local", "def1", ...) as this is really internal OpenVPN historical cruft.
---
M doc/man-sections/script-options.rst
M src/openvpn/options.c
2 files changed, 22 insertions(+), 0 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/56/1156/1
doc/man-sections/script-options.rst +8 -0
@@ -874,6 +874,14 @@ translations will be recorded rather than their names as denoted on the command line or configuration file. +:code:`route_redirect_gateway_ipv4` + +:code:`route_redirect_gateway_ipv6` + Set to `1` if the corresponding default gateway should be redirected + into the tunnel, and to `2` if also the local LAN segment should be + blocked (`block-local`). Not set otherwise. Set prior to **--up** script + execution. + :code:`script_context` Set to "init" or "restart" prior to up/down script execution. For more information, see documentation for ``--up``.
src/openvpn/options.c +14 -0
@@ -5720,6 +5720,8 @@ { options->routes_ipv6->flags =0 ; } +env_set_del (es,"route_redirect_gateway_ipv4" ); +env_set_del (es,"route_redirect_gateway_ipv6" ); }else if (streq (p[0 ],"dns" ) && !p[1 ]) {
@@ -6039,6 +6041,8 @@ { options->routes_ipv6->flags =0 ; } +env_set_del (es,"route_redirect_gateway_ipv4" ); +env_set_del (es,"route_redirect_gateway_ipv6" ); *update_options_found |=OPT_P_U_REDIR_GATEWAY ; } }
@@ -7661,6 +7665,16 @@ goto err; } } +if (options->routes->flags &RG_REROUTE_GW ) + { +setenv_int (es,"route_redirect_gateway_ipv4" , + options->routes->flags &RG_BLOCK_LOCAL ?2 :1 ); + } +if (options->routes_ipv6 && (options->routes_ipv6->flags &RG_REROUTE_GW )) + { +setenv_int (es,"route_redirect_gateway_ipv6" , + options->routes->flags &RG_BLOCK_LOCAL ?2 :1 ); + }#ifdef _WIN32/* we need this here to handle pushed --redirect-gateway */ remap_redirect_gateway_flags (options);
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1156?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I1e623b4a836f7216750867243299c7e4d0bd32d0
Gerrit-Change-Number: 1156
Gerrit-PatchSet: 1
Gerrit-Owner: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange
Attention is currently required from: cron2, flichtenheld.
plaisthos has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/1156?usp=email )
Change subject: Introduce env variables to communicate desired gateway redirection to NM.
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1156?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I1e623b4a836f7216750867243299c7e4d0bd32d0
Gerrit-Change-Number: 1156
Gerrit-PatchSet: 1
Gerrit-Owner: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Tue, 26 Aug 2025 12:54:51 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
PATCH 1/1 Introduce env variables to communicate desired gateway redirection to NM.
In reply to a message not in the archiveWhen run under Network Manager control, OpenVPN is not allowed to control routing. Instead, NM uses the OpenVPN-set environment variables ("route_network_1" etc) to set up routes as requested. This method never worked properly for "redirect-gateway", as the information was not made available in environment variables.
Introduce new env vars:
route_redirect_gateway_ipv4
route_redirect_gateway_ipv6
to communicate desired state:
<not set> = no gateway redirection desired
1 = "redirect-gateway for that protocol in question" 2 = "include block-local to redirect the local LAN as well"
We intentionally do not expose all the IPv4 flags ("local", "def1", ...) as this is really internal OpenVPN historical cruft.
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1156
This mail reflects revision 1 of this Change.
Acked-by according to Gerrit (reflected above):
Arne Schwabe <[email protected]...>
doc/man-sections/script-options.rst +8 -0
@@ -874,6 +874,14 @@ translations will be recorded rather than their names as denoted on the command line or configuration file. +:code:`route_redirect_gateway_ipv4` + +:code:`route_redirect_gateway_ipv6` + Set to `1` if the corresponding default gateway should be redirected + into the tunnel, and to `2` if also the local LAN segment should be + blocked (`block-local`). Not set otherwise. Set prior to **--up** script + execution. + :code:`script_context` Set to "init" or "restart" prior to up/down script execution. For more information, see documentation for ``--up``.
src/openvpn/options.c +14 -0
@@ -5720,6 +5720,8 @@ { options->routes_ipv6->flags =0 ; } +env_set_del (es,"route_redirect_gateway_ipv4" ); +env_set_del (es,"route_redirect_gateway_ipv6" ); }else if (streq (p[0 ],"dns" ) && !p[1 ]) {
@@ -6039,6 +6041,8 @@ { options->routes_ipv6->flags =0 ; } +env_set_del (es,"route_redirect_gateway_ipv4" ); +env_set_del (es,"route_redirect_gateway_ipv6" ); *update_options_found |=OPT_P_U_REDIR_GATEWAY ; } }
@@ -7661,6 +7665,16 @@ goto err; } } +if (options->routes->flags &RG_REROUTE_GW ) + { +setenv_int (es,"route_redirect_gateway_ipv4" , + options->routes->flags &RG_BLOCK_LOCAL ?2 :1 ); + } +if (options->routes_ipv6 && (options->routes_ipv6->flags &RG_REROUTE_GW )) + { +setenv_int (es,"route_redirect_gateway_ipv6" , + options->routes->flags &RG_BLOCK_LOCAL ?2 :1 ); + }#ifdef _WIN32/* we need this here to handle pushed --redirect-gateway */ remap_redirect_gateway_flags (options);
[Openvpn-devel] [PATCH applied] Re: Introduce env variables to communicate desired gateway redirection to NM.
Now let's see how we can communicate that to the NM folks... :-)
Patch has been applied to the master branch.
commit 1cc3525b46a3ef8b064e44b0ea33d84a39a479e9
Author: Gert Doering Date: Tue Aug 26 20:40:38 2025 +0200
Introduce env variables to communicate desired gateway redirection to NM.
Signed-off-by: Gert Doering <[email protected]...>
Acked-by: Arne Schwabe <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg32686.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
Hello flichtenheld, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1156?usp=email
to look at the new patch set (#2).
The following approvals got outdated and were removed:
Code-Review+2 by plaisthos
Change subject: Introduce env variables to communicate desired gateway redirection to NM.
......................................................................
Introduce env variables to communicate desired gateway redirection to NM.
When run under Network Manager control, OpenVPN is not allowed to control routing. Instead, NM uses the OpenVPN-set environment variables ("route_network_1" etc) to set up routes as requested. This method never worked properly for "redirect-gateway", as the information was not made available in environment variables.
Introduce new env vars:
route_redirect_gateway_ipv4
route_redirect_gateway_ipv6
to communicate desired state:
<not set> = no gateway redirection desired
1 = "redirect-gateway for that protocol in question" 2 = "include block-local to redirect the local LAN as well"
We intentionally do not expose all the IPv4 flags ("local", "def1", ...) as this is really internal OpenVPN historical cruft.
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg32686.html
---
M doc/man-sections/script-options.rst
M src/openvpn/options.c
2 files changed, 22 insertions(+), 0 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/56/1156/2
doc/man-sections/script-options.rst +8 -0
@@ -874,6 +874,14 @@ translations will be recorded rather than their names as denoted on the command line or configuration file. +:code:`route_redirect_gateway_ipv4` + +:code:`route_redirect_gateway_ipv6` + Set to `1` if the corresponding default gateway should be redirected + into the tunnel, and to `2` if also the local LAN segment should be + blocked (`block-local`). Not set otherwise. Set prior to **--up** script + execution. + :code:`script_context` Set to "init" or "restart" prior to up/down script execution. For more information, see documentation for ``--up``.
src/openvpn/options.c +14 -0
@@ -5720,6 +5720,8 @@ { options->routes_ipv6->flags =0 ; } +env_set_del (es,"route_redirect_gateway_ipv4" ); +env_set_del (es,"route_redirect_gateway_ipv6" ); }else if (streq (p[0 ],"dns" ) && !p[1 ]) {
@@ -6039,6 +6041,8 @@ { options->routes_ipv6->flags =0 ; } +env_set_del (es,"route_redirect_gateway_ipv4" ); +env_set_del (es,"route_redirect_gateway_ipv6" ); *update_options_found |=OPT_P_U_REDIR_GATEWAY ; } }
@@ -7661,6 +7665,16 @@ goto err; } } +if (options->routes->flags &RG_REROUTE_GW ) + { +setenv_int (es,"route_redirect_gateway_ipv4" , + options->routes->flags &RG_BLOCK_LOCAL ?2 :1 ); + } +if (options->routes_ipv6 && (options->routes_ipv6->flags &RG_REROUTE_GW )) + { +setenv_int (es,"route_redirect_gateway_ipv6" , + options->routes->flags &RG_BLOCK_LOCAL ?2 :1 ); + }#ifdef _WIN32/* we need this here to handle pushed --redirect-gateway */ remap_redirect_gateway_flags (options);
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1156?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I1e623b4a836f7216750867243299c7e4d0bd32d0
Gerrit-Change-Number: 1156
Gerrit-PatchSet: 2
Gerrit-Owner: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1156?usp=email )
Change subject: Introduce env variables to communicate desired gateway redirection to NM.
......................................................................
Introduce env variables to communicate desired gateway redirection to NM.
When run under Network Manager control, OpenVPN is not allowed to control routing. Instead, NM uses the OpenVPN-set environment variables ("route_network_1" etc) to set up routes as requested. This method never worked properly for "redirect-gateway", as the information was not made available in environment variables.
Introduce new env vars:
route_redirect_gateway_ipv4
route_redirect_gateway_ipv6
to communicate desired state:
<not set> = no gateway redirection desired
1 = "redirect-gateway for that protocol in question" 2 = "include block-local to redirect the local LAN as well"
We intentionally do not expose all the IPv4 flags ("local", "def1", ...) as this is really internal OpenVPN historical cruft.
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg32686.html
---
M doc/man-sections/script-options.rst
M src/openvpn/options.c
2 files changed, 22 insertions(+), 0 deletions(-)
doc/man-sections/script-options.rst +8 -0
@@ -874,6 +874,14 @@ translations will be recorded rather than their names as denoted on the command line or configuration file. +:code:`route_redirect_gateway_ipv4` + +:code:`route_redirect_gateway_ipv6` + Set to `1` if the corresponding default gateway should be redirected + into the tunnel, and to `2` if also the local LAN segment should be + blocked (`block-local`). Not set otherwise. Set prior to **--up** script + execution. + :code:`script_context` Set to "init" or "restart" prior to up/down script execution. For more information, see documentation for ``--up``.
src/openvpn/options.c +14 -0
@@ -5720,6 +5720,8 @@ { options->routes_ipv6->flags =0 ; } +env_set_del (es,"route_redirect_gateway_ipv4" ); +env_set_del (es,"route_redirect_gateway_ipv6" ); }else if (streq (p[0 ],"dns" ) && !p[1 ]) {
@@ -6039,6 +6041,8 @@ { options->routes_ipv6->flags =0 ; } +env_set_del (es,"route_redirect_gateway_ipv4" ); +env_set_del (es,"route_redirect_gateway_ipv6" ); *update_options_found |=OPT_P_U_REDIR_GATEWAY ; } }
@@ -7661,6 +7665,16 @@ goto err; } } +if (options->routes->flags &RG_REROUTE_GW ) + { +setenv_int (es,"route_redirect_gateway_ipv4" , + options->routes->flags &RG_BLOCK_LOCAL ?2 :1 ); + } +if (options->routes_ipv6 && (options->routes_ipv6->flags &RG_REROUTE_GW )) + { +setenv_int (es,"route_redirect_gateway_ipv6" , + options->routes->flags &RG_BLOCK_LOCAL ?2 :1 ); + }#ifdef _WIN32/* we need this here to handle pushed --redirect-gateway */ remap_redirect_gateway_flags (options);
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1156?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I1e623b4a836f7216750867243299c7e4d0bd32d0
Gerrit-Change-Number: 1156
Gerrit-PatchSet: 2
Gerrit-Owner: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged