summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@diac24.net>2019-04-21 18:17:45 +0200
committerDavid Lamparter <equinox@diac24.net>2019-04-27 19:33:45 +0200
commita274fef86899e1907b81f3c28bf5e3f978eea6ad (patch)
treefc519b40def7b4701c392603fef7bb76a3adabc0
parent4bef0ec4fbe97c7865f1de676d22832344167bab (diff)
bgpd: replace ADV_FIFO with DECLARE_LIST
The FIFO_* stuff in lib/fifo.h is no different from a simple unsorted list. Just use DECLARE_LIST here so we can get rid of FIFO_*. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
-rw-r--r--bgpd/bgp_advertise.c6
-rw-r--r--bgpd/bgp_advertise.h51
-rw-r--r--bgpd/bgp_updgrp.c6
-rw-r--r--bgpd/bgp_updgrp.h6
-rw-r--r--bgpd/bgp_updgrp_adv.c12
-rw-r--r--bgpd/bgp_updgrp_packet.c8
6 files changed, 28 insertions, 61 deletions
diff --git a/bgpd/bgp_advertise.c b/bgpd/bgp_advertise.c
index 05eeeca156..c9f68d037b 100644
--- a/bgpd/bgp_advertise.c
+++ b/bgpd/bgp_advertise.c
@@ -241,9 +241,9 @@ 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;
}
}
diff --git a/bgpd/bgp_advertise.h b/bgpd/bgp_advertise.h
index 9aa5a0eaff..cc845b93e7 100644
--- a/bgpd/bgp_advertise.h
+++ b/bgpd/bgp_advertise.h
@@ -21,16 +21,11 @@
#ifndef _QUAGGA_BGP_ADVERTISE_H
#define _QUAGGA_BGP_ADVERTISE_H
-#include <lib/fifo.h>
+#include "lib/typesafe.h"
-struct update_subgroup;
+PREDECL_LIST(bgp_adv_fifo)
-/* BGP advertise FIFO. */
-struct bgp_advertise_fifo {
- struct bgp_advertise *next;
- struct bgp_advertise *prev;
- uint32_t count;
-};
+struct update_subgroup;
/* BGP advertise attribute. */
struct bgp_advertise_attr {
@@ -46,7 +41,7 @@ struct bgp_advertise_attr {
struct bgp_advertise {
/* FIFO for advertisement. */
- struct bgp_advertise_fifo fifo;
+ struct bgp_adv_fifo_item fifo;
/* Link list for same attribute advertise. */
struct bgp_advertise *next;
@@ -65,6 +60,8 @@ struct bgp_advertise {
struct bgp_path_info *pathi;
};
+DECLARE_LIST(bgp_adv_fifo, struct bgp_advertise, fifo)
+
/* BGP adjacency out. */
struct bgp_adj_out {
/* RB Tree of adjacency entries */
@@ -110,9 +107,9 @@ struct bgp_adj_in {
/* BGP advertisement list. */
struct bgp_synchronize {
- struct bgp_advertise_fifo update;
- struct bgp_advertise_fifo withdraw;
- struct bgp_advertise_fifo withdraw_low;
+ struct bgp_adv_fifo_head update;
+ struct bgp_adv_fifo_head withdraw;
+ struct bgp_adv_fifo_head withdraw_low;
};
/* BGP adjacency linked list. */
@@ -138,36 +135,6 @@ struct bgp_synchronize {
#define BGP_ADJ_IN_ADD(N, A) BGP_PATH_INFO_ADD(N, A, adj_in)
#define BGP_ADJ_IN_DEL(N, A) BGP_PATH_INFO_DEL(N, A, adj_in)
-#define BGP_ADV_FIFO_ADD(F, N) \
- do { \
- FIFO_ADD((F), (N)); \
- (F)->count++; \
- } while (0)
-
-#define BGP_ADV_FIFO_DEL(F, N) \
- do { \
- FIFO_DEL((N)); \
- (F)->count--; \
- } while (0)
-
-#define BGP_ADV_FIFO_INIT(F) \
- do { \
- FIFO_INIT((F)); \
- (F)->count = 0; \
- } while (0)
-
-#define BGP_ADV_FIFO_COUNT(F) (F)->count
-
-#define BGP_ADV_FIFO_EMPTY(F) \
- (((struct bgp_advertise_fifo *)(F))->next \
- == (struct bgp_advertise *)(F))
-
-#define BGP_ADV_FIFO_HEAD(F) \
- ((((struct bgp_advertise_fifo *)(F))->next \
- == (struct bgp_advertise *)(F)) \
- ? NULL \
- : (F)->next)
-
/* Prototypes. */
extern int bgp_adj_out_lookup(struct peer *, struct bgp_node *, uint32_t);
extern void bgp_adj_in_set(struct bgp_node *, struct peer *, struct attr *,
diff --git a/bgpd/bgp_updgrp.c b/bgpd/bgp_updgrp.c
index 49a435120d..57717bf59b 100644
--- a/bgpd/bgp_updgrp.c
+++ b/bgpd/bgp_updgrp.c
@@ -83,9 +83,9 @@ static void sync_init(struct update_subgroup *subgrp)
{
subgrp->sync =
XCALLOC(MTYPE_BGP_SYNCHRONISE, sizeof(struct bgp_synchronize));
- BGP_ADV_FIFO_INIT(&subgrp->sync->update);
- BGP_ADV_FIFO_INIT(&subgrp->sync->withdraw);
- BGP_ADV_FIFO_INIT(&subgrp->sync->withdraw_low);
+ bgp_adv_fifo_init(&subgrp->sync->update);
+ bgp_adv_fifo_init(&subgrp->sync->withdraw);
+ bgp_adv_fifo_init(&subgrp->sync->withdraw_low);
subgrp->hash =
hash_create(baa_hash_key, baa_hash_cmp, "BGP SubGroup Hash");
diff --git a/bgpd/bgp_updgrp.h b/bgpd/bgp_updgrp.h
index 6b3bf9d1f7..39e67bf608 100644
--- a/bgpd/bgp_updgrp.h
+++ b/bgpd/bgp_updgrp.h
@@ -590,9 +590,9 @@ static inline void bgp_announce_peer(struct peer *peer)
*/
static inline int advertise_list_is_empty(struct update_subgroup *subgrp)
{
- if (!BGP_ADV_FIFO_EMPTY(&subgrp->sync->update)
- || !BGP_ADV_FIFO_EMPTY(&subgrp->sync->withdraw)
- || !BGP_ADV_FIFO_EMPTY(&subgrp->sync->withdraw_low)) {
+ if (bgp_adv_fifo_count(&subgrp->sync->update)
+ || bgp_adv_fifo_count(&subgrp->sync->withdraw)
+ || bgp_adv_fifo_count(&subgrp->sync->withdraw_low)) {
return 0;
}
diff --git a/bgpd/bgp_updgrp_adv.c b/bgpd/bgp_updgrp_adv.c
index 3870df593f..b64c51f341 100644
--- a/bgpd/bgp_updgrp_adv.c
+++ b/bgpd/bgp_updgrp_adv.c
@@ -422,7 +422,7 @@ bgp_advertise_clean_subgroup(struct update_subgroup *subgrp,
struct bgp_advertise *adv;
struct bgp_advertise_attr *baa;
struct bgp_advertise *next;
- struct bgp_advertise_fifo *fhead;
+ struct bgp_adv_fifo_head *fhead;
adv = adj->adv;
baa = adv->baa;
@@ -444,7 +444,7 @@ bgp_advertise_clean_subgroup(struct update_subgroup *subgrp,
/* Unlink myself from advertisement FIFO. */
- BGP_ADV_FIFO_DEL(fhead, adv);
+ bgp_adv_fifo_del(fhead, adv);
/* Free memory. */
bgp_advertise_free(adj->adv);
@@ -507,7 +507,7 @@ void bgp_adj_out_set_subgroup(struct bgp_node *rn,
* If the update adv list is empty, trigger the member peers'
* mrai timers so the socket writes can happen.
*/
- if (BGP_ADV_FIFO_EMPTY(&subgrp->sync->update)) {
+ if (!bgp_adv_fifo_count(&subgrp->sync->update)) {
struct peer_af *paf;
SUBGRP_FOREACH_PEER (subgrp, paf) {
@@ -515,7 +515,7 @@ void bgp_adj_out_set_subgroup(struct bgp_node *rn,
}
}
- BGP_ADV_FIFO_ADD(&subgrp->sync->update, &adv->fifo);
+ bgp_adv_fifo_add_tail(&subgrp->sync->update, adv);
subgrp->version = max(subgrp->version, rn->version);
}
@@ -550,11 +550,11 @@ void bgp_adj_out_unset_subgroup(struct bgp_node *rn,
/* Note if we need to trigger a packet write */
trigger_write =
- BGP_ADV_FIFO_EMPTY(&subgrp->sync->withdraw);
+ !bgp_adv_fifo_count(&subgrp->sync->withdraw);
/* Add to synchronization entry for withdraw
* announcement. */
- BGP_ADV_FIFO_ADD(&subgrp->sync->withdraw, &adv->fifo);
+ bgp_adv_fifo_add_tail(&subgrp->sync->withdraw, adv);
if (trigger_write)
subgroup_trigger_write(subgrp);
diff --git a/bgpd/bgp_updgrp_packet.c b/bgpd/bgp_updgrp_packet.c
index 66e306cba2..3556b236a7 100644
--- a/bgpd/bgp_updgrp_packet.c
+++ b/bgpd/bgp_updgrp_packet.c
@@ -664,11 +664,11 @@ int subgroup_packets_to_build(struct update_subgroup *subgrp)
if (!subgrp)
return 0;
- adv = BGP_ADV_FIFO_HEAD(&subgrp->sync->withdraw);
+ adv = bgp_adv_fifo_first(&subgrp->sync->withdraw);
if (adv)
return 1;
- adv = BGP_ADV_FIFO_HEAD(&subgrp->sync->update);
+ adv = bgp_adv_fifo_first(&subgrp->sync->update);
if (adv)
return 1;
@@ -725,7 +725,7 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
addpath_encode = bgp_addpath_encode_tx(peer, afi, safi);
addpath_overhead = addpath_encode ? BGP_ADDPATH_ID_LEN : 0;
- adv = BGP_ADV_FIFO_HEAD(&subgrp->sync->update);
+ adv = bgp_adv_fifo_first(&subgrp->sync->update);
while (adv) {
assert(adv->rn);
rn = adv->rn;
@@ -966,7 +966,7 @@ struct bpacket *subgroup_withdraw_packet(struct update_subgroup *subgrp)
addpath_encode = bgp_addpath_encode_tx(peer, afi, safi);
addpath_overhead = addpath_encode ? BGP_ADDPATH_ID_LEN : 0;
- while ((adv = BGP_ADV_FIFO_HEAD(&subgrp->sync->withdraw)) != NULL) {
+ while ((adv = bgp_adv_fifo_first(&subgrp->sync->withdraw)) != NULL) {
assert(adv->rn);
adj = adv->adj;
rn = adv->rn;