summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_advertise.c
diff options
context:
space:
mode:
Diffstat (limited to 'bgpd/bgp_advertise.c')
-rw-r--r--bgpd/bgp_advertise.c55
1 files changed, 46 insertions, 9 deletions
diff --git a/bgpd/bgp_advertise.c b/bgpd/bgp_advertise.c
index ecf531f7..43573b59 100644
--- a/bgpd/bgp_advertise.c
+++ b/bgpd/bgp_advertise.c
@@ -26,12 +26,14 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#include "hash.h"
#include "thread.h"
#include "filter.h"
+#include "linklist.h"
#include "bgpd/bgpd.h"
#include "bgpd/bgp_table.h"
#include "bgpd/bgp_route.h"
#include "bgpd/bgp_advertise.h"
#include "bgpd/bgp_attr.h"
+#include "bgpd/bgp_debug.h"
#include "bgpd/bgp_aspath.h"
#include "bgpd/bgp_packet.h"
#include "bgpd/bgp_fsm.h"
@@ -186,10 +188,12 @@ bgp_advertise_clean (struct peer *peer, struct bgp_adj_out *adj,
struct bgp_advertise *adv;
struct bgp_advertise_attr *baa;
struct bgp_advertise *next;
+ struct bgp_advertise_fifo *fhead;
adv = adj->adv;
baa = adv->baa;
next = NULL;
+ fhead = (struct bgp_advertise_fifo *)&peer->sync[afi][safi]->withdraw;
if (baa)
{
@@ -201,10 +205,12 @@ bgp_advertise_clean (struct peer *peer, struct bgp_adj_out *adj,
/* Unintern BGP advertise attribute. */
bgp_advertise_unintern (peer->hash[afi][safi], baa);
+
+ fhead = (struct bgp_advertise_fifo *)&peer->sync[afi][safi]->update;
}
/* Unlink myself from advertisement FIFO. */
- FIFO_DEL (adv);
+ BGP_ADV_FIFO_DEL (fhead, adv);
/* Free memory. */
bgp_advertise_free (adj->adv);
@@ -264,7 +270,24 @@ bgp_adj_out_set (struct bgp_node *rn, struct peer *peer, struct prefix *p,
/* Add new advertisement to advertisement attribute list. */
bgp_advertise_add (adv->baa, adv);
- FIFO_ADD (&peer->sync[afi][safi]->update, &adv->fifo);
+ BGP_ADV_FIFO_ADD (&peer->sync[afi][safi]->update, &adv->fifo);
+
+ /*
+ * Schedule write thread (by triggering adjustment of MRAI timer) only if
+ * update FIFO has grown. Otherwise, it will be done upon the work queue
+ * being fully processed. Only adjust timer if needed.
+ */
+ if (!BGP_ROUTE_ADV_HOLD(peer->bgp) &&
+ (BGP_ADV_FIFO_COUNT(&peer->sync[afi][safi]->update) >=
+ peer->bgp->adv_quanta))
+ {
+ if (!peer->radv_adjusted)
+ {
+ if (bgp_debug_update(peer, NULL, 0))
+ zlog_debug("%s scheduling MRAI timer after adj_out_set", peer->host);
+ bgp_adjust_routeadv(peer);
+ }
+ }
}
void
@@ -298,10 +321,24 @@ bgp_adj_out_unset (struct bgp_node *rn, struct peer *peer, struct prefix *p,
adv->adj = adj;
/* Add to synchronization entry for withdraw announcement. */
- FIFO_ADD (&peer->sync[afi][safi]->withdraw, &adv->fifo);
-
- /* Schedule packet write. */
- BGP_WRITE_ON (peer->t_write, bgp_write, peer->fd);
+ BGP_ADV_FIFO_ADD (&peer->sync[afi][safi]->withdraw, &adv->fifo);
+
+ /*
+ * Schedule write thread only if withdraw FIFO has grown. Otherwise,
+ * it will be done upon the work queue being fully processed.
+ */
+ if (!BGP_ROUTE_ADV_HOLD(peer->bgp) &&
+ (BGP_ADV_FIFO_COUNT(&peer->sync[afi][safi]->withdraw) >=
+ peer->bgp->wd_quanta))
+ {
+ if (!peer->t_write)
+ {
+ if (bgp_debug_update(peer, NULL, 0))
+ zlog_debug("%s scheduling write thread after adj_out_unset",
+ peer->host);
+ BGP_WRITE_ON (peer->t_write, bgp_write, peer->fd);
+ }
+ }
}
else
{
@@ -391,9 +428,9 @@ bgp_sync_init (struct peer *peer)
{
sync = XCALLOC (MTYPE_BGP_SYNCHRONISE,
sizeof (struct bgp_synchronize));
- FIFO_INIT (&sync->update);
- FIFO_INIT (&sync->withdraw);
- 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);
}