OpenVPN 2.1.4/Linux: route-gatewy not working
Hi list,
I've been struggling with OpenVPN bridge mode an entire day before going down to the source code:
The documentation (man page) says that the server-bridge configuration directive expands to more directives, including a "route-gateway" push. The push is actually done and is received on client side, but does nothing, i.e no default route is added on the client.
I've tracked down the issue in the source code and it seems that this option as no effect when no route list have been created:do_open_tun() only calls do_init_route_list if c->options.routes has been initialized. This seems to be done by rol_check_alloc() in add_option during option parsing. This is done only for the "redirect-gateway" gateway option and never for "route-gateway", resulting in this option being a no-op.
I've also tried (client-side and server-side) to use dummy routes(the route that would be automatically added upon tap creation) to make OpenVPN to create a route list without more success.
I don't know if this is the desired behavior or if I'm missing something here, but at least the documentation should be more clear on this feature.
Below is a patch that fix what I find broken.
----
Author: Samuel CUELLA <[email protected]...>
Fix the route-gateway option behavior.
----
options.c 2012-03-23 13:20:08.000000000 +0100 renamed from /options.c 2010-11-04 20:29:02.000000000 +0100 +2 -0
@@ -4561,6 +4561,8 @@ else if (streq (p[0], "route-gateway") && p[1]) { VERIFY_PERMISSION (OPT_P_ROUTE_EXTRAS); + rol_check_alloc (options); + if (streq (p[1], "dhcp")) { options->route_gateway_via_dhcp = true;
@@ -4570,6 +4572,7 @@ if (ip_or_dns_addr_safe (p[1], options->allow_pull_fqdn) ||
is_special_addr (p[1])) /* FQDN -- may be DNS name */
{
options->route_default_gateway = p[1];
+ options->routes->flags |= (RG_ENABLE|RG_REROUTE_GW);
}
else
{-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 19 lines · Samuel CUELLA
Hi list,
I've been struggling with OpenVPN bridge mode an entire day before going down to the source code:
The documentation (man page) says that the server-bridge configuration directive expands to more directives, including a "route-gateway" push. The push is actually done and is received on client side, but does nothing, i.e no default route is added on the client.
I've tracked down the issue in the source code and it seems that this option as no effect when no route list have been created:
do_open_tun()only callsdo_init_route_listifc->options.routeshas been initialized. This seems to be done byrol_check_alloc()inadd_optionduring option parsing. This is done only for the "redirect-gateway" gateway option and never for "route-gateway", resulting in this option being a no-op.
Quoted 7 lines
I've also tried (client-side and server-side) to use dummy routes(the route that would be automatically added upon tap creation) to make OpenVPN to create a route list without more success.
I don't know if this is the desired behavior or if I'm missing something here, but at least the documentation should be more clear on this feature.
Hi Samuel,
Interesting finding you've found here. However, we're not developing the 2.1 branch any more. So if you could try the latest git master branch [1], that'd be great ... And if that still fails, try to apply your patch to see if that improves it.
There has been some fixes to the whole routing part in 2.2 and 2.3, so we need to be sure we're not fixing something which is fixed in a different way.
kind regards,
David Sommerseth
[1]
<https://community.openvpn.net/openvpn/wiki/DeveloperDocumentation#Coderepositories>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk9sifIACgkQDC186MBRfroZgQCfRTJQCONz6O5C+AVzSibOktTF YbAAnA1zpAIXx1SesGU0a4cxbd3tmQ31
=e1YT
-----END PGP SIGNATURE-----
Quoted 11 lines · David Sommerseth
Hi Samuel,
Interesting finding you've found here. However, we're not developing the 2.1 branch any more. So if you could try the latest git master branch [1], that'd be great ... And if that still fails, try to apply your patch to see if that improves it.
There has been some fixes to the whole routing part in 2.2 and 2.3, so we need to be sure we're not fixing something which is fixed in a different way.
I've just tested with the git master: same problem with the exact same cause.
My patch just create an empty route list and set appropriate flags, just like "redirect-gateway". I've also noted that redirect_default_route_to_vpn() will only apply the pushed default route if a default route already exist on the client.
If there is no default route, the pushed default route won't be applied. Is that an expected/desired behavior ?
Here is the patch against the latest git master:
----
Author: Samuel CUELLA <[email protected]...>
Fix the route-gateway option behavior.
----
options.c 2012-03-23 17:29:33.000000000 +0100 renamed from options.c 2012-03-23 15:59:29.000000000 +0100 +1 -0
@@ -5218,6 +5218,7 @@ else if (streq (p[0], "route-gateway") && p[1]) { VERIFY_PERMISSION (OPT_P_ROUTE_EXTRAS); + rol_check_alloc (options); if (streq (p[1], "dhcp")) { options->route_gateway_via_dhcp = true;
@@ -5227,6 +5228,7 @@ if (ip_or_dns_addr_safe (p[1], options->allow_pull_fqdn) ||
is_special_addr (p[1])) /* FQDN -- may be DNS name */
{
options->route_default_gateway = p[1];
+ options->routes->flags |= (RG_ENABLE|RG_REROUTE_GW);
}
else
{Quoted 11 lines · David Sommerseth
Hi Samuel,
Interesting finding you've found here. However, we're not developing the 2.1 branch any more. So if you could try the latest git master branch [1], that'd be great ... And if that still fails, try to apply your patch to see if that improves it.
There has been some fixes to the whole routing part in 2.2 and 2.3, so we need to be sure we're not fixing something which is fixed in a different way.
I've just tested with the git master: same problem with the exact same cause.
My patch just create an empty route list and set appropriate flags, just like "redirect-gateway". I've also noted that redirect_default_route_to_vpn() will only apply the pushed default route if a default route already exist on the client.
If there is no default route, the pushed default route won't be applied. Is that an expected/desired behavior ?
Here is the patch against the latest git master:
----
Author: Samuel CUELLA <[email protected]...>
Fix the route-gateway option behavior.
----
options.c 2012-03-23 17:29:33.000000000 +0100 renamed from options.c 2012-03-23 15:59:29.000000000 +0100 +1 -0
@@ -5218,6 +5218,7 @@ else if (streq (p[0], "route-gateway") && p[1]) { VERIFY_PERMISSION (OPT_P_ROUTE_EXTRAS); + rol_check_alloc (options); if (streq (p[1], "dhcp")) { options->route_gateway_via_dhcp = true;
@@ -5227,6 +5228,7 @@ if (ip_or_dns_addr_safe (p[1], options->allow_pull_fqdn) ||
is_special_addr (p[1])) /* FQDN -- may be DNS name */
{
options->route_default_gateway = p[1];
+ options->routes->flags |= (RG_ENABLE|RG_REROUTE_GW);
}
else
{