From: David Lamparter Date: Fri, 5 Feb 2010 03:58:46 +0000 (+0100) Subject: zebra: netlink: get blackhole routes from kernel X-Git-Tag: frr-4.0-dev~365^2~1 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=e655a03c18b16345aba74be59d3a6a83741e143e;p=mirror%2Ffrr.git zebra: netlink: get blackhole routes from kernel support processing of RTN_BLACKHOLE et al. from kernel and dump them into appropriate blackhole rib entries. Signed-off-by: David Lamparter --- diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index fa38c21abf..0076e91569 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -240,13 +240,27 @@ static int netlink_route_change_read_unicast(struct sockaddr_nl *snl, void *gate = NULL; void *prefsrc = NULL; /* IPv4 preferred source host address */ void *src = NULL; /* IPv6 srcdest source prefix */ + enum blackhole_type bh_type = BLACKHOLE_UNSPEC; rtm = NLMSG_DATA(h); if (startup && h->nlmsg_type != RTM_NEWROUTE) return 0; - if (startup && rtm->rtm_type != RTN_UNICAST) + switch (rtm->rtm_type) { + case RTN_UNICAST: + break; + case RTN_BLACKHOLE: + bh_type = BLACKHOLE_NULL; + break; + case RTN_UNREACHABLE: + bh_type = BLACKHOLE_REJECT; + break; + case RTN_PROHIBIT: + bh_type = BLACKHOLE_ADMINPROHIB; + break; + default: return 0; + } len = h->nlmsg_len - NLMSG_LENGTH(sizeof(struct rtmsg)); if (len < 0) @@ -380,8 +394,10 @@ static int netlink_route_change_read_unicast(struct sockaddr_nl *snl, nh.type = (afi == AFI_IP) ? NEXTHOP_TYPE_IPV4 : NEXTHOP_TYPE_IPV6; - else + else { nh.type = NEXTHOP_TYPE_BLACKHOLE; + nh.bh_type = bh_type; + } nh.ifindex = index; if (prefsrc) memcpy(&nh.src, prefsrc, sz); @@ -623,18 +639,10 @@ int netlink_route_change(struct sockaddr_nl *snl, struct nlmsghdr *h, if (len < 0) return -1; - switch (rtm->rtm_type) { - case RTN_UNICAST: - netlink_route_change_read_unicast(snl, h, ns_id, startup); - break; - case RTN_MULTICAST: + if (rtm->rtm_type == RTN_MULTICAST) netlink_route_change_read_multicast(snl, h, ns_id, startup); - break; - default: - return 0; - break; - } - + else + netlink_route_change_read_unicast(snl, h, ns_id, startup); return 0; }