]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: Actually release peer from bgp_peer hash
authorDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 31 May 2018 16:56:21 +0000 (12:56 -0400)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Mon, 4 Jun 2018 11:16:29 +0000 (13:16 +0200)
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 <sharpd@cumulusnetworks.com>
bgpd/bgpd.c

index 3f4e4eeacb73f4c215388169db7ee58fa6f199b4..3613503559b138654c0d20af14bcaf30aba14610 100644 (file)
@@ -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);
 }