From: Donald Sharp Date: Fri, 12 Oct 2018 12:44:15 +0000 (-0400) Subject: bgpd: Cleanup bgp_route_map_process_update to be readable X-Git-Tag: frr-7.1-dev~108^2~7 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=c983710570ea69a086588ac83265b6b30695a39c;p=matthieu%2Ffrr.git bgpd: Cleanup bgp_route_map_process_update to be readable Cleanup the bgp_route_map_process_update code to be a bit easier to read as that it approached the right side of the 80 column limit a whole bunch and became hard to read. Signed-off-by: Donald Sharp --- diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index 8093ffe49f..73b01b6b2d 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -3228,32 +3228,25 @@ static void bgp_route_map_process_update(struct bgp *bgp, const char *rmap_name, for (bn = bgp_table_top(bgp->route[afi][safi]); bn; bn = bgp_route_next(bn)) { bgp_static = bgp_static_get_node_info(bn); - if (bgp_static != NULL) { - if (bgp_static->rmap.name - && (strcmp(rmap_name, bgp_static->rmap.name) - == 0)) { - - bgp_static->rmap.map = map; - - if (route_update) - if (!bgp_static->backdoor) { - if (bgp_debug_zebra( - &bn->p)) - zlog_debug( - "Processing route_map %s update on " - "static route %s", - rmap_name, - inet_ntop( - bn->p.family, - &bn->p.u.prefix, - buf, - INET6_ADDRSTRLEN)); - bgp_static_update( - bgp, &bn->p, - bgp_static, afi, - safi); - } - } + if (!bgp_static) + continue; + + if (!bgp_static->rmap.name + || (strcmp(rmap_name, bgp_static->rmap.name) != 0)) + continue; + + bgp_static->rmap.map = map; + + if (route_update && !bgp_static->backdoor) { + if (bgp_debug_zebra(&bn->p)) + zlog_debug( + "Processing route_map %s update on static route %s", + rmap_name, + inet_ntop(bn->p.family, + &bn->p.u.prefix, buf, + INET6_ADDRSTRLEN)); + bgp_static_update(bgp, &bn->p, bgp_static, afi, + safi); } } } @@ -3269,38 +3262,38 @@ static void bgp_route_map_process_update(struct bgp *bgp, const char *rmap_name, continue; for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { - if (red->rmap.name - && (strcmp(rmap_name, red->rmap.name) - == 0)) { - red->rmap.map = map; - - if (route_update) { - if (BGP_DEBUG(zebra, ZEBRA)) - zlog_debug( - "Processing route_map %s update on " - "redistributed routes", - rmap_name); - - bgp_redistribute_resend( - bgp, afi, i, + if (!red->rmap.name + || (strcmp(rmap_name, red->rmap.name) != 0)) + continue; + + red->rmap.map = map; + + if (!route_update) + continue; + + if (BGP_DEBUG(zebra, ZEBRA)) + zlog_debug( + "Processing route_map %s update on redistributed routes", + rmap_name); + + bgp_redistribute_resend(bgp, afi, i, red->instance); - } - } } } /* for type5 command route-maps */ FOREACH_AFI_SAFI (afi, safi) { - if (bgp->adv_cmd_rmap[afi][safi].name - && strcmp(rmap_name, bgp->adv_cmd_rmap[afi][safi].name) - == 0) { - if (BGP_DEBUG(zebra, ZEBRA)) - zlog_debug( - "Processing route_map %s update on advertise type5 route command", - rmap_name); - bgp_evpn_withdraw_type5_routes(bgp, afi, safi); - bgp_evpn_advertise_type5_routes(bgp, afi, safi); - } + if (!bgp->adv_cmd_rmap[afi][safi].name + || strcmp(rmap_name, bgp->adv_cmd_rmap[afi][safi].name) + != 0) + continue; + + if (BGP_DEBUG(zebra, ZEBRA)) + zlog_debug( + "Processing route_map %s update on advertise type5 route command", + rmap_name); + bgp_evpn_withdraw_type5_routes(bgp, afi, safi); + bgp_evpn_advertise_type5_routes(bgp, afi, safi); } }