]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: Allow recursively resolved blackhole routes to be installed
authorDonald Sharp <sharpd@cumulusnetworks.com>
Tue, 12 Sep 2017 12:14:50 +0000 (08:14 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Tue, 12 Sep 2017 12:33:37 +0000 (08:33 -0400)
So the current code for a blackhole route assumed that you
would never want a recursively resolved blackhole to work.
Suppose you have this setup:

1) ip route 192.0.2.1/32 Null0
2) BGP installed with a route-map that rewrites the
   nexthop to 192.0.2.1.

Zebra will end up with a recursive nexthop that resolves
to the blackhole.

The original rib install function assumed that we would never
want the ability to recursively resolve a blackhole route.
Instead just handle the blackhole as part of the nexthop_num = 1
case.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
zebra/rt_netlink.c

index 12b61853957a2011afc4cee113bc2c43d6ce0e52..ef59f26f213bf295427ed602a0bc095c12009fde 100644 (file)
@@ -1321,23 +1321,6 @@ static int netlink_route_multipath(int cmd, struct prefix *p,
        req.r.rtm_scope = RT_SCOPE_UNIVERSE;
        req.r.rtm_type = RTN_UNICAST;
 
-       if (re->nexthop_num == 1
-           && re->nexthop->type == NEXTHOP_TYPE_BLACKHOLE) {
-               discard = 1;
-
-               switch (re->nexthop->bh_type) {
-               case BLACKHOLE_ADMINPROHIB:
-                       req.r.rtm_type = RTN_PROHIBIT;
-                       break;
-               case BLACKHOLE_REJECT:
-                       req.r.rtm_type = RTN_UNREACHABLE;
-                       break;
-               default:
-                       req.r.rtm_type = RTN_BLACKHOLE;
-                       break;
-               }
-       }
-
        addattr_l(&req.n, sizeof req, RTA_DST, &p->u.prefix, bytelen);
        if (src_p)
                addattr_l(&req.n, sizeof req, RTA_SRC, &src_p->u.prefix,
@@ -1396,6 +1379,27 @@ static int netlink_route_multipath(int cmd, struct prefix *p,
        if (nexthop_num == 1 || multipath_num == 1) {
                nexthop_num = 0;
                for (ALL_NEXTHOPS(re->nexthop, nexthop)) {
+                       /*
+                        * So we want to cover 2 types of blackhole
+                        * routes here:
+                        * 1) A normal blackhole route( ala from a static
+                        *    install.
+                        * 2) A recursively resolved blackhole route
+                        */
+                       if (nexthop->type == NEXTHOP_TYPE_BLACKHOLE) {
+                               switch (nexthop->bh_type) {
+                               case BLACKHOLE_ADMINPROHIB:
+                                       req.r.rtm_type = RTN_PROHIBIT;
+                                       break;
+                               case BLACKHOLE_REJECT:
+                                       req.r.rtm_type = RTN_UNREACHABLE;
+                                       break;
+                               default:
+                                       req.r.rtm_type = RTN_BLACKHOLE;
+                                       break;
+                               }
+                               goto skip;
+                       }
                        if (CHECK_FLAG(nexthop->flags,
                                       NEXTHOP_FLAG_RECURSIVE)) {
                                if (!setsrc) {