+++ route.c 2011-05-18 09:15:17.000000000 +0200
if (!r->defined)
return;
@@ -1113,23 +1114,26 @@ add_route (struct route *r, const struct tuntap *tt, unsigned int flags, const s
#if defined(TARGET_LINUX)
#ifdef CONFIG_FEATURE_IPROUTE
- argv_printf (&argv, "%s route add %s/%d via %s",
+ argv_printf (&argv, "%s route add %s/%d via %s dev %s", iproute_path,
network, count_netmask_bits(netmask),
- gateway);
+ gateway,
+ device);
if (r->metric_defined)
argv_printf_cat (&argv, "metric %d", r->metric); #else
- argv_printf (&argv, "%s add -net %s netmask %s gw %s",
+ argv_printf (&argv, "%s add -net %s netmask %s gw %s dev %s", ROUTE_PATH,
network,
netmask,
- gateway);
+ gateway,
+ device);
if (r->metric_defined)
argv_printf_cat (&argv, "metric %d", r->metric); #endif /*CONFIG_FEATURE_IPROUTE*/
+
argv_msg (D_ROUTE, &argv);
status = openvpn_execve_check (&argv, es, 0, "ERROR: Linux route add command failed");
@@ -1452,6 +1456,7 @@ delete_route (const struct route *r, const struct tuntap *tt, unsigned int flags
const char *network;
const char *netmask;
const char *gateway;
+ const char *device = tt->actual_name;
if (!r->defined)
return;
@@ -1465,16 +1470,18 @@ delete_route (const struct route *r, const struct tuntap *tt, unsigned int flags
#if defined(TARGET_LINUX)
#ifdef CONFIG_FEATURE_IPROUTE
- argv_printf (&argv, "%s route del %s/%d",
+ argv_printf (&argv, "%s route del %s/%d dev %s", iproute_path,
network,
- count_netmask_bits(netmask)); + count_netmask_bits(netmask), + device);
#else
- argv_printf (&argv, "%s del -net %s netmask %s",
+ argv_printf (&argv, "%s del -net %s netmask %s dev %s", ROUTE_PATH,
network,
- netmask);
+ netmask,
+ device);
#endif /*CONFIG_FEATURE_IPROUTE*/
if (r->metric_defined)
argv_printf_cat (&argv, "metric %d", r->metric);Hi,
Review add_route (struct route *r, const struct tuntap *tt, unsigned int flags, const s · line 1117
Quoted 8 lines · Xavier Franquet
if (!r->defined) return;(quoted diff) +1
-1@@ -1113,23 +1114,26 @@ add_route (struct route *r, const struct tuntap *tt, unsigned int flags, const s #if defined(TARGET_LINUX) #ifdef CONFIG_FEATURE_IPROUTE - argv_printf (&argv, "%s route add %s/%d via %s", + argv_printf (&argv, "%s route add %s/%d via %s dev %s",
A few words on why exactly this patch is needed, and what problems it solves would be appreciated...
As it stands, I'd NAK it, because "the existing code works for me", and your code just makes it more complicated.
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
In addition to Gert's comments, I would like to see a complete commit patch. It seems you just did "git diff | git send-email", which makes this patch more difficult to apply.
Please do a git commit -s to your local git tree (you have all rights to do so, its all on your own computer) then do 'git format-patch HEAD~1' and send the 0001-whatever-comes-here.patch via git send-email.
When doing git commit -s, you need to put in an explanation/comment to your commit. First a short one-line summary, a blank line and a more verbose description of why this change is needed.
But you might want to get answer Gert's comment before submitting a new patch.
Kind regards,
David Sommerseth
Quoted 55 lines · Xavier Franquet
if (!r->defined) return;(quoted diff) +11
-6@@ -1113,23 +1114,26 @@ add_route (struct route *r, const struct tuntap *tt, unsigned int flags, const s #if defined(TARGET_LINUX) #ifdef CONFIG_FEATURE_IPROUTE - argv_printf (&argv, "%s route add %s/%d via %s", + argv_printf (&argv, "%s route add %s/%d via %s dev %s", iproute_path, network, count_netmask_bits(netmask), - gateway); + gateway, + device); if (r->metric_defined) argv_printf_cat (&argv, "metric %d", r->metric); #else - argv_printf (&argv, "%s add -net %s netmask %s gw %s", + argv_printf (&argv, "%s add -net %s netmask %s gw %s dev %s", ROUTE_PATH, network, netmask, - gateway); + gateway, + device); if (r->metric_defined) argv_printf_cat (&argv, "metric %d", r->metric); #endif /*CONFIG_FEATURE_IPROUTE*/ + argv_msg (D_ROUTE, &argv); status = openvpn_execve_check (&argv, es, 0, "ERROR: Linux route add command failed");@@ -1452,6 +1456,7 @@ delete_route (const struct route *r, const struct tuntap *tt, unsigned int flags const char *network; const char *netmask; const char *gateway; + const char *device = tt->actual_name; if (!r->defined) return;@@ -1465,16 +1470,18 @@ delete_route (const struct route *r, const struct tuntap *tt, unsigned int flags #if defined(TARGET_LINUX) #ifdef CONFIG_FEATURE_IPROUTE - argv_printf (&argv, "%s route del %s/%d", + argv_printf (&argv, "%s route del %s/%d dev %s", iproute_path, network, - count_netmask_bits(netmask)); + count_netmask_bits(netmask), + device); #else
Review delete_route (const struct route *r, const struct tuntap *tt, unsigned int flags · line 1487
Quoted 10 lines
(quoted diff) +3
-2- argv_printf (&argv, "%s del -net %s netmask %s", + argv_printf (&argv, "%s del -net %s netmask %s dev %s", ROUTE_PATH, network, - netmask); + netmask, + device); #endif /*CONFIG_FEATURE_IPROUTE*/ if (r->metric_defined) argv_printf_cat (&argv, "metric %d", r->metric);
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iEYEARECAAYFAk3U81UACgkQDC186MBRfroMHwCgirtiLfD2eYx4kUd36m5URLAb nUUAn05ktAbALzn21y5miaclKtMSs8tH
=j4/1
-----END PGP SIGNATURE-----
Quoted 3 lines · David Sommerseth
Please do a git commit -s to your local git tree (you have all rights to do so, its all on your own computer) then do 'git format-patch HEAD~1' and send the 0001-whatever-comes-here.patch via git send-email.
git send-email HEAD~1 # is shorthand for that
//Peter
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 7 lines · Peter Stuge
Quoted 3 lines · David Sommerseth
Please do a git commit -s to your local git tree (you have all rights to do so, its all on your own computer) then do 'git format-patch HEAD~1' and send the 0001-whatever-comes-here.patch via git send-email.
git send-email HEAD~1 # is shorthand for that
Thanks a lot! I wasn't aware of that one! I'll update the wiki about this one.
kind regards,
David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iEYEARECAAYFAk3VK4MACgkQDC186MBRfrpmNQCdEJiscIPU8cPGVLzU12LW4e6b hBIAoK6+kjF7EXA4LWliLNV5iqD9YbB1
=EoPy
-----END PGP SIGNATURE-----
PATCH 1/1 Modified previous patch for route command. The parameter "dev <device>" is only used when the route goes through the VPN and not for local routes.
In reply to Xavier Franquet--- route.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
route.c +7 -0
@@ -1130,6 +1130,9 @@ add_route (struct route *r, const struct tuntap *tt, unsigned int flags, const sif (r->metric_defined)argv_printf_cat (&argv,"metric %d" , r->metric);#endif /*CONFIG_FEATURE_IPROUTE*/ +if (r->option->gateway ==NULL || !strcmp (r->option->gateway,"vpn_gateway" )) +argv_print (&argv,"dev %s" , tt->actual_name); +argv_msg (D_ROUTE , &argv); status =openvpn_execve_check (&argv, es,0 ,"ERROR: Linux route add command failed" );
@@ -1478,6 +1481,10 @@ delete_route (const struct route *r, const struct tuntap *tt, unsigned int flags#endif /*CONFIG_FEATURE_IPROUTE*/ if (r->metric_defined)argv_printf_cat (&argv,"metric %d" , r->metric); + +if (r->option->gateway ==NULL || !strcmp (r->option->gateway,"vpn_gateway" )) +argv_print (&argv,"dev %s" , tt->actual_name); +argv_msg (D_ROUTE , &argv);openvpn_execve_check (&argv, es,0 ,"ERROR: Linux route delete command failed" );
Signature · 1 line
1.7.1