[Openvpn-devel] Also restore/save route-gatreway options in reconnects

Message ID 20210416133512.1176870-1-arne@rfc2549.org
State Accepted
Headers show
Series
  • [Openvpn-devel] Also restore/save route-gatreway options in reconnects
Related show

Commit Message

Arne Schwabe April 16, 2021, 1:35 p.m.
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
---
 src/openvpn/options.c | 6 ++++++
 src/openvpn/options.h | 3 +++
 2 files changed, 9 insertions(+)

Comments

Gert Doering April 17, 2021, 9:47 a.m. | #1
Acked-by: Gert Doering <gert@greenie.muc.de>

Stared-at-code (looks good) and subjected to the test rig that breaks
(server with topology subnet, pushing route-gateway, SIGUSR1, advance
to server that uses top net30, stuck route-gateway breaks route 
installation).  Good :-)

Backport to 2.5 was fairly trivial (rename pre_connect to pre_pull
and adjust indent) - tested there as well, fixes that as well.

Your patch has been applied to the master branch and release/2.5.

commit 57c8d220aab14b661bafd4fafc40c195326b8d8f (master)
commit 7b594d4980f696583397a3b87e5c928acba17081 (release/2.5)
Author: Arne Schwabe
Date:   Fri Apr 16 15:35:12 2021 +0200

     Also restore/save route-gateway options on SIGUSR1 reconnects

     Signed-off-by: Arne Schwabe <arne@rfc2549.org>
     Acked-by: Gert Doering <gert@greenie.muc.de>
     Message-Id: <20210416133512.1176870-1-arne@rfc2549.org>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22132.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/src/openvpn/options.c b/src/openvpn/options.c
index 5934b0b84..10078a4d6 100644
--- a/src/openvpn/options.c
+++ b/src/openvpn/options.c
@@ -3571,6 +3571,9 @@  pre_connect_save(struct options *o)
         o->pre_connect->client_nat_defined = true;
     }
 
+    o->pre_connect->route_default_gateway = o->route_default_gateway;
+    o->pre_connect->route_ipv6_default_gateway = o->route_ipv6_default_gateway;
+
     /* NCP related options that can be overwritten by a push */
     o->pre_connect->ciphername = o->ciphername;
     o->pre_connect->authname = o->authname;
@@ -3619,6 +3622,9 @@  pre_connect_restore(struct options *o, struct gc_arena *gc)
             o->routes_ipv6 = NULL;
         }
 
+        o->route_default_gateway = pp->route_default_gateway;
+        o->route_ipv6_default_gateway = pp->route_ipv6_default_gateway;
+
         if (pp->client_nat_defined)
         {
             cnol_check_alloc(o);
diff --git a/src/openvpn/options.h b/src/openvpn/options.h
index ee3fd7e50..ef59f0a99 100644
--- a/src/openvpn/options.h
+++ b/src/openvpn/options.h
@@ -70,6 +70,9 @@  struct options_pre_connect
     bool routes_ipv6_defined;
     struct route_ipv6_option_list *routes_ipv6;
 
+    const char *route_default_gateway;
+    const char *route_ipv6_default_gateway;
+
     bool client_nat_defined;
     struct client_nat_option_list *client_nat;