]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd: Cleanup bgp_route_map_process_update to be readable
authorDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 12 Oct 2018 12:44:15 +0000 (08:44 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 16 Nov 2018 14:43:35 +0000 (09:43 -0500)
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 <sharpd@cumulusnetworks.com>
bgpd/bgp_routemap.c

index 8093ffe49f6b8397cbe17bc80511290ff76d3119..73b01b6b2d253951af10d4540a8e1b8b925f5228 100644 (file)
@@ -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);
        }
 }