Skip to content

Commit 937a9fb

Browse files
committed
zebra: Limit reading packets when MetaQ is full
Currently Zebra is just reading packets off the zapi wire and stacking them up for processing in zebra in the future. When there is significant churn in the network the size of zebra can grow without bounds due to the MetaQ sizing constraints. This ends up showing by the number of nexthops in the system. Reducing the number of packets serviced to limit the metaQ size to the packets to process allieviates this problem. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
1 parent 12bf042 commit 937a9fb

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

zebra/rib.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,8 @@ extern void meta_queue_free(struct meta_queue *mq, struct zebra_vrf *zvrf);
462462
extern int zebra_rib_labeled_unicast(struct route_entry *re);
463463
extern struct route_table *rib_table_ipv6;
464464

465+
extern uint32_t zebra_rib_meta_queue_size(void);
466+
465467
extern void rib_unlink(struct route_node *rn, struct route_entry *re);
466468
extern int rib_gc_dest(struct route_node *rn);
467469
extern struct route_table *rib_tables_iter_next(rib_tables_iter_t *iter);

zebra/zebra_rib.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3302,8 +3302,8 @@ static int rib_meta_queue_add(struct meta_queue *mq, void *data)
33023302
mq->size++;
33033303

33043304
if (IS_ZEBRA_DEBUG_RIB_DETAILED)
3305-
rnode_debug(rn, re->vrf_id, "queued rn %p into sub-queue %s",
3306-
(void *)rn, subqueue2str(qindex));
3305+
rnode_debug(rn, re->vrf_id, "queued rn %p into sub-queue %s mq size %u", (void *)rn,
3306+
subqueue2str(qindex), zrouter.mq->size);
33073307

33083308
return 0;
33093309
}
@@ -3335,8 +3335,8 @@ static int rib_meta_queue_nhg_ctx_add(struct meta_queue *mq, void *data)
33353335
mq->size++;
33363336

33373337
if (IS_ZEBRA_DEBUG_RIB_DETAILED)
3338-
zlog_debug("NHG Context id=%u queued into sub-queue %s",
3339-
ctx->id, subqueue2str(qindex));
3338+
zlog_debug("NHG Context id=%u queued into sub-queue %s mq size %u", ctx->id,
3339+
subqueue2str(qindex), zrouter.mq->size);
33403340

33413341
return 0;
33423342
}
@@ -3363,8 +3363,8 @@ static int rib_meta_queue_nhg_process(struct meta_queue *mq, void *data,
33633363
mq->size++;
33643364

33653365
if (IS_ZEBRA_DEBUG_RIB_DETAILED)
3366-
zlog_debug("NHG id=%u queued into sub-queue %s", nhe->id,
3367-
subqueue2str(qindex));
3366+
zlog_debug("NHG id=%u queued into sub-queue %s mq size %u", nhe->id,
3367+
subqueue2str(qindex), zrouter.mq->size);
33683368

33693369
return 0;
33703370
}
@@ -3410,6 +3410,11 @@ static int mq_add_handler(void *data,
34103410
return mq_add_func(zrouter.mq, data);
34113411
}
34123412

3413+
uint32_t zebra_rib_meta_queue_size(void)
3414+
{
3415+
return zrouter.mq->size;
3416+
}
3417+
34133418
void mpls_ftn_uninstall(struct zebra_vrf *zvrf, enum lsp_types_t type,
34143419
struct prefix *prefix, uint8_t route_type,
34153420
uint8_t route_instance)
@@ -4226,7 +4231,7 @@ static int rib_meta_queue_gr_run_add(struct meta_queue *mq, void *data)
42264231
mq->size++;
42274232

42284233
if (IS_ZEBRA_DEBUG_RIB_DETAILED)
4229-
zlog_debug("Graceful Run adding");
4234+
zlog_debug("Graceful Run adding mq size %u", zrouter.mq->size);
42304235

42314236
return 0;
42324237
}
@@ -4241,10 +4246,9 @@ static int rib_meta_queue_early_route_add(struct meta_queue *mq, void *data)
42414246
if (IS_ZEBRA_DEBUG_RIB_DETAILED) {
42424247
struct vrf *vrf = vrf_lookup_by_id(ere->re->vrf_id);
42434248

4244-
zlog_debug("Route %pFX(%s) (%s) queued for processing into sub-queue %s",
4245-
&ere->p, VRF_LOGNAME(vrf),
4246-
ere->deletion ? "delete" : "add",
4247-
subqueue2str(META_QUEUE_EARLY_ROUTE));
4249+
zlog_debug("Route %pFX(%s) (%s) queued for processing into sub-queue %s mq size %u",
4250+
&ere->p, VRF_LOGNAME(vrf), ere->deletion ? "delete" : "add",
4251+
subqueue2str(META_QUEUE_EARLY_ROUTE), zrouter.mq->size);
42484252
}
42494253

42504254
return 0;

zebra/zserv.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,12 @@ static void zserv_process_messages(struct event *thread)
530530
struct stream_fifo *cache = stream_fifo_new();
531531
uint32_t p2p = zrouter.packets_to_process;
532532
bool need_resched = false;
533+
uint32_t meta_queue_size = zebra_rib_meta_queue_size();
534+
535+
if (meta_queue_size < p2p)
536+
p2p = p2p - meta_queue_size;
537+
else
538+
p2p = 0;
533539

534540
frr_with_mutex (&client->ibuf_mtx) {
535541
uint32_t i;

0 commit comments

Comments
 (0)