summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@nvidia.com>2024-09-09 10:26:13 -0400
committerDonald Sharp <sharpd@nvidia.com>2024-09-11 17:46:33 -0400
commit69b8857ab924049c494d76ffde4d6458efe80f14 (patch)
treea8ef8958123cd16593a30e2a7ced8ec4418c3028
parenta76a7d1b1266f112f279aef3a544b18409e2ca7a (diff)
bgpd: Allow BGP to process certain routes early
There is a need to be able to process certain bgp routes earlier than others. Especially when there is major trauma going on in the network. Start the ability for this to happen. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
-rw-r--r--bgpd/bgp_route.c28
-rw-r--r--bgpd/bgp_route.h12
2 files changed, 33 insertions, 7 deletions
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 3c0f0c8b53..4cf9a6b5f9 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -4011,8 +4011,9 @@ static struct bgp_process_queue *bgp_processq_alloc(struct bgp *bgp)
return pqnode;
}
-void bgp_process(struct bgp *bgp, struct bgp_dest *dest,
- struct bgp_path_info *pi, afi_t afi, safi_t safi)
+static void bgp_process_internal(struct bgp *bgp, struct bgp_dest *dest,
+ struct bgp_path_info *pi, afi_t afi,
+ safi_t safi, bool early_process)
{
#define ARBITRARY_PROCESS_QLEN 10000
struct work_queue *wq = bgp->process_queue;
@@ -4075,9 +4076,9 @@ void bgp_process(struct bgp *bgp, struct bgp_dest *dest,
struct work_queue_item *item = work_queue_last_item(wq);
pqnode = item->data;
- if (CHECK_FLAG(pqnode->flags, BGP_PROCESS_QUEUE_EOIU_MARKER)
- || pqnode->bgp != bgp
- || pqnode->queued >= ARBITRARY_PROCESS_QLEN)
+ if (CHECK_FLAG(pqnode->flags, BGP_PROCESS_QUEUE_EOIU_MARKER) ||
+ pqnode->bgp != bgp ||
+ (pqnode->queued >= ARBITRARY_PROCESS_QLEN && !early_process))
pqnode = bgp_processq_alloc(bgp);
else
pqnode_reuse = 1;
@@ -4091,7 +4092,10 @@ void bgp_process(struct bgp *bgp, struct bgp_dest *dest,
/* can't be enqueued twice */
assert(STAILQ_NEXT(dest, pq) == NULL);
- STAILQ_INSERT_TAIL(&pqnode->pqueue, dest, pq);
+ if (early_process)
+ STAILQ_INSERT_HEAD(&pqnode->pqueue, dest, pq);
+ else
+ STAILQ_INSERT_TAIL(&pqnode->pqueue, dest, pq);
pqnode->queued++;
if (!pqnode_reuse)
@@ -4100,6 +4104,18 @@ void bgp_process(struct bgp *bgp, struct bgp_dest *dest,
return;
}
+void bgp_process(struct bgp *bgp, struct bgp_dest *dest,
+ struct bgp_path_info *pi, afi_t afi, safi_t safi)
+{
+ bgp_process_internal(bgp, dest, pi, afi, safi, false);
+}
+
+void bgp_process_early(struct bgp *bgp, struct bgp_dest *dest,
+ struct bgp_path_info *pi, afi_t afi, safi_t safi)
+{
+ bgp_process_internal(bgp, dest, pi, afi, safi, true);
+}
+
void bgp_add_eoiu_mark(struct bgp *bgp)
{
struct bgp_process_queue *pqnode;
diff --git a/bgpd/bgp_route.h b/bgpd/bgp_route.h
index bc3ca4b2f8..b6df241181 100644
--- a/bgpd/bgp_route.h
+++ b/bgpd/bgp_route.h
@@ -804,10 +804,20 @@ extern void bgp_withdraw(struct peer *peer, const struct prefix *p,
int sub_type, struct prefix_rd *prd,
mpls_label_t *label, uint8_t num_labels);
-/* for bgp_nexthop and bgp_damp */
+/*
+ * Add a route to be processed for bgp bestpath through the bgp
+ * workqueue. This route is added to the end of all other routes
+ * queued for processing
+ *
+ * bgp_process_early adds the route for processing at the beginning
+ * of the current queue for processing.
+ */
extern void bgp_process(struct bgp *bgp, struct bgp_dest *dest,
struct bgp_path_info *pi, afi_t afi, safi_t safi);
+extern void bgp_process_early(struct bgp *bgp, struct bgp_dest *dest,
+ struct bgp_path_info *pi, afi_t afi, safi_t safi);
+
/*
* Add an end-of-initial-update marker to the process queue. This is just a
* queue element with NULL bgp node.