From: Renato Westphal Date: Fri, 1 Sep 2017 00:13:23 +0000 (-0300) Subject: zebra: allow blackhole routes from the kernel to be deleted X-Git-Tag: frr-4.0-dev~347^2~1 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=8ba5bd58aa7bb8de6c18dd4ebddecf142ae4012e;p=mirror%2Ffrr.git zebra: allow blackhole routes from the kernel to be deleted 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 --- diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index c58a7aa2fa..f05025e630 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -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);