]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_advertise.c
Merge pull request #5793 from ton31337/fix/formatting_show_bgp_summary_failed
[mirror_frr.git] / bgpd / bgp_advertise.c
index 840cc35751f0965c7a1f441f898ca377c2d286ad..8d1c83cf5f4650d9655e486d1fd691e434598ff0 100644 (file)
@@ -45,8 +45,8 @@
    peer.  */
 struct bgp_advertise_attr *baa_new(void)
 {
-       return (struct bgp_advertise_attr *)XCALLOC(
-               MTYPE_BGP_ADVERTISE_ATTR, sizeof(struct bgp_advertise_attr));
+       return XCALLOC(MTYPE_BGP_ADVERTISE_ATTR,
+                      sizeof(struct bgp_advertise_attr));
 }
 
 static void baa_free(struct bgp_advertise_attr *baa)
@@ -64,14 +64,14 @@ static void *baa_hash_alloc(void *p)
        return baa;
 }
 
-unsigned int baa_hash_key(void *p)
+unsigned int baa_hash_key(const void *p)
 {
-       struct bgp_advertise_attr *baa = (struct bgp_advertise_attr *)p;
+       const struct bgp_advertise_attr *baa = p;
 
        return attrhash_key_make(baa->attr);
 }
 
-int baa_hash_cmp(const void *p1, const void *p2)
+bool baa_hash_cmp(const void *p1, const void *p2)
 {
        const struct bgp_advertise_attr *baa1 = p1;
        const struct bgp_advertise_attr *baa2 = p2;
@@ -84,15 +84,14 @@ int baa_hash_cmp(const void *p1, const void *p2)
    information.  */
 struct bgp_advertise *bgp_advertise_new(void)
 {
-       return (struct bgp_advertise *)XCALLOC(MTYPE_BGP_ADVERTISE,
-                                              sizeof(struct bgp_advertise));
+       return XCALLOC(MTYPE_BGP_ADVERTISE, sizeof(struct bgp_advertise));
 }
 
 void bgp_advertise_free(struct bgp_advertise *adv)
 {
-       if (adv->binfo)
-               bgp_info_unlock(
-                       adv->binfo); /* bgp_advertise bgp_info reference */
+       if (adv->pathi)
+               /* bgp_advertise bgp_path_info reference */
+               bgp_path_info_unlock(adv->pathi);
        XFREE(MTYPE_BGP_ADVERTISE, adv);
 }
 
@@ -146,7 +145,7 @@ void bgp_advertise_unintern(struct hash *hash, struct bgp_advertise_attr *baa)
 }
 
 int bgp_adj_out_lookup(struct peer *peer, struct bgp_node *rn,
-                      u_int32_t addpath_tx_id)
+                      uint32_t addpath_tx_id)
 {
        struct bgp_adj_out *adj;
        struct peer_af *paf;
@@ -154,7 +153,7 @@ int bgp_adj_out_lookup(struct peer *peer, struct bgp_node *rn,
        safi_t safi;
        int addpath_capable;
 
-       for (adj = rn->adj_out; adj; adj = adj->next)
+       RB_FOREACH (adj, bgp_adj_out_rb, &rn->adj_out)
                SUBGRP_FOREACH_PEER (adj->subgroup, paf)
                        if (paf->peer == peer) {
                                afi = SUBGRP_AFI(adj->subgroup);
@@ -179,7 +178,7 @@ int bgp_adj_out_lookup(struct peer *peer, struct bgp_node *rn,
 
 
 void bgp_adj_in_set(struct bgp_node *rn, struct peer *peer, struct attr *attr,
-                   u_int32_t addpath_id)
+                   uint32_t addpath_id)
 {
        struct bgp_adj_in *adj;
 
@@ -195,6 +194,7 @@ void bgp_adj_in_set(struct bgp_node *rn, struct peer *peer, struct attr *attr,
        adj = XCALLOC(MTYPE_BGP_ADJ_IN, sizeof(struct bgp_adj_in));
        adj->peer = peer_lock(peer); /* adj_in peer reference */
        adj->attr = bgp_attr_intern(attr);
+       adj->uptime = bgp_clock();
        adj->addpath_rx_id = addpath_id;
        BGP_ADJ_IN_ADD(rn, adj);
        bgp_lock_node(rn);
@@ -209,7 +209,7 @@ void bgp_adj_in_remove(struct bgp_node *rn, struct bgp_adj_in *bai)
 }
 
 int bgp_adj_in_unset(struct bgp_node *rn, struct peer *peer,
-                    u_int32_t addpath_id)
+                    uint32_t addpath_id)
 {
        struct bgp_adj_in *adj;
        struct bgp_adj_in *adj_next;
@@ -242,12 +242,10 @@ void bgp_sync_init(struct peer *peer)
        FOREACH_AFI_SAFI (afi, safi) {
                sync = XCALLOC(MTYPE_BGP_SYNCHRONISE,
                               sizeof(struct bgp_synchronize));
-               BGP_ADV_FIFO_INIT(&sync->update);
-               BGP_ADV_FIFO_INIT(&sync->withdraw);
-               BGP_ADV_FIFO_INIT(&sync->withdraw_low);
+               bgp_adv_fifo_init(&sync->update);
+               bgp_adv_fifo_init(&sync->withdraw);
+               bgp_adv_fifo_init(&sync->withdraw_low);
                peer->sync[afi][safi] = sync;
-               peer->hash[afi][safi] = hash_create(baa_hash_key, baa_hash_cmp,
-                                                   "BGP Sync Hash");
        }
 }
 
@@ -257,12 +255,6 @@ void bgp_sync_delete(struct peer *peer)
        safi_t safi;
 
        FOREACH_AFI_SAFI (afi, safi) {
-               if (peer->sync[afi][safi])
-                       XFREE(MTYPE_BGP_SYNCHRONISE, peer->sync[afi][safi]);
-               peer->sync[afi][safi] = NULL;
-
-               if (peer->hash[afi][safi])
-                       hash_free(peer->hash[afi][safi]);
-               peer->hash[afi][safi] = NULL;
+               XFREE(MTYPE_BGP_SYNCHRONISE, peer->sync[afi][safi]);
        }
 }