I updated both an aarch64 and an x86_64 box to git head today. No issues.

...

Attached is part one of trying to get atomic updates to work, which is
a change to how metrics are passed into the kernel. I don't know if
this change is worth
it by itself, nor do I understand why -1 was used in the first place.

The original code would export -1 into the linux kernel routing table
for unreachable routes, in addition to setting RTN_UNREACHABLE.

RTN_UNREACHABLE is all you need (at least, on modern kernels), and
changing the metric to -1 makes it impossible to do atomic
updates. Also it has a theoretical flaw in that other similar routes
with smaller metrics, inserted by other protocols, can override the
now unreachable route. Using the defaults leads to more consistent
behavior.

This uses the defaults of 0 and 1024 for ipv4 and ipv6 route metrics
respectively.
From cea7e11152b0a7cebd3572c63ccc9454e6840277 Mon Sep 17 00:00:00 2001
From: Dave Taht <d...@taht.net>
Date: Thu, 8 Mar 2018 13:00:01 -0800
Subject: [PATCH] Always specify linux route metric to defaults

The original code would export -1 into the linux kernel routing table
for unreachable routes, in addition to setting RTN_UNREACHABLE.

RTN_UNREACHABLE is all you need (at least, on modern kernels), and
changing the metric to -1 makes it impossible to do atomic
updates. Also it has a theoretical flaw in that other similar routes
with smaller metrics, inserted by other protocols, can override the
now unreachable route. Using the defaults leads to more consistent
behavior.

This uses the defaults of 0 and 1024 for ipv4 and ipv6 route metrics
respectively.
---
 kernel_netlink.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/kernel_netlink.c b/kernel_netlink.c
index 94f01b0..e521ed7 100644
--- a/kernel_netlink.c
+++ b/kernel_netlink.c
@@ -100,6 +100,9 @@ int num_old_if = 0;
 
 static int dgram_socket = -1;
 
+static const int ipv4_metric = 0;
+static const int ipv6_metric = 1024;
+
 #ifndef ARPHRD_ETHER
 #warning ARPHRD_ETHER not defined, we might not support exotic link layers
 #define ARPHRD_ETHER 1
@@ -1055,9 +1058,9 @@ kernel_route(int operation, int table,
     rta = RTA_NEXT(rta, len);
     rta->rta_len = RTA_LENGTH(sizeof(int));
     rta->rta_type = RTA_PRIORITY;
+    *(int*)RTA_DATA(rta) = ipv4 ? ipv4_metric : ipv6_metric;
 
     if(metric < KERNEL_INFINITY) {
-        *(int*)RTA_DATA(rta) = metric;
         rta = RTA_NEXT(rta, len);
         rta->rta_len = RTA_LENGTH(sizeof(int));
         rta->rta_type = RTA_OIF;
@@ -1074,8 +1077,6 @@ kernel_route(int operation, int table,
             rta->rta_type = RTA_GATEWAY;
             memcpy(RTA_DATA(rta), gate, sizeof(struct in6_addr));
         }
-    } else {
-        *(int*)RTA_DATA(rta) = -1;
     }
     buf.nh.nlmsg_len = (char*)rta + rta->rta_len - buf.raw;
 
-- 
2.7.4

_______________________________________________
Babel-users mailing list
Babel-users@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/babel-users

Reply via email to