Skip to content

Commit 75ba07d

Browse files
mrbffcron2
authored andcommitted
get_default_gateway(): Prevent passing IPV4_INVALID_ADDR as a destination
When using --redirect-gateway (IPv4) while connected to an IPv6 remote, OpenVPN still attempts to determine the IPv4 default gateway, so link_socket_current_remote() returns IPV4_INVALID_ADDR (0xffffffff) as the destination, leading to unintended behavior: - the IPv4 default gateway (rl->rgi.gateway.addr) gets wiped. - this prevents proper restoration of the original route when needed. To fix this, if link_socket_current_remote() returns IPV4_INVALID_ADDR, we now pass INADDR_ANY (0x00000000) to get_default_gateway(), ensuring the function behaves correctly. Change-Id: I02afe6817433ca21aae76671c35151ec6a066933 Signed-off-by: Marco Baffo <[email protected]> Acked-by: Gert Doering <[email protected]> Message-Id: <[email protected]> URL: https://www.mail-archive.com/[email protected]/msg30895.html Signed-off-by: Gert Doering <[email protected]>
1 parent 6e16dc6 commit 75ba07d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/openvpn/route.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ init_route_list(struct route_list *rl,
655655
rl->spec.flags |= RTSA_DEFAULT_METRIC;
656656
}
657657

658-
get_default_gateway(&rl->rgi, remote_host, ctx);
658+
get_default_gateway(&rl->rgi, remote_host != IPV4_INVALID_ADDR ? remote_host : INADDR_ANY, ctx);
659659
if (rl->rgi.flags & RGI_ADDR_DEFINED)
660660
{
661661
setenv_route_addr(es, "net_gateway", rl->rgi.gateway.addr, -1);

0 commit comments

Comments
 (0)