From cb86d8e3a4515291f8bbd34a0a32e23f2495a315 Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Fri, 1 Sep 2023 17:51:54 +0200 Subject: [PATCH] bgpd: fix label allocation should not be allocated at startup BGP always asks zebra for a chunk of MPLS label even if it doesn't need it. Fix this by correcting the rounding up "labels_needed" formula. Fixes: 80853c2ec7f8 ("bgpd: improve labelpool performance at scale") Signed-off-by: Philippe Guibert --- bgpd/bgp_labelpool.c | 10 +++++++--- tests/topotests/bgp_lu_topo1/R2/labelpool.summ.json | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/bgpd/bgp_labelpool.c b/bgpd/bgp_labelpool.c index d33f14ac41..03987b6bbf 100644 --- a/bgpd/bgp_labelpool.c +++ b/bgpd/bgp_labelpool.c @@ -642,7 +642,11 @@ void bgp_lp_event_zebra_up(void) } /* round up */ - chunks_needed = (labels_needed / lp->next_chunksize) + 1; + if (((float)labels_needed / (float)lp->next_chunksize) > + (labels_needed / lp->next_chunksize)) + chunks_needed = (labels_needed / lp->next_chunksize) + 1; + else + chunks_needed = (labels_needed / lp->next_chunksize); labels_needed = chunks_needed * lp->next_chunksize; /* @@ -650,8 +654,8 @@ void bgp_lp_event_zebra_up(void) */ list_delete_all_node(lp->chunks); - if (!bgp_zebra_request_label_range(MPLS_LABEL_BASE_ANY, labels_needed, - true)) + if (labels_needed && !bgp_zebra_request_label_range(MPLS_LABEL_BASE_ANY, + labels_needed, true)) return; lp->pending_count = labels_needed; diff --git a/tests/topotests/bgp_lu_topo1/R2/labelpool.summ.json b/tests/topotests/bgp_lu_topo1/R2/labelpool.summ.json index d35e4ef463..17b9accb4a 100644 --- a/tests/topotests/bgp_lu_topo1/R2/labelpool.summ.json +++ b/tests/topotests/bgp_lu_topo1/R2/labelpool.summ.json @@ -2,5 +2,5 @@ "ledger":0, "inUse":0, "requests":0, - "labelChunks":1 + "labelChunks":0 } -- 2.39.5