]> git.puffer.fish Git - matthieu/frr.git/commitdiff
babeld: Add support for blackhole routes.
authorJuliusz Chroboczek <jch@pps.jussieu.fr>
Thu, 9 Feb 2012 16:23:09 +0000 (17:23 +0100)
committerPaul Jakma <paul@quagga.net>
Sun, 25 Mar 2012 16:06:54 +0000 (17:06 +0100)
Babel makes use of blackhole routes to prevent routing loops between
overlapping prefixes shortly after a route is retracted (see RFC 6126
sections 2.8 and 3.5.5).  This patch adds support for installing such
blackhole routes.

babeld/kernel_zebra.c

index 1df4217f0fa3de53cd98c41e1317bb7c9ffe5cb4..d262a86b846cca003de01ad1fd18bb101994a1f7 100644 (file)
@@ -186,12 +186,16 @@ kernel_route_add_v4(const unsigned char *pref, unsigned short plen,
        correctly. */
 
     SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
-    api.nexthop_num = 1;
-    api.nexthop = &nexthop_pointer;
     api.ifindex_num = 0;
-
-    SET_FLAG(api.message, ZAPI_MESSAGE_METRIC);
-    api.metric = metric;
+    if(metric >= KERNEL_INFINITY) {
+        api.flags = ZEBRA_FLAG_BLACKHOLE;
+        api.nexthop_num = 0;
+    } else {
+        api.nexthop_num = 1;
+        api.nexthop = &nexthop_pointer;
+        SET_FLAG(api.message, ZAPI_MESSAGE_METRIC);
+        api.metric = metric;
+    }
 
     debugf(BABEL_DEBUG_ROUTE, "adding route (ipv4) to zebra");
     return zapi_ipv4_route (ZEBRA_IPV4_ROUTE_ADD, zclient,
@@ -226,13 +230,18 @@ kernel_route_add_v6(const unsigned char *pref, unsigned short plen,
     api.message = 0;
     api.safi = SAFI_UNICAST;
     SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
-    api.nexthop_num = 1;
-    api.nexthop = &nexthop_pointer;
-    SET_FLAG(api.message, ZAPI_MESSAGE_IFINDEX);
-    api.ifindex_num = 1;
-    api.ifindex = &tmp_ifindex;
-    SET_FLAG(api.message, ZAPI_MESSAGE_METRIC);
-    api.metric = metric;
+    if(metric >= KERNEL_INFINITY) {
+        api.nexthop_num = 0;
+        api.ifindex_num = 0;
+    } else {
+        api.nexthop_num = 1;
+        api.nexthop = &nexthop_pointer;
+        SET_FLAG(api.message, ZAPI_MESSAGE_IFINDEX);
+        api.ifindex_num = 1;
+        api.ifindex = &tmp_ifindex;
+        SET_FLAG(api.message, ZAPI_MESSAGE_METRIC);
+        api.metric = metric;
+    }
 
     debugf(BABEL_DEBUG_ROUTE, "adding route (ipv6) to zebra");
     return zapi_ipv6_route (ZEBRA_IPV6_ROUTE_ADD, zclient,
@@ -267,11 +276,16 @@ kernel_route_delete_v4(const unsigned char *pref, unsigned short plen,
     api.message = 0;
     api.safi = SAFI_UNICAST;
     SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
-    api.nexthop_num = 1;
-    api.nexthop = &nexthop_pointer;
     api.ifindex_num = 0;
-    SET_FLAG(api.message, ZAPI_MESSAGE_METRIC);
-    api.metric = metric;
+    if(metric >= KERNEL_INFINITY) {
+        api.flags = ZEBRA_FLAG_BLACKHOLE;
+        api.nexthop_num = 0;
+    } else {
+        api.nexthop_num = 1;
+        api.nexthop = &nexthop_pointer;
+        SET_FLAG(api.message, ZAPI_MESSAGE_METRIC);
+        api.metric = metric;
+    }
 
     debugf(BABEL_DEBUG_ROUTE, "removing route (ipv4) to zebra");
     return zapi_ipv4_route (ZEBRA_IPV4_ROUTE_DELETE, zclient,
@@ -307,11 +321,19 @@ kernel_route_delete_v6(const unsigned char *pref, unsigned short plen,
     api.message = 0;
     api.safi = SAFI_UNICAST;
     SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
-    api.nexthop_num = 1;
-    api.nexthop = &nexthop_pointer;
-    SET_FLAG(api.message, ZAPI_MESSAGE_IFINDEX);
-    api.ifindex_num = 1;
-    api.ifindex = &tmp_ifindex;
+    if(metric >= KERNEL_INFINITY) {
+        api.flags = ZEBRA_FLAG_BLACKHOLE;
+        api.nexthop_num = 0;
+        api.ifindex_num = 0;
+    } else {
+        api.nexthop_num = 1;
+        api.nexthop = &nexthop_pointer;
+        SET_FLAG(api.message, ZAPI_MESSAGE_IFINDEX);
+        api.ifindex_num = 1;
+        api.ifindex = &tmp_ifindex;
+        SET_FLAG(api.message, ZAPI_MESSAGE_METRIC);
+        api.metric = metric;
+    }
 
     debugf(BABEL_DEBUG_ROUTE, "removing route (ipv6) to zebra");
     return zapi_ipv6_route (ZEBRA_IPV6_ROUTE_DELETE, zclient,