Browse code

Preserve ifconfig(_ipv6)_local across reconnect

Turns out that ifconfig_(ipv6)_local options are set once
and are not reset on a reconnect.

Consider following scenario:

- connect first time, server pushes ifconfig-ipv6
- add a ipv6 network route because ifconfig_ipv6_local is set
- reconnect, server doesn't push ifconfig-ipv6

Because of ifconfig_ipv6_local is not reset and holds the value
set by the first connect, client adds a ipv6 network route -
but this is wrong, since ipv6 wasn't pushed this time by the server.

Fix by saving/restoring ifconfig(_ipv6)_local in a
struct options_pre_connect along with other options which
preserves the initial values until --pull modifications
are applied.

Github: OpenVPN/openvpn#850
Change-Id: I9b099924286f9bccb6833e1e40606abe72714bbb
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1248
Message-Id: <20251009171916.12811-1-gert@greenie.muc.de>
URL: https://sourceforge.net/p/openvpn/mailman/message/59244523/
Signed-off-by: Gert Doering <gert@greenie.muc.de>

Lev Stipakov authored on 2025/10/10 02:19:11
Showing 2 changed files
... ...
@@ -3143,6 +3143,9 @@ pre_connect_save(struct options *o)
3143 3143
         o->pre_connect->client_nat_defined = true;
3144 3144
     }
3145 3145
 
3146
+    o->pre_connect->ifconfig_local = o->ifconfig_local;
3147
+    o->pre_connect->ifconfig_ipv6_local = o->ifconfig_ipv6_local;
3148
+
3146 3149
     o->pre_connect->route_default_gateway = o->route_default_gateway;
3147 3150
     o->pre_connect->route_ipv6_default_gateway = o->route_ipv6_default_gateway;
3148 3151
 
... ...
@@ -3193,6 +3196,9 @@ pre_connect_restore(struct options *o, struct gc_arena *gc)
3193 3193
             o->routes_ipv6 = NULL;
3194 3194
         }
3195 3195
 
3196
+        o->ifconfig_local = pp->ifconfig_local;
3197
+        o->ifconfig_ipv6_local = pp->ifconfig_ipv6_local;
3198
+
3196 3199
         o->route_default_gateway = pp->route_default_gateway;
3197 3200
         o->route_ipv6_default_gateway = pp->route_ipv6_default_gateway;
3198 3201
 
... ...
@@ -64,6 +64,9 @@ struct options_pre_connect
64 64
     bool tuntap_options_defined;
65 65
     struct tuntap_options tuntap_options;
66 66
 
67
+    const char *ifconfig_local;
68
+    const char *ifconfig_ipv6_local;
69
+
67 70
     bool routes_defined;
68 71
     struct route_option_list *routes;
69 72