[Babel-users] [PATCH 3/3] Always use the same metric for unreachable routes

Dave Taht dave.taht at gmail.com
Tue Sep 25 17:31:38 BST 2018


Not representing this to the kernel helps.

Signed-off-by: Dave Taht <dave.taht at gmail.com>
---
 kernel_netlink.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/kernel_netlink.c b/kernel_netlink.c
index 23a2da5..011df0f 100644
--- a/kernel_netlink.c
+++ b/kernel_netlink.c
@@ -962,6 +962,12 @@ kernel_has_ipv6_subtrees(void)
     return (kernel_older_than("Linux", 3, 11) == 0);
 }
 
+/* Someday we could make these globally settable to something like
+   32, as bird does */
+
+static int ipv4_metric = 0;
+static int ipv6_metric = 1024;
+
 int
 kernel_route(int operation, int table,
              const unsigned char *dest, unsigned short plen,
@@ -1100,7 +1106,7 @@ kernel_route(int operation, int table,
     rta->rta_type = RTA_PRIORITY;
 
     if(metric < KERNEL_INFINITY) {
-        *(int*)RTA_DATA(rta) = metric;
+        *(int*)RTA_DATA(rta) = ipv4 ? ipv4_metric : ipv6_metric;
         rta = RTA_NEXT(rta, len);
         rta->rta_len = RTA_LENGTH(sizeof(int));
         rta->rta_type = RTA_OIF;
@@ -1118,7 +1124,7 @@ kernel_route(int operation, int table,
             memcpy(RTA_DATA(rta), gate, sizeof(struct in6_addr));
         }
     } else {
-        *(int*)RTA_DATA(rta) = -1;
+        *(int*)RTA_DATA(rta) = ipv4 ? ipv4_metric : ipv6_metric;
     }
     buf.nh.nlmsg_len = (char*)rta + rta->rta_len - buf.raw;
 
-- 
2.7.4




More information about the Babel-users mailing list