From: "cron2 (Code Review)" Date: Sun, 22 Jun 2025 11:36:22 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., gianmarco@...2726..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="Djs4vVSj9Cg="; charset=UTF-8 Subject: [Openvpn-devel] [M] Change in openvpn[master]: Route: add support for user defined routing table List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: its_Giaan Cc: flichtenheld , plaisthos , openvpn-devel --Djs4vVSj9Cg= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/52= 4?usp=3Demail ) Change subject: Route: add support for user defined routing table ...................................................................... Route: add support for user defined routing table Add the ability for users to specify a custom routing table where routes should be installed in. As of now routes are always installed in the main routing table of the operating system, however, with the new --route-table option it is possibile to specify the ID of the default routing table to be used by --route(-ipv6). Please note: this feature is currently supported only by Linux/SITNL. Support for other platforms should be added in related backends. Trac #1399 Change-Id: I3e4ebef484d2a04a383a65ede5617ee98bf218a7 Signed-off-by: Gianmarco De Gregori Acked-by: Gert Doering Message-Id: <20250622110311.1140-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31= 946.html Signed-off-by: Gert Doering --- M doc/man-sections/vpn-network-options.rst M src/openvpn/helper.c M src/openvpn/init.c M src/openvpn/options.c M src/openvpn/options.h M src/openvpn/route.c M src/openvpn/route.h 7 files changed, 68 insertions(+), 20 deletions(-) diff --git a/doc/man-sections/vpn-network-options.rst b/doc/man-sections/vp= n-network-options.rst index 40b8c19..4a64e8d 100644 --- a/doc/man-sections/vpn-network-options.rst +++ b/doc/man-sections/vpn-network-options.rst @@ -389,6 +389,14 @@ Like ``--redirect-gateway``, but omit actually changing the default gate= way. Useful when pushing private subnets. +--route-table id + Specify a default table id for use with --route. + By default, OpenVPN installs routes in the main routing + table of the operating system, but with this option, + a user defined routing table can be used instead. + + (Supported on Linux only, on other platforms this is a no-op). + --route args Add route to routing table after connection is established. Multiple routes can be specified. Routes will be automatically torn down in @@ -463,14 +471,20 @@ Setup IPv6 routing in the system to send the specified IPv6 network into OpenVPN's *tun*. - Valid syntax: + Valid syntaxes: :: - route-ipv6 ipv6addr/bits [gateway] [metric] + route-ipv6 ipv6addr/bits + route-ipv6 ipv6addr/bits gateway + route-ipv6 ipv6addr/bits gateway metric - The gateway parameter is only used for IPv6 routes across *tap* devices, - and if missing, the ``ipv6remote`` field from ``--ifconfig-ipv6`` or - ``--route-ipv6-gateway`` is used. + ``gateway`` + Only used for IPv6 routes across *tap* devices, + and if missing, the ``ipv6remote`` field from ``--ifconfig-ipv6`` = or + ``--route-ipv6-gateway`` is used. + + ``metric`` + default taken from ``--route-metric`` if set, otherwise :code:`0`. --route-gateway arg Specify a default *gateway* for use with ``--route``. diff --git a/src/openvpn/helper.c b/src/openvpn/helper.c index 8761826..7cef9db 100644 --- a/src/openvpn/helper.c +++ b/src/openvpn/helper.c @@ -118,7 +118,8 @@ print_in_addr_t(network, 0, &o->gc), print_in_addr_t(netmask, 0, &o->gc), NULL, - NULL); + NULL, + o->route_default_table_id); } static void diff --git a/src/openvpn/init.c b/src/openvpn/init.c index 7d4eb85..77747a2 100644 --- a/src/openvpn/init.c +++ b/src/openvpn/init.c @@ -1566,7 +1566,7 @@ { add_route_ipv6_to_option_list( options->routes_ipv6, string_alloc(opt_list[i], optio= ns->routes_ipv6->gc), - NULL, NULL ); + NULL, NULL, options->route_defa= ult_table_id); } } diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 3cf8c2a..7e26069 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -213,6 +213,10 @@ " pass --ifconfig parms by environment to scripts.\= n" "--ifconfig-nowarn : Don't warn if the --ifconfig option on this side = of the\n" " connection doesn't match the remote side.\n" +#ifdef TARGET_LINUX + "--route-table table_id : Specify a custom routing table for use with = --route(-ipv6).\n" + " If not specified, the id of the default ro= uting table will be used.\n" +#endif "--route network [netmask] [gateway] [metric] :\n" " Add route to routing table after connection\n" " is established. Multiple routes can be specified.\= n" @@ -829,6 +833,7 @@ o->ce.mssfix =3D 0; o->ce.mssfix_default =3D true; o->ce.mssfix_encap =3D true; + o->route_default_table_id =3D 0; o->route_delay_window =3D 30; o->resolve_retry_seconds =3D RESOLV_RETRY_INFINITE; o->resolve_in_advance =3D false; @@ -1799,6 +1804,7 @@ SHOW_STR(route_script); SHOW_STR(route_default_gateway); SHOW_INT(route_default_metric); + SHOW_INT(route_default_table_id); SHOW_BOOL(route_noexec); SHOW_INT(route_delay); SHOW_INT(route_delay_window); @@ -7064,6 +7070,14 @@ cnol_check_alloc(options); add_client_nat_to_option_list(options->client_nat, p[1], p[2], p[3= ], p[4], msglevel); } + else if (streq(p[0], "route-table") && p[1] && !p[2]) + { +#ifndef ENABLE_SITNL + msg(M_WARN, "NOTE: --route-table is supported only on Linux when S= ITNL is built-in"); +#endif + VERIFY_PERMISSION(OPT_P_ROUTE_TABLE); + options->route_default_table_id =3D positive_atoi(p[1], msglevel); + } else if (streq(p[0], "route") && p[1] && !p[5]) { VERIFY_PERMISSION(OPT_P_ROUTE); @@ -7085,8 +7099,9 @@ msg(msglevel, "route parameter gateway '%s' must be a vali= d address", p[3]); goto err; } + /* p[4] is metric, if specified */ } - add_route_to_option_list(options->routes, p[1], p[2], p[3], p[4]); + add_route_to_option_list(options->routes, p[1], p[2], p[3], p[4], = options->route_default_table_id); } else if (streq(p[0], "route-ipv6") && p[1] && !p[4]) { @@ -7104,9 +7119,9 @@ msg(msglevel, "route-ipv6 parameter gateway '%s' must be a= valid address", p[2]); goto err; } - /* p[3] is metric, if present */ + /* p[3] is metric, if specified */ } - add_route_ipv6_to_option_list(options->routes_ipv6, p[1], p[2], p[= 3]); + add_route_ipv6_to_option_list(options->routes_ipv6, p[1], p[2], p[= 3], options->route_default_table_id); } else if (streq(p[0], "max-routes") && !p[2]) { diff --git a/src/openvpn/options.h b/src/openvpn/options.h index 46ec32b..56e85d7 100644 --- a/src/openvpn/options.h +++ b/src/openvpn/options.h @@ -427,6 +427,7 @@ const char *route_predown_script; const char *route_default_gateway; const char *route_ipv6_default_gateway; + int route_default_table_id; int route_default_metric; bool route_noexec; int route_delay; @@ -758,6 +759,7 @@ #define OPT_P_PEER_ID (1<<28) #define OPT_P_INLINE (1<<29) #define OPT_P_PUSH_MTU (1<<30) +#define OPT_P_ROUTE_TABLE (1<<31) #define OPT_P_DEFAULT (~(OPT_P_INSTANCE|OPT_P_PULL_MODE)) diff --git a/src/openvpn/route.c b/src/openvpn/route.c index bd79a28..156262a 100644 --- a/src/openvpn/route.c +++ b/src/openvpn/route.c @@ -330,13 +330,11 @@ r->option =3D ro; /* network */ - if (!is_route_parm_defined(ro->network)) { goto fail; } - /* get_special_addr replaces specialaddr with a special ip addr * like gw. getaddrinfo is called to convert a a addrinfo struct */ @@ -442,6 +440,9 @@ r->flags |=3D RT_DEFINED; + /* routing table id */ + r->table_id =3D ro->table_id; + return true; fail: @@ -498,6 +499,9 @@ r6->flags |=3D RT_DEFINED; + /* routing table id */ + r6->table_id =3D r6o->table_id; + return true; fail: @@ -511,7 +515,8 @@ const char *network, const char *netmask, const char *gateway, - const char *metric) + const char *metric, + int table_id) { struct route_option *ro; ALLOC_OBJ_GC(ro, struct route_option, l->gc); @@ -519,6 +524,7 @@ ro->netmask =3D netmask; ro->gateway =3D gateway; ro->metric =3D metric; + ro->table_id =3D table_id; ro->next =3D l->routes; l->routes =3D ro; @@ -528,13 +534,15 @@ add_route_ipv6_to_option_list(struct route_ipv6_option_list *l, const char *prefix, const char *gateway, - const char *metric) + const char *metric, + int table_id) { struct route_ipv6_option *ro; ALLOC_OBJ_GC(ro, struct route_ipv6_option, l->gc); ro->prefix =3D prefix; ro->gateway =3D gateway; ro->metric =3D metric; + ro->table_id =3D table_id; ro->next =3D l->routes_ipv6; l->routes_ipv6 =3D ro; } @@ -1610,9 +1618,10 @@ metric =3D r->metric; } + status =3D RTA_SUCCESS; int ret =3D net_route_v4_add(ctx, &r->network, netmask_to_netbits2(r->= netmask), - &r->gateway, iface, 0, metric); + &r->gateway, iface, r->table_id, metric); if (ret =3D=3D -EEXIST) { msg(D_ROUTE, "NOTE: Linux route add command failed because route e= xists"); @@ -2007,7 +2016,7 @@ status =3D RTA_SUCCESS; int ret =3D net_route_v6_add(ctx, &r6->network, r6->netbits, gateway_needed ? &r6->gateway : NULL, - device, 0, metric); + device, r6->table_id, metric); if (ret =3D=3D -EEXIST) { msg(D_ROUTE, "NOTE: Linux route add command failed because route e= xists"); @@ -2227,7 +2236,7 @@ } if (net_route_v4_del(ctx, &r->network, netmask_to_netbits2(r->netmask), - &r->gateway, NULL, 0, metric) < 0) + &r->gateway, NULL, r->table_id, metric) < 0) { msg(M_WARN, "ERROR: Linux route delete command failed"); } @@ -2452,7 +2461,7 @@ } if (net_route_v6_del(ctx, &r6->network, r6->netbits, - gateway_needed ? &r6->gateway : NULL, device, 0, + gateway_needed ? &r6->gateway : NULL, device, r6-= >table_id, metric) < 0) { msg(M_WARN, "ERROR: Linux route v6 delete command failed"); diff --git a/src/openvpn/route.h b/src/openvpn/route.h index aa3114c..237375c 100644 --- a/src/openvpn/route.h +++ b/src/openvpn/route.h @@ -69,6 +69,7 @@ in_addr_t remote_host; int remote_host_local; /* TLA_x value */ struct route_bypass bypass; + int table_id; int default_metric; }; @@ -77,6 +78,7 @@ const char *network; const char *netmask; const char *gateway; + int table_id; const char *metric; }; @@ -101,6 +103,7 @@ const char *prefix; /* e.g. "2001:db8:1::/64" */ const char *gateway; /* e.g. "2001:db8:0::2" */ const char *metric; /* e.g. "5" */ + int table_id; }; struct route_ipv6_option_list { @@ -119,6 +122,7 @@ in_addr_t network; in_addr_t netmask; in_addr_t gateway; + int table_id; int metric; }; @@ -129,6 +133,7 @@ unsigned int netbits; struct in6_addr gateway; int metric; + int table_id; /* gateway interface */ #ifdef _WIN32 DWORD adapter_index; /* interface or ~0 if undefined */ @@ -290,12 +295,14 @@ const char *network, const char *netmask, const char *gateway, - const char *metric); + const char *metric, + int table_id); void add_route_ipv6_to_option_list(struct route_ipv6_option_list *l, const char *prefix, const char *gateway, - const char *metric); + const char *metric, + int table_id); bool init_route_list(struct route_list *rl, const struct route_option_list *opt, -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/524?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I3e4ebef484d2a04a383a65ede5617ee98bf218a7 Gerrit-Change-Number: 524 Gerrit-PatchSet: 10 Gerrit-Owner: its_Giaan Gerrit-Reviewer: cron2 Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-MessageType: merged --Djs4vVSj9Cg= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 submitted this change.

View Change

Route: add support for user defined routing ta=
ble

Add the ability for users to specify a custom
routing table w= here routes should be installed in.
As of now routes are always installe= d in the main
routing table of the operating system, however,
with th= e new --route-table option it is possibile
to specify the ID of the defa= ult routing table
to be used by --route(-ipv6).

Please note: this= feature is currently supported
only by Linux/SITNL.
Support for othe= r platforms should be added in related backends.

Trac #1399
Chang= e-Id: I3e4ebef484d2a04a383a65ede5617ee98bf218a7
Signed-off-by: Gianmarco= De Gregori <gianmarco@...2726...>
Acked-by: Gert Doering <gert= @...1296...>
Message-Id: <20250622110311.1140-1-gert@...1296...>= ;
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/= msg31946.html
Signed-off-by: Gert Doering <gert@...1296...>
---=
M doc/man-sections/vpn-network-options.rst
M src/openvpn/helper.cM src/openvpn/init.c
M src/openvpn/options.c
M src/openvpn/options.h=
M src/openvpn/route.c
M src/openvpn/route.h
7 files changed, 68 i= nsertions(+), 20 deletions(-)

diff --git a/doc/man-sections/vpn-network-options.rst b/doc/man-sections=
/vpn-network-options.rst
index 40b8c19..4a64e8d 100644
--- a/doc/man-sections/vpn-network-options.rst
= +++ b/doc/man-sections/vpn-network-options.rst
@@ -389,6 +3= 89,14 @@
Like ``--redirect-gateway``, but omit actually = changing the default gateway.
Useful when pushing privat= e subnets.

+--route-table id
+ Specify a default table id for use with --route.
+ By default, OpenVPN installs routes = in the main routing
+= table of the operating system, but with this option,
+ a user defined routing table can be us= ed instead.
+<= br>+ (Supported on Linux only,= on other platforms this is a no-op).
+
--route args
Add rou= te to routing table after connection is established. Multiple
routes can be specified. Routes will be automatically torn down in
@@ -463,14 +471,20 @@
Setup IPv6 routing i= n the system to send the specified IPv6 network into
Ope= nVPN's *tun*.

- Valid syntax:
+ Valid syntaxes:
::
<= br>- route-ipv6 ipv6addr/bits= [gateway] [metric]
+= route-ipv6 ipv6addr/bits
+ route-ipv6 ipv6addr/bits gateway
+ route-ipv6 ipv6addr/bits gateway metric

- The = gateway parameter is only used for IPv6 routes across *tap* devices,=
- and if missing, the ``ipv6= remote`` field from ``--ifconfig-ipv6`` or
- ``--route-ipv6-gateway`` is used.
+ ``gateway``
+ Only used for IPv6 routes across *ta= p* devices,
+ = and if missing, the ``ipv6remote`` field from ``--ifconfig-ipv6`` or=
+ ``--route-ipv6-gat= eway`` is used.
+

+ ``metric``
= + default taken from ``-= -route-metric`` if set, otherwise :code:`0`.

--route-gateway arg

Specify a default *gateway* for= use with ``--route``.
diff --git a/src/openvpn/helper.c b/= src/openvpn/helper.c
index 8761826..7cef9db 100644--- a/src/openvpn/helper.c
+++ b/src/openvpn/helper= .c
@@ -118,7 +118,8 @@
= print_in_addr_t(network, 0, &o->gc),
= print_in_addr_t(netmask, 0, &o->gc),=
NULL,
- NULL);
+ NULL,<= /span>
+ = o->route_default_table_id);
}
=
static void
diff --git a/src/openvpn/ini= t.c b/src/openvpn/init.c
index 7d4eb85..77747a2 100644
--- a/src/openvpn/init.c
+++ b/src/openvpn/init= .c
@@ -1566,7 +1566,7 @@
{<= br> add_route_ipv6_to_option_list( options->routes_ipv= 6,
string_alloc= (opt_list[i], options->routes_ipv6->gc),
- NULL, N= ULL );
+ = NULL, NULL, options->route_default_table_i= d);
}
}

diff --git a/src/openvpn/options.c b/src/openvpn/options.c
index 3cf8c2a..7e26069 100644
--- a/src/openvp= n/options.c
+++ b/src/openvpn/options.c
@@ = -213,6 +213,10 @@
" pass --ifc= onfig parms by environment to scripts.\n"
"-= -ifconfig-nowarn : Don't warn if the --ifconfig option on this side of = the\n"
" connection doesn= 't match the remote side.\n"
+#ifdef TARGET_LINUX
+ "--route-table table_id : Specify a custom routi= ng table for use with --route(-ipv6).\n"
+ " If not speci= fied, the id of the default routing table will be used.\n"
<= span style=3D"color: hsl(120, 100%, 40%);">+#endif

&qu= ot;--route network [netmask] [gateway] [metric] :\n"
= " Add route to routing table after connection\n&q= uot;
" is established. Multiple= routes can be specified.\n"
@@ -829,6 +833,7 @@
o->ce.mssfix =3D 0;
o->ce.mssfix= _default =3D true;
o->ce.mssfix_encap =3D true;
+ o->route_default= _table_id =3D 0;
o->route_delay_window =3D 30;
o->resolve_retry_seconds =3D RESOLV_RETRY_INFINITE;
o->resolve_in_advance =3D false;
@@ -1= 799,6 +1804,7 @@
SHOW_STR(route_script);
SHOW_STR(route_default_gateway);

SHOW_INT(rout= e_default_metric);
+ = SHOW_INT(route_default_table_id);
SHOW_BOOL(route_n= oexec);
SHOW_INT(route_delay);
SH= OW_INT(route_delay_window);
@@ -7064,6 +7070,14 @@ cnol_check_alloc(options);
add_cl= ient_nat_to_option_list(options->client_nat, p[1], p[2], p[3], p[4], msg= level);
}
+ else if (streq(p[0], "route-table") && p[1= ] && !p[2])
+= {
+#ifndef ENABLE= _SITNL
+ msg(M= _WARN, "NOTE: --route-table is supported only on Linux when SITNL is b= uilt-in");
+#end= if
+ VERIFY_PE= RMISSION(OPT_P_ROUTE_TABLE);
+ options->route_default_table_id =3D positive_atoi(p[1],= msglevel);
+ }
else if (streq(p[0], "route") && p[1] = && !p[5])
{
VERIFY_PE= RMISSION(OPT_P_ROUTE);
@@ -7085,8 +7099,9 @@
msg(msglevel, "route parameter gateway '%s'= must be a valid address", p[3]);

got= o err;
}
+ /* p[4] is metric, if specified */
= }
- = add_route_to_option_list(options->routes, p[1], p[2], p[3], p[4]);
+ add_route_to_o= ption_list(options->routes, p[1], p[2], p[3], p[4], options->route_de= fault_table_id);
}
else if (streq= (p[0], "route-ipv6") && p[1] && !p[4])
= {
@@ -7104,9 +7119,9 @@
= msg(msglevel, "route-ipv6 parameter gateway '%s' must= be a valid address", p[2]);
goto err= ;
}
- /* p[3] is metric, if present */
+ /* p[3] is metric, if speci= fied */
}
- add_route_ipv6_to_option_list(options->routes_ipv6,= p[1], p[2], p[3]);
+= add_route_ipv6_to_option_list(options->routes_ipv6, p[1], p[2], = p[3], options->route_default_table_id);
} else if (streq(p[0], "max-routes") && !p[2])<= /span>
{
diff --git a/src/openvpn/options.h b= /src/openvpn/options.h
index 46ec32b..56e85d7 100644=
--- a/src/openvpn/options.h
+++ b/src/openvpn/opt= ions.h
@@ -427,6 +427,7 @@
const char = *route_predown_script;
const char *route_default_gatew= ay;
const char *route_ipv6_default_gateway;
= + int route_default_table_id= ;
int route_default_metric;
bool = route_noexec;
int route_delay;
@@ -758= ,6 +759,7 @@
#define OPT_P_PEER_ID (1<<28)
#define OPT_P_INLINE (1<<29)
#define OPT_P_PUSH_MTU (1<<30)

+#define OPT_P_ROUTE_TABLE (1<<31)

#define OPT_P_DEFAULT (~(OPT_P_INSTANCE|OPT= _P_PULL_MODE))

diff --git a/src/openvpn/r= oute.c b/src/openvpn/route.c
index bd79a28..156262a 100644<= /span>
--- a/src/openvpn/route.c
+++ b/src/openvpn= /route.c
@@ -330,13 +330,11 @@
r->o= ption =3D ro;

/* network */-
if (!is_= route_parm_defined(ro->network))
{
= goto fail;
}

-

/* get_special= _addr replaces specialaddr with a special ip addr
* l= ike gw. getaddrinfo is called to convert a a addrinfo struct */
<= span>

@@ -442,6 +440,9 @@

r->flags |=3D RT_DEFINED;


+ /* routing table id */
+ r->table_id =3D ro->tabl= e_id;

+
return true;


fail:
@@ -498,6 +499,9 @@


r6->flags = |=3D RT_DEFINED;

+ /* routing table id */
+ r6->table_id =3D r6o->table_id;
<= span style=3D"color: hsl(120, 100%, 40%);">+

return tr= ue;

fail:
@@ -511,7 +515= ,8 @@
const char *network,=
const char *netmask,
= const char *gateway,
- const char *metric)<= br>+ co= nst char *metric,
+ = int table_id)
{
= struct route_option *ro;
ALLOC_OBJ_GC(ro, struct rou= te_option, l->gc);
@@ -519,6 +524,7 @@
= ro->netmask =3D netmask;
ro->gateway =3D gat= eway;
ro->metric =3D metric;
+ ro->table_id =3D table_id;<= br> ro->next =3D l->routes;
l->rout= es =3D ro;

@@ -528,13 +534,15 @@ add_route_ipv6_to_option_list(struct route_ipv6_option_list *l,
const char *prefix,
= const char *gateway,
- const cha= r *metric)
+ = const char *metric,
+ int table_id)
= {
struct route_ipv6_option *ro;
ALLOC_OBJ_GC(ro, struct route_ipv6_option, l->gc);

ro->prefix =3D prefix;
ro->gateway =3D gat= eway;
ro->metric =3D metric;
+ ro->table_id =3D table_id;<= br> ro->next =3D l->routes_ipv6;
l->= ;routes_ipv6 =3D ro;
}
@@ -1610,9 +1618,10= @@
metric =3D r->metric;
= }

+=
status =3D RTA_SUCCESS;
int ret = =3D net_route_v4_add(ctx, &r->network, netmask_to_netbits2(r->net= mask),
- = &r->gateway, iface, 0, metric);
+ &r-&g= t;gateway, iface, r->table_id, metric);
if (ret =3D= =3D -EEXIST)
{
msg(D_ROUTE, &= quot;NOTE: Linux route add command failed because route exists");
@@ -2007,7 +2016,7 @@
status =3D RTA_SUCCE= SS;
int ret =3D net_route_v6_add(ctx, &r6->netw= ork, r6->netbits,
gatewa= y_needed ? &r6->gateway : NULL,
- device, 0, metric);<= br>+ = device, r6->table_id, metric);
if (ret =3D=3D -= EEXIST)
{
msg(D_ROUTE, "= NOTE: Linux route add command failed because route exists");@@ -2227,7 +2236,7 @@
}

if (net_route_v4_del(ctx, &r->network, netmask_to_ne= tbits2(r->netmask),
= - &r->gateway, NULL, 0, metric) < 0)
+ = &r->gateway, NULL, r->table_id, metric) < 0)
= {
msg(M_WARN, "ERROR: Linux route delete= command failed");
}
@@ -2452,7 += 2461,7 @@
}

if = (net_route_v6_del(ctx, &r6->network, r6->netbits,
- gateway_need= ed ? &r6->gateway : NULL, device, 0,

+ gateway_needed ? &r6-&= gt;gateway : NULL, device, r6->table_id,
= metric) < 0)
{
= msg(M_WARN, "ERROR: Linux route v6 delete command failed");
diff --git a/src/openvpn/route.h b/src/openvpn/route.hindex aa3114c..237375c 100644
--- a/src/openvpn/rout= e.h
+++ b/src/openvpn/route.h
@@ -69,6 +69,= 7 @@
in_addr_t remote_host;
int r= emote_host_local; /* TLA_x value */
struct route_bypas= s bypass;
+ int ta= ble_id;
int default_metric;
};=

@@ -77,6 +78,7 @@
const ch= ar *network;
const char *netmask;
= const char *gateway;
+ int table_id;
const char *metric;
};


@@ -101,6 +103,7 @@
const char *prefix; /* e.g. "2001:db8:1::/64" */
const char *gateway; /* e.g. "2001:db8:0::2&= quot; */
const char *metric; /* e.g. "5&q= uot; */
+ int tabl= e_id;
};

struct route_i= pv6_option_list {
@@ -119,6 +122,7 @@
= in_addr_t network;
in_addr_t netmask;
= in_addr_t gateway;
+ int table_id;
int metric;
};<= /span>

@@ -129,6 +133,7 @@
= unsigned int netbits;
struct in6_addr gateway;<= br> int metric;
+ int table_id;
/* gateway interface */=
#ifdef _WIN32
DWORD adapter_index; /= * interface or ~0 if undefined */
@@ -290,12 +295,14 @@
const char *network,
= const char *netmask,
= const char *gateway,
- const char *metr= ic);
+ = const char *metric,
+ int table_id);

void add_route_ipv6_to_option_list(struct route_ipv6_op= tion_list *l,
const cha= r *prefix,
const char *= gateway,
- = const char *metric);
+ const char *metri= c,
+ = int table_id);

bool in= it_route_list(struct route_list *rl,
= const struct route_option_list *opt,

To= view, visit change 524. To unsubscribe, or for help writing mail filters, visit= settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I3e4ebef484d2a04a383a65ede56= 17ee98bf218a7
Gerrit-Change-Number: 524
Gerrit-PatchSet: 10
Gerrit-Owner: its_Giaan <gianmarco@...2786...= ..>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-MessageType: merged
--Djs4vVSj9Cg=--