summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilippe Guibert <philippe.guibert@6wind.com>2023-10-05 15:49:10 +0200
committerPhilippe Guibert <philippe.guibert@6wind.com>2023-10-18 09:41:02 +0200
commit7a7c4bc80ac413d4841c31abb3e22c590ad4cdb2 (patch)
tree6a02517237f64c27a9e0986480d94f25f9d2cf30
parent0832a2be53eadcf4677c317573d5ac878301a984 (diff)
zebra: rework dynamic label request algorithm
The label chunk algorithm needs to be revisited to support a configured dynamic-block or the default one. Reuse the 'lbl_mgr.dynamic_block_[start/end]' variables, whereever needed, and simplify the algorithm. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
-rw-r--r--zebra/label_manager.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/zebra/label_manager.c b/zebra/label_manager.c
index 3fc1ee5bae..bb722f4313 100644
--- a/zebra/label_manager.c
+++ b/zebra/label_manager.c
@@ -399,7 +399,7 @@ assign_label_chunk(uint8_t proto, unsigned short instance, uint32_t session_id,
{
struct label_manager_chunk *lmc;
struct listnode *node;
- uint32_t prev_end = MPLS_LABEL_UNRESERVED_MIN - 1;
+ uint32_t prev_end = lbl_mgr.dynamic_block_start - 1;
/* handle chunks request with a specific base label
* - static label requests: BGP hardset value, Pathd
@@ -414,8 +414,9 @@ assign_label_chunk(uint8_t proto, unsigned short instance, uint32_t session_id,
/* first check if there's one available */
for (ALL_LIST_ELEMENTS_RO(lbl_mgr.lc_list, node, lmc)) {
- if (lmc->proto == NO_PROTO
- && lmc->end - lmc->start + 1 == size) {
+ if (lmc->start <= prev_end)
+ continue;
+ if (lmc->proto == NO_PROTO && lmc->end - lmc->start + 1 == size) {
lmc->proto = proto;
lmc->instance = instance;
lmc->session_id = session_id;
@@ -425,7 +426,7 @@ assign_label_chunk(uint8_t proto, unsigned short instance, uint32_t session_id,
}
/* check if we hadve a "hole" behind us that we can squeeze into
*/
- if ((lmc->start > prev_end) && (lmc->start - prev_end > size)) {
+ if (lmc->start - prev_end > size) {
lmc = create_label_chunk(proto, instance, session_id,
keep, prev_end + 1,
prev_end + size, true);
@@ -438,14 +439,14 @@ assign_label_chunk(uint8_t proto, unsigned short instance, uint32_t session_id,
uint32_t start_free;
if (list_isempty(lbl_mgr.lc_list))
- start_free = MPLS_LABEL_UNRESERVED_MIN;
+ start_free = lbl_mgr.dynamic_block_start;
else
start_free = ((struct label_manager_chunk *)listgetdata(
listtail(lbl_mgr.lc_list)))
->end
+ 1;
- if (start_free > MPLS_LABEL_UNRESERVED_MAX - size + 1) {
+ if (start_free > lbl_mgr.dynamic_block_end - size + 1) {
flog_err(EC_ZEBRA_LM_EXHAUSTED_LABELS,
"Reached max labels. Start: %u, size: %u", start_free,
size);