Skip to contentSkip to conversation

Adding "protocol static" to Linux routes?

Openvpn-devel Samuel Thibault 3 participants 6 messages Jun 19, 2016 – Jun 20, 2016

lore
Share & tools
lore
#0 lore raw

Hello,

Here we used two openvpn servers for resiliency, and we use the bird bgp daemon to make the two boxes exchange routes. Bird however does not pick up openvpn's routes because they are considered as "protocol boot" in Linux' "ip route" terms, i.e. they are assumed to be an automatic configuration, and not an administratively-configured route (see the protocol RTPROTO part of man ip-route for the details).

So we need the attached change, which just adds "protocol static", to express that the routes created by openvpn are to override other dynamic routing.

What do you think?

Samuel

src/openvpn/route.c +1 -1
index a90195f..62ea633 100644
@@ -1418,7 +1418,7 @@ add_route (struct route_ipv4 *r,
 
 #if defined(TARGET_LINUX)
 #ifdef ENABLE_IPROUTE
-  argv_printf (&argv, "%s route add %s/%d",
+  argv_printf (&argv, "%s route add %s/%d protocol static",
   	      iproute_path,
 	      network,
               netmask_to_netbits2(r->netmask));
#1 lore raw
Quoted 3 lines · Samuel Thibault, on Sun 19 Jun 2016 21:45:38 +0200, wrote:

So we need the attached change, which just adds "protocol static", to express that the routes created by openvpn are to override other dynamic routing.

Of course, v6 needs it too.

Samuel

route.c +2 -2
@@ -1113,7 +1113,7 @@ add_route (struct route *r, const struct
 
 #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 protocol static",
   	      iproute_path,
 	      network,
 	      count_netmask_bits(netmask),
@@ -1328,7 +1328,7 @@ add_route_ipv6 (struct route_ipv6 *r6, c
 
 #if defined(TARGET_LINUX)
 #ifdef CONFIG_FEATURE_IPROUTE
-  argv_printf (&argv, "%s -6 route add %s/%d dev %s",
+  argv_printf (&argv, "%s -6 route add %s/%d dev %s protocol static",
   	      iproute_path,
 	      network,
 	      r6->netbits,
#2 lore raw
Quoted 6 lines · Samuel Thibault
Quoted 3 lines · Samuel Thibault, on Sun 19 Jun 2016 21:45:38 +0200, wrote:

So we need the attached change, which just adds "protocol static", to express that the routes created by openvpn are to override other dynamic routing.

Of course, v6 needs it too.

Which platforms have this change been tested on?

Signature · 3 lines
kind regards,

David Sommerseth
#3 lore raw
Quoted 9 lines · David Sommerseth, on Mon 20 Jun 2016 01:23:34 +0200, wrote:
Quoted 6 lines · Samuel Thibault
Quoted 3 lines · Samuel Thibault, on Sun 19 Jun 2016 21:45:38 +0200, wrote:

So we need the attached change, which just adds "protocol static", to express that the routes created by openvpn are to override other dynamic routing.

Of course, v6 needs it too.

Which platforms have this change been tested on?

I'm not sure what you mean by "platforms" exactly? The modified code is built on Linux only, and the iproute2 software supports "protocol static" since at least 2004, so I don't see any potential for breakage.

Samuel

#4 lore raw
In reply to Samuel Thibault

Hi,

Quoted 7 lines · Samuel Thibault

Here we used two openvpn servers for resiliency, and we use the bird bgp daemon to make the two boxes exchange routes. Bird however does not pick up openvpn's routes because they are considered as "protocol boot" in Linux' "ip route" terms, i.e. they are assumed to be an automatic configuration, and not an administratively-configured route (see the protocol RTPROTO part of man ip-route for the details).

Quoted 5 lines

So we need the attached change, which just adds "protocol static", to express that the routes created by openvpn are to override other dynamic routing.

What do you think?

I'm wondering how you do the resiliency. Traditionally, one would set up the routes on client-connect/client-disconnect (or via --learn-address), so it's under your control anyway - if you set up the routes from within openvpn, both servers would announce all the routes all the time...

Besides, I'm a bit reluctant to change something like this, which might break someone *else*'s setup, which relies on the route being what they are today ("boot") - can't you teach bird to do "redistribute boot"?

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]...
#5 lore raw

Hello,

Quoted 3 lines · Gert Doering, on Mon 20 Jun 2016 08:40:12 +0200, wrote:

I'm wondering how you do the resiliency. Traditionally, one would set up the routes on client-connect/client-disconnect (or via --learn-address), so it's under your control anyway

Ah, right, yes, we do that, and we announce those routes via bgp.

So what remains is the "converse": the routes set by openvpn with the "route" configuration element. When a client manages to connect to the server and thus get access to the network, it is useful to add the routes with "protocol static" so that the access to the network is announced through bgp to the network behind the client. Of course we could drop the "route" configuration element, and add the route ourself in a route-up script, but that's less clean.

Quoted 3 lines

Besides, I'm a bit reluctant to change something like this, which might break someone *else*'s setup, which relies on the route being what they are today ("boot") - can't you teach bird to do "redistribute boot"?

You mean patching bird? AIUI that would be counter-productive: the boot/static separation was explicitly made to separate between routes which shouldn't be announced and routes which should be announced...

Setting static could also be made an option, e.g.

--route network/IP [netmask] [gateway] [metric] [announce]

and putting "announce" would make openvpn set "protocol static" in the route command.

Samuel