]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Route: remove incorrect routes on exit
authorGianmarco De Gregori <gianmarco@mandelbit.com>
Wed, 21 Feb 2024 11:18:14 +0000 (12:18 +0100)
committerGert Doering <gert@greenie.muc.de>
Tue, 17 Sep 2024 10:36:19 +0000 (12:36 +0200)
Implemented a safeguard to verify the returned value
from add_route3() when the default gateway is not a local
remote host.

Prior to this implementation, RT_DID_LOCAL flag was
erroneously set even in case of add_route3() failure.
This problem typically occurs when there's no default
route and the --redirect-gateway def1 option is specified,
and in case of reconnection makes it impossible for the client
to reobtain the route to the server.
This fix ensures OpenVPN accurately deletes the appropriate
route on exit by properly handling add_route3() return value.

Trac: #1457
Change-Id: I8a67b82eb4afdc8d82c5a879c18457b41e77cbe7
Signed-off-by: Gianmarco De Gregori <gianmarco@mandelbit.com>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20240221111814.942965-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg28290.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 14d2db6cd41fb6414992869caf109972d7a8275e)

src/openvpn/route.c

index a5832ff5cae68682ae1e171c14803eec31a057dd..66540dbda8c7cb52cb6fa37c5b1afcd253770b08 100644 (file)
@@ -1053,7 +1053,10 @@ redirect_default_route_to_vpn(struct route_list *rl, const struct tuntap *tt,
                     ret = add_route3(rl->spec.remote_host, IPV4_NETMASK_HOST,
                                      rl->rgi.gateway.addr, tt, flags | ROUTE_REF_GW,
                                      &rl->rgi, es, ctx);
-                    rl->iflags |= RL_DID_LOCAL;
+                    if (ret)
+                    {
+                        rl->iflags |= RL_DID_LOCAL;
+                    }
                 }
                 else
                 {