[PATCH] metric: Enable support for route metric on FreeBSD

Pouria Mousavizadeh Tehrani <[email protected]>
Newsgroups gmane.network.openvpn.devel
Message-ID <[email protected]>
The route metric has been available since FreeBSD version 1600019.

Signed-off-by: Pouria Mousavizadeh Tehrani <[email protected]>
---
 src/openvpn/route.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/openvpn/route.c b/src/openvpn/route.c
index 8ea745d1..7b9e106b 100644
--- a/src/openvpn/route.c
+++ b/src/openvpn/route.c
@@ -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;
-- 
2.55.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.