From d12b745c9080e283e66140de08d34282d588a885 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 31 May 2018 12:56:21 -0400 Subject: [PATCH] bgpd: Actually release peer from bgp_peer hash When we are determining the state of a peer, we sometimes detect that we should update the peer->su. The bgp->peer_hash keeps a hash of peers based upon the peer->su. This requires us to release the stored value before we re-insert it. Signed-off-by: Donald Sharp --- bgpd/bgpd.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 3f4e4eeacb..3613503559 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -1374,6 +1374,12 @@ void bgp_peer_conf_if_to_su_update(struct peer *peer) if (!peer->conf_if) return; + /* + * Our peer structure is stored in the bgp->peerhash + * release it before we modify anything. + */ + hash_release(peer->bgp->peerhash, peer); + prev_family = peer->su.sa.sa_family; if ((ifp = if_lookup_by_name(peer->conf_if, peer->bgp->vrf_id))) { peer->ifp = ifp; @@ -1412,8 +1418,9 @@ void bgp_peer_conf_if_to_su_update(struct peer *peer) memset(&peer->su.sin6.sin6_addr, 0, sizeof(struct in6_addr)); } - /* Since our su changed we need to del/add peer to the peerhash */ - hash_release(peer->bgp->peerhash, peer); + /* + * Since our su changed we need to del/add peer to the peerhash + */ hash_get(peer->bgp->peerhash, peer, hash_alloc_intern); } -- 2.39.5