Skip to contentSkip to conversation

metric: Enable support for route metric on FreeBSD

PATCH In review Pouria Mousavizadeh Tehrani 2 participants 6 messages Aug 5 – Nov 19

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 metric: Enable support for route metric on FreeBSD

The route metric has been available since FreeBSD version 1600019.

---
 src/openvpn/route.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
src/openvpn/route.c +9 -2
index 8ea745d1..7b9e106b 100644
@@ -1640,10 +1640,10 @@ add_route(struct route_ipv4 *r, const struct tuntap *tt, unsigned int flags,
 
     argv_printf(&argv, "%s add", ROUTE_PATH);
 
-#if 0
+#if __FreeBSD_version >= 1600019
     if (r->flags & RT_METRIC_DEFINED)
     {
-        argv_printf_cat(&argv, "-rtt %d", r->metric);
+        argv_printf_cat(&argv, "-metric %d", r->metric);
     }
 #endif
 
@@ -1946,6 +1946,13 @@ add_route_ipv6(struct route_ipv6 *r6, const struct tuntap *tt, unsigned int flag
         argv_printf_cat(&argv, "-iface %s", device);
     }
 
+#if defined(TARGET_FREEBSD) && __FreeBSD_version >= 1600019
+    if (r6->flags & RT_METRIC_DEFINED)
+    {
+        argv_printf_cat(&argv, "-metric %d", r6->metric);
+    }
+#endif
+
     argv_msg(D_ROUTE, &argv);
     bool ret = openvpn_execve_check(&argv, es, 0, "ERROR: *BSD route add -inet6 command failed");
     status = ret ? RTA_SUCCESS : RTA_ERROR;
Signature · 8 lines
2.55.0



_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
#1 lore raw

Hi,

Quoted 1 line · Pouria Mousavizadeh Tehrani

The route metric has been available since FreeBSD version 1600019.

Is there some documentation what this does? As in, can you now install two routes for the same prefix, with different metrics, and the one with the "lowest metric wins"?

gert

Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you 
 feed honest figures into a computer, honest figures come out. Never doubted 
 it myself till I met a computer with a sense of humor."
                             Robert A. Heinlein, The Moon is a Harsh Mistress

Gert Doering - Munich, Germany                             [email protected]

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#2 lore raw

Hi

Quoted 8 lines · Gert Doering

Hi,

Quoted 1 line · Pouria Mousavizadeh Tehrani

The route metric has been available since FreeBSD version 1600019.

Is there some documentation what this does? As in, can you now install two routes for the same prefix, with different metrics, and the one with the "lowest metric wins"?

Yes, the route(8) manual is updated.
https://man.freebsd.org/cgi/man.cgi?query=route&sektion=8&manpath=freebsd-current

To answer your question:

```
% mdo route -n4 add -net 172.31.0.0/16 -gateway 192.168.1.1 -metric 10
add net 172.31.0.0: gateway 192.168.1.1
% mdo route -n4 add -net 172.31.0.0/16 -gateway 192.168.1.2 -metric 1
add net 172.31.0.0: gateway 192.168.1.2
% netstat -rn4W | grep 172.31.0.0
172.31.0.0/16 192.168.1.1 UGS 0 1500 bridge0 10
172.31.0.0/16 192.168.1.2 UGS 0 1500 bridge0  1
% route -n4 get 172.31.0.0
     route to: 172.31.0.0
  destination: 172.31.0.0
         mask: 255.255.0.0
      gateway: 192.168.1.2
...
```
Quoted 2 lines

gert

Signature · 1 line
Pouria

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#3 lore raw

Hi,

I haven't contributed to this project before, and I followed the CONTRIBUTING.rst guide.

I'd like to help move this patch forward. Did I miss anything in the process, or is there anything else I should do on my side to assist?

Thank you.

Quoted 41 lines · Pouria Mousavizadeh Tehrani

Hi

Quoted 8 lines · Gert Doering

Hi,

Quoted 1 line · Pouria Mousavizadeh Tehrani

The route metric has been available since FreeBSD version 1600019.

Is there some documentation what this does?  As in, can you now install two routes for the same prefix, with different metrics, and the one with the "lowest metric wins"?

Yes, the route(8) manual is updated.
https://man.freebsd.org/cgi/man.cgi? query=route&sektion=8&manpath=freebsd-current

To answer your question:

```
% mdo route -n4 add -net 172.31.0.0/16 -gateway 192.168.1.1 -metric 10
add net 172.31.0.0: gateway 192.168.1.1
% mdo route -n4 add -net 172.31.0.0/16 -gateway 192.168.1.2 -metric 1
add net 172.31.0.0: gateway 192.168.1.2
% netstat -rn4W | grep 172.31.0.0
172.31.0.0/16 192.168.1.1 UGS 0 1500 bridge0 10
172.31.0.0/16 192.168.1.2 UGS 0 1500 bridge0  1
% route -n4 get 172.31.0.0
      route to: 172.31.0.0
   destination: 172.31.0.0
          mask: 255.255.0.0
       gateway: 192.168.1.2
...
```
Quoted 2 lines

gert

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Signature · 1 line
Pouria

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#4 lore raw

Hi,

Quoted 5 lines · Pouria Mousavizadeh Tehrani

I haven't contributed to this project before, and I followed the CONTRIBUTING.rst guide.

I'd like to help move this patch forward. Did I miss anything in the process, or is there anything else I should do on my side to assist?

You did everything correctly. The one thing you can not provide is "sufficient manpower on our end"... alas.

The patch is reasonable and looks like a good addition, so we'll pick it up one way or the other. Right now we have two methods to add routes on FreeBSD with different internal APIs, which is a mess that need to be unified and cleaned up - so maybe this is a good starting point for the cleanup as well.

gert

Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you 
 feed honest figures into a computer, honest figures come out. Never doubted 
 it myself till I met a computer with a sense of humor."
                             Robert A. Heinlein, The Moon is a Harsh Mistress

Gert Doering - Munich, Germany                             [email protected]

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#5 lore raw
In reply to Pouria Mousavizadeh Tehrani

Hi,

Quoted 2 lines · Pouria Mousavizadeh Tehrani

I'd like to help move this patch forward. Did I miss anything in the process, or is there anything else I should do on my side to assist?

Just to give you a quick heads-up why nothing has happened so far - there are two independent "add route" implementations in OpenVPN so far, one in route.c and one in networking_freebsd.c

I wanted to clean these up into just one (networking_freebsd.c, because that is "the future path", and also because that already has fib support) but didn't find time. Razvan sent two patches to clean up & change the code accordingly

	https://gerrit.openvpn.net/c/openvpn/+/2153/2
	https://gerrit.openvpn.net/c/openvpn/+/2154/4

... and of course that required to fix up DragonFly first (because it was not working at all anymore). So now we're at "DragonFly got fixed, 2153 next".

When these are in, route metric on top of 2154 should be quick :-)

gert

Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you 
 feed honest figures into a computer, honest figures come out. Never doubted 
 it myself till I met a computer with a sense of humor."
                             Robert A. Heinlein, The Moon is a Harsh Mistress

Gert Doering - Munich, Germany                             [email protected]

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel