From f4517a795d9b719b220fa9013810c1a234e69568 Mon Sep 17 00:00:00 2001 From: Richard Wu Date: Wed, 3 Jun 2020 09:44:16 +0800 Subject: [PATCH 1/2] zebra: Fix zebra crashed in building FPM netlink message when bgp sends aggregation routes to zebra. Issue: When BGP sends aggregation routes to zebra, the next hop is black hole. Then Zebra will try to build the netlink FPM message, but there is no next hop as it is a black hole route. Then the netlink_route_info_fill function returns 0. In the result, zebra will crashed in "assert(data_len)" of zfpm_build_route_updates. This issue also happen when I create a static black hole route via staticd. Fix: As the netlink message of the blackhole route is legal, it should return success. Signed-off-by: Richard Wu (cherry picked from commit b0e9567ed162da708f8d0b3a3caf87cd03b62e96) --- zebra/zebra_fpm_netlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zebra/zebra_fpm_netlink.c b/zebra/zebra_fpm_netlink.c index 00909df1db..0e3d99cfb6 100644 --- a/zebra/zebra_fpm_netlink.c +++ b/zebra/zebra_fpm_netlink.c @@ -339,7 +339,7 @@ static int netlink_route_info_fill(netlink_route_info_t *ri, int cmd, } /* If there is no useful nexthop then return. */ - if (ri->num_nhs == 0) { + if (ri->rtm_type != RTN_BLACKHOLE && ri->num_nhs == 0) { zfpm_debug("netlink_encode_route(): No useful nexthop."); return 0; } From 75740b9c79afdc05f8a444ede41b144e45231027 Mon Sep 17 00:00:00 2001 From: Duncan Eastoe Date: Mon, 28 Sep 2020 12:51:19 +0100 Subject: [PATCH 2/2] zebra: fix FPM abort for unreach/prohibit routes f4517a795d9b719b220fa9013810c1a234e69568 fixed an issue whereby zebra would abort while building an update for a blackhole route. The same issue, `assert(data_len)` failing in `zfpm_build_route_updates()`, can be observed when building updates for unreachable and prohibit routes. To address this `netlink_route_info_fill()` is updated to not indicate failure, due to lack of nexthops, for any blackhole routes. Signed-off-by: Duncan Eastoe (cherry picked from commit 94f7786375030e08063cdae5b4577edf26adb456) --- zebra/zebra_fpm_netlink.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/zebra/zebra_fpm_netlink.c b/zebra/zebra_fpm_netlink.c index 0e3d99cfb6..01d2674ccf 100644 --- a/zebra/zebra_fpm_netlink.c +++ b/zebra/zebra_fpm_netlink.c @@ -338,10 +338,18 @@ static int netlink_route_info_fill(netlink_route_info_t *ri, int cmd, } } - /* If there is no useful nexthop then return. */ - if (ri->rtm_type != RTN_BLACKHOLE && ri->num_nhs == 0) { - zfpm_debug("netlink_encode_route(): No useful nexthop."); - return 0; + if (ri->num_nhs == 0) { + switch (ri->rtm_type) { + case RTN_PROHIBIT: + case RTN_UNREACHABLE: + case RTN_BLACKHOLE: + break; + default: + /* If there is no useful nexthop then return. */ + zfpm_debug( + "netlink_encode_route(): No useful nexthop."); + return 0; + } } return 1;