Skip to content

Commit 4ad3aa5

Browse files
itsGiaancron2
authored andcommitted
Route: remove incorrect routes on exit
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 <[email protected]> Acked-by: Frank Lichtenheld <[email protected]> Message-Id: <[email protected]> URL: https://www.mail-archive.com/[email protected]/msg28290.html Signed-off-by: Gert Doering <[email protected]> (cherry picked from commit 14d2db6)
1 parent 7e6723a commit 4ad3aa5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/openvpn/route.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,10 @@ redirect_default_route_to_vpn(struct route_list *rl, const struct tuntap *tt,
10531053
ret = add_route3(rl->spec.remote_host, IPV4_NETMASK_HOST,
10541054
rl->rgi.gateway.addr, tt, flags | ROUTE_REF_GW,
10551055
&rl->rgi, es, ctx);
1056-
rl->iflags |= RL_DID_LOCAL;
1056+
if (ret)
1057+
{
1058+
rl->iflags |= RL_DID_LOCAL;
1059+
}
10571060
}
10581061
else
10591062
{

0 commit comments

Comments
 (0)