]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Reduce the nesting level for bgp_clear_damp_route() 15911/head
authorDonatas Abraitis <donatas@opensourcerouting.org>
Thu, 2 May 2024 19:48:19 +0000 (22:48 +0300)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Fri, 3 May 2024 06:30:33 +0000 (09:30 +0300)
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
bgpd/bgp_route.c

index 5022ba36abe0f40d95ada0876d8c39f4af530252..8c24ff32b3b90525843bd989a33a9350e54ef8e0 100644 (file)
@@ -15839,42 +15839,38 @@ static int bgp_clear_damp_route(struct vty *vty, const char *view_name,
                }
        } else {
                dest = bgp_node_match(bgp->rib[afi][safi], &match);
-               if (dest != NULL) {
-                       const struct prefix *dest_p = bgp_dest_get_prefix(dest);
+               if (!dest)
+                       return CMD_SUCCESS;
 
-                       if (!prefix_check
-                           || dest_p->prefixlen == match.prefixlen) {
-                               pi = bgp_dest_get_bgp_path_info(dest);
-                               while (pi) {
-                                       if (pi->extra && pi->extra->damp_info) {
-                                               pi_temp = pi->next;
-                                               struct bgp_damp_info *bdi =
-                                                       pi->extra->damp_info;
-                                               if (bdi->lastrecord
-                                                   == BGP_RECORD_UPDATE) {
-                                                       bgp_aggregate_increment(
-                                                               bgp,
-                                                               bgp_dest_get_prefix(
-                                                                       bdi->dest),
-                                                               bdi->path,
-                                                               bdi->afi,
-                                                               bdi->safi);
-                                                       bgp_process(bgp,
-                                                                   bdi->dest,
-                                                                   bdi->path,
-                                                                   bdi->afi,
-                                                                   bdi->safi);
-                                               }
-                                               bgp_damp_info_free(pi->extra->damp_info,
-                                                                  NULL, 1);
-                                               pi = pi_temp;
-                                       } else
-                                               pi = pi->next;
-                               }
+               const struct prefix *dest_p = bgp_dest_get_prefix(dest);
+
+               if (prefix_check || dest_p->prefixlen != match.prefixlen)
+                       return CMD_SUCCESS;
+
+               pi = bgp_dest_get_bgp_path_info(dest);
+               while (pi) {
+                       if (!(pi->extra && pi->extra->damp_info)) {
+                               pi = pi->next;
+                               continue;
                        }
 
-                       bgp_dest_unlock_node(dest);
+                       pi_temp = pi->next;
+                       struct bgp_damp_info *bdi = pi->extra->damp_info;
+
+                       if (bdi->lastrecord != BGP_RECORD_UPDATE)
+                               continue;
+
+                       bgp_aggregate_increment(bgp,
+                                               bgp_dest_get_prefix(bdi->dest),
+                                               bdi->path, bdi->afi, bdi->safi);
+                       bgp_process(bgp, bdi->dest, bdi->path, bdi->afi,
+                                   bdi->safi);
+
+                       bgp_damp_info_free(pi->extra->damp_info, NULL, 1);
+                       pi = pi_temp;
                }
+
+               bgp_dest_unlock_node(dest);
        }
 
        return CMD_SUCCESS;