]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: allow blackhole routes from the kernel to be deleted
authorRenato Westphal <renato@opensourcerouting.org>
Fri, 1 Sep 2017 00:13:23 +0000 (21:13 -0300)
committerRenato Westphal <renato@opensourcerouting.org>
Fri, 1 Sep 2017 01:14:48 +0000 (22:14 -0300)
Fixes the following bug:
% ip -6 route add unreachable 4000::/64
% ip -6 route del unreachable 4000::/64
% vtysh -c "show ipv6 route"
[snip]
K>* 4000::/64 [0/1024] unreachable (ICMP unreachable)

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
zebra/rt_netlink.c

index c58a7aa2fad99e264323aec10bae7bed97720786..f05025e630390e2bae5e75b613320415c2b046b4 100644 (file)
@@ -491,17 +491,26 @@ static int netlink_route_change_read_unicast(struct sockaddr_nl *snl,
                        size_t sz = (afi == AFI_IP) ? 4 : 16;
 
                        memset(&nh, 0, sizeof(nh));
-                       if (index && !gate)
-                               nh.type = NEXTHOP_TYPE_IFINDEX;
-                       else if (index && gate)
-                               nh.type = (afi == AFI_IP)
-                                                 ? NEXTHOP_TYPE_IPV4_IFINDEX
-                                                 : NEXTHOP_TYPE_IPV6_IFINDEX;
-                       else if (!index && gate)
-                               nh.type = (afi == AFI_IP) ? NEXTHOP_TYPE_IPV4
+                       if (bh_type == BLACKHOLE_UNSPEC) {
+                               if (index && !gate)
+                                       nh.type = NEXTHOP_TYPE_IFINDEX;
+                               else if (index && gate)
+                                       nh.type =
+                                               (afi == AFI_IP)
+                                                       ? NEXTHOP_TYPE_IPV4_IFINDEX
+                                                       : NEXTHOP_TYPE_IPV6_IFINDEX;
+                               else if (!index && gate)
+                                       nh.type = (afi == AFI_IP)
+                                                         ? NEXTHOP_TYPE_IPV4
                                                          : NEXTHOP_TYPE_IPV6;
-                       else
+                               else {
+                                       nh.type = NEXTHOP_TYPE_BLACKHOLE;
+                                       nh.bh_type = BLACKHOLE_UNSPEC;
+                               }
+                       } else {
                                nh.type = NEXTHOP_TYPE_BLACKHOLE;
+                               nh.bh_type = bh_type;
+                       }
                        nh.ifindex = index;
                        if (gate)
                                memcpy(&nh.gate, gate, sz);