As bgpd has its own processing queue for calculating route entries and populating globalRIB table, a new queue is defined so as to do the same for VRF RIB tables. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com> --- bgpd/bgp_fsm.c | 2 ++ bgpd/bgp_route.c | 44 ++++++++++++++++++++++++++++++++++++++++++-- bgpd/bgpd.c | 5 +++++ bgpd/bgpd.h | 1 + 4 files changed, 50 insertions(+), 2 deletions(-) diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c index 60a647533090..00168842b9b9 100644 --- a/bgpd/bgp_fsm.c +++ b/bgpd/bgp_fsm.c @@ -617,6 +617,7 @@ bgp_update_delay_end (struct bgp *bgp) /* Resume the queue processing. This should trigger the event that would take care of processing any work that was queued during the read-only mode. */ work_queue_unplug(bm->process_main_queue); + work_queue_unplug(bm->process_vrf_queue); } /** @@ -873,6 +874,7 @@ bgp_update_delay_begin (struct bgp *bgp) /* Stop the processing of queued work. Enqueue shall continue */ work_queue_plug(bm->process_main_queue); + work_queue_plug(bm->process_vrf_queue); for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) peer->update_delay_over = 0; diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 389f2de6f325..76ca587d95fe 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -2022,6 +2022,18 @@ bgp_process_main (struct work_queue *wq, void *data) return WQ_SUCCESS; } +/* processing done for BGP VRF tables */ +static wq_item_status +bgp_process_vrf_main (struct work_queue *wq, void *data) +{ + struct bgp_process_queue *pq = data; + struct bgp_node *rn = pq->rn; + + if (rn) + UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); + return WQ_SUCCESS; +} + static void bgp_processq_del (struct work_queue *wq, void *data) { @@ -2052,6 +2064,17 @@ bgp_process_queue_init (void) exit (1); } } + if (!bm->process_vrf_queue) + { + bm->process_vrf_queue + = work_queue_new (bm->master, "process_vrf_queue"); + + if ( !bm->process_vrf_queue) + { + zlog_err ("%s: Failed to allocate work queue", __func__); + exit (1); + } + } bm->process_main_queue->spec.workfunc = &bgp_process_main; bm->process_main_queue->spec.del_item_data = &bgp_processq_del; @@ -2059,6 +2082,14 @@ bgp_process_queue_init (void) bm->process_main_queue->spec.hold = 50; /* Use a higher yield value of 50ms for main queue processing */ bm->process_main_queue->spec.yield = 50 * 1000L; + + bm->process_vrf_queue->spec.workfunc = &bgp_process_vrf_main; + bm->process_vrf_queue->spec.del_item_data = &bgp_processq_del; + bm->process_vrf_queue->spec.max_retries = 0; + bm->process_vrf_queue->spec.hold = 50; + /* Use a higher yield value of 50ms for main queue processing */ + bm->process_vrf_queue->spec.yield = 50 * 1000L; + } void @@ -2070,7 +2101,8 @@ bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) if (CHECK_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED)) return; - if (bm->process_main_queue == NULL) + if ((bm->process_main_queue == NULL) || + (bm->process_vrf_queue == NULL)) bgp_process_queue_init (); pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE, @@ -2085,7 +2117,15 @@ bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) bgp_lock (bgp); pqnode->afi = afi; pqnode->safi = safi; - work_queue_add (bm->process_main_queue, pqnode); + switch (bgp_node_table (rn)->type) + { + case BGP_TABLE_MAIN: + work_queue_add (bm->process_main_queue, pqnode); + break; + case BGP_TABLE_VRF: + work_queue_add (bm->process_vrf_queue, pqnode); + break; + } SET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED); return; } diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index a1b9d204ace1..f055f6853084 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -7629,6 +7629,11 @@ bgp_terminate (void) work_queue_free (bm->process_main_queue); bm->process_main_queue = NULL; } + if (bm->process_vrf_queue) + { + work_queue_free (bm->process_vrf_queue); + bm->process_vrf_queue = NULL; + } if (bm->t_rmap_update) BGP_TIMER_OFF(bm->t_rmap_update); diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index 38c4471b5c83..00d96b51603f 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -95,6 +95,7 @@ struct bgp_master /* work queues */ struct work_queue *process_main_queue; + struct work_queue *process_vrf_queue; /* Listening sockets */ struct list *listen_sockets; -- 2.1.4