]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: Unlock dest if we return earlier for aggregate install
authorDonatas Abraitis <donatas@opensourcerouting.org>
Mon, 13 Mar 2023 20:26:09 +0000 (22:26 +0200)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Wed, 15 Mar 2023 11:34:55 +0000 (13:34 +0200)
If the bgp is in shutdown state or so, do not forget to unlock the dest node.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
bgpd/bgp_route.c
bgpd/bgp_route.h
bgpd/bgp_routemap.c

index 56f548bfd5483ea6bfc60f4a1ed09f14505785e9..a307e32589ef692505182152940397c7750aaa3e 100644 (file)
@@ -7243,7 +7243,7 @@ static struct bgp_aggregate *bgp_aggregate_new(void)
        return XCALLOC(MTYPE_BGP_AGGREGATE, sizeof(struct bgp_aggregate));
 }
 
-static void bgp_aggregate_free(struct bgp_aggregate *aggregate)
+void bgp_aggregate_free(struct bgp_aggregate *aggregate)
 {
        XFREE(MTYPE_ROUTE_MAP_NAME, aggregate->suppress_map_name);
        route_map_counter_decrement(aggregate->suppress_map);
@@ -7646,7 +7646,7 @@ static void bgp_aggregate_med_update(struct bgp_aggregate *aggregate,
 }
 
 /* Update an aggregate as routes are added/removed from the BGP table */
-void bgp_aggregate_route(struct bgp *bgp, const struct prefix *p, afi_t afi,
+bool bgp_aggregate_route(struct bgp *bgp, const struct prefix *p, afi_t afi,
                         safi_t safi, struct bgp_aggregate *aggregate)
 {
        struct bgp_table *table;
@@ -7665,10 +7665,8 @@ void bgp_aggregate_route(struct bgp *bgp, const struct prefix *p, afi_t afi,
         * then do not create aggregate route
         */
        if (CHECK_FLAG(bgp->flags, BGP_FLAG_DELETE_IN_PROGRESS) ||
-           (bgp->peer_self == NULL)) {
-               bgp_aggregate_free(aggregate);
-               return;
-       }
+           bgp->peer_self == NULL)
+               return false;
 
        /* Initialize and test routes for MED difference. */
        if (aggregate->match_med)
@@ -7860,6 +7858,8 @@ void bgp_aggregate_route(struct bgp *bgp, const struct prefix *p, afi_t afi,
        bgp_aggregate_install(bgp, afi, safi, p, origin, aspath, community,
                              ecommunity, lcommunity, atomic_aggregate,
                              aggregate);
+
+       return true;
 }
 
 void bgp_aggregate_delete(struct bgp *bgp, const struct prefix *p, afi_t afi,
@@ -8502,7 +8502,10 @@ static int bgp_aggregate_set(struct vty *vty, const char *prefix_str, afi_t afi,
        bgp_dest_set_bgp_aggregate_info(dest, aggregate);
 
        /* Aggregate address insert into BGP routing table. */
-       bgp_aggregate_route(bgp, &p, afi, safi, aggregate);
+       if (!bgp_aggregate_route(bgp, &p, afi, safi, aggregate)) {
+               bgp_aggregate_free(aggregate);
+               bgp_dest_unlock_node(dest);
+       }
 
        return CMD_SUCCESS;
 }
index 66cc62ab090f5f708d1fdde743c126d0cd938790..088baf9a867555a2aea487cf2b99f210516cdd91 100644 (file)
@@ -766,7 +766,7 @@ extern void bgp_config_write_distance(struct vty *, struct bgp *, afi_t,
 extern void bgp_aggregate_delete(struct bgp *bgp, const struct prefix *p,
                                 afi_t afi, safi_t safi,
                                 struct bgp_aggregate *aggregate);
-extern void bgp_aggregate_route(struct bgp *bgp, const struct prefix *p,
+extern bool bgp_aggregate_route(struct bgp *bgp, const struct prefix *p,
                                afi_t afi, safi_t safi,
                                struct bgp_aggregate *aggregate);
 extern void bgp_aggregate_increment(struct bgp *bgp, const struct prefix *p,
@@ -876,6 +876,7 @@ extern void bgp_path_info_free_with_caller(const char *caller,
 extern void bgp_path_info_add_with_caller(const char *caller,
                                          struct bgp_dest *dest,
                                          struct bgp_path_info *pi);
+extern void bgp_aggregate_free(struct bgp_aggregate *aggregate);
 #define bgp_path_info_add(A, B)                                                \
        bgp_path_info_add_with_caller(__func__, (A), (B))
 #define bgp_path_info_free(B) bgp_path_info_free_with_caller(__func__, (B))
index 8fd46d00af771347c1648d61f29588c3d78d0a5d..b7bef75123b29760eca3fd36988dc542271d8db9 100644 (file)
@@ -4266,8 +4266,8 @@ static void bgp_route_map_process_update(struct bgp *bgp, const char *rmap_name,
                                                inet_ntop(bn_p->family,
                                                          &bn_p->u.prefix, buf,
                                                          sizeof(buf)));
-                               bgp_aggregate_route(bgp, bn_p, afi, safi,
-                                                   aggregate);
+                               (void)bgp_aggregate_route(bgp, bn_p, afi, safi,
+                                                         aggregate);
                        }
                }
        }