]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: bgp_adj_in_unset needs to return the dest pointer
authorDonald Sharp <sharpd@nvidia.com>
Sun, 10 Sep 2023 13:27:51 +0000 (09:27 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Mon, 11 Sep 2023 16:45:59 +0000 (12:45 -0400)
This is incase it has been freed ( it wont due to locking )
and then we need to ensure that we can continue to use
the pointer.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
bgpd/bgp_advertise.c
bgpd/bgp_advertise.h
bgpd/bgp_route.c

index c215611edfd9793a1da9a0842b7e150a9322fe4d..6f4916b3c31188eda4fe4a0e81223128525a723a 100644 (file)
@@ -197,13 +197,13 @@ void bgp_adj_in_remove(struct bgp_dest **dest, struct bgp_adj_in *bai)
        XFREE(MTYPE_BGP_ADJ_IN, bai);
 }
 
-bool bgp_adj_in_unset(struct bgp_dest *dest, struct peer *peer,
+bool bgp_adj_in_unset(struct bgp_dest **dest, struct peer *peer,
                      uint32_t addpath_id)
 {
        struct bgp_adj_in *adj;
        struct bgp_adj_in *adj_next;
 
-       adj = dest->adj_in;
+       adj = (*dest)->adj_in;
 
        if (!adj)
                return false;
@@ -212,11 +212,11 @@ bool bgp_adj_in_unset(struct bgp_dest *dest, struct peer *peer,
                adj_next = adj->next;
 
                if (adj->peer == peer && adj->addpath_rx_id == addpath_id)
-                       bgp_adj_in_remove(&dest, adj);
+                       bgp_adj_in_remove(dest, adj);
 
                adj = adj_next;
 
-               assert(dest);
+               assert(*dest);
        }
 
        return true;
index e597c56d1388f2a144d343b54ec4c84d70b4d769..94168e2fd7ccabb662e552703c86ce375a0930e3 100644 (file)
@@ -130,7 +130,7 @@ extern bool bgp_adj_out_lookup(struct peer *peer, struct bgp_dest *dest,
                               uint32_t addpath_tx_id);
 extern void bgp_adj_in_set(struct bgp_dest *dest, struct peer *peer,
                           struct attr *attr, uint32_t addpath_id);
-extern bool bgp_adj_in_unset(struct bgp_dest *dest, struct peer *peer,
+extern bool bgp_adj_in_unset(struct bgp_dest **dest, struct peer *peer,
                             uint32_t addpath_id);
 extern void bgp_adj_in_remove(struct bgp_dest **dest, struct bgp_adj_in *bai);
 
index e72ebe3ae7decd44eaf361a8a0abc35c8d2865f1..34d36a63756fa01c990b2c3e49f23ac5cce90e86 100644 (file)
@@ -5083,7 +5083,8 @@ void bgp_withdraw(struct peer *peer, const struct prefix *p,
         */
        if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)
            && peer != bgp->peer_self)
-               if (!bgp_adj_in_unset(dest, peer, addpath_id)) {
+               if (!bgp_adj_in_unset(&dest, peer, addpath_id)) {
+                       assert(dest);
                        peer->stat_pfx_dup_withdraw++;
 
                        if (bgp_debug_update(peer, p, NULL, 1)) {
@@ -5100,6 +5101,7 @@ void bgp_withdraw(struct peer *peer, const struct prefix *p,
                }
 
        /* Lookup withdrawn route. */
+       assert(dest);
        for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next)
                if (pi->peer == peer && pi->type == type
                    && pi->sub_type == sub_type