summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFredi Raspall <fredi@voltanet.io>2021-05-29 03:22:04 +0200
committerEmanuele Di Pascale <emanuele@voltanet.io>2021-09-28 10:40:32 +0200
commit37a331f8c2ba2ba72bed447fb80ee91a72dae8ec (patch)
treee09a2015d9fea6bb274efd55e25fde8d381ce1f4
parent4e10b4dfba74c0984e1f3f289e8a6c0265cb6914 (diff)
ospfd: fix condition to get label from SRLB
The prior condition was wrong since it ended up allowing for labels past the end of the SRLB. Variable 'current' should be in range [0, size-1] for labels not to exceed the SRLB upper boundary. In addition, emit a warning log when all labels in the SRLB have been used. Signed-off-by: Fredi Raspall <fredi@voltanet.io>
-rw-r--r--ospfd/ospf_sr.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/ospfd/ospf_sr.c b/ospfd/ospf_sr.c
index e19dbc7d3b..60485a770f 100644
--- a/ospfd/ospf_sr.c
+++ b/ospfd/ospf_sr.c
@@ -385,9 +385,10 @@ mpls_label_t ospf_sr_local_block_request_label(void)
mpls_label_t label;
uint32_t index;
uint32_t pos;
+ uint32_t size = srlb->end - srlb->start + 1;
/* Check if we ran out of available labels */
- if (srlb->current >= srlb->end)
+ if (srlb->current >= size)
return MPLS_INVALID_LABEL;
/* Get first available label and mark it used */
@@ -399,7 +400,7 @@ mpls_label_t ospf_sr_local_block_request_label(void)
/* Jump to the next free position */
srlb->current++;
pos = srlb->current % SRLB_BLOCK_SIZE;
- while (srlb->current < srlb->end) {
+ while (srlb->current < size) {
if (pos == 0)
index++;
if (!((1ULL << pos) & srlb->used_mark[index]))
@@ -410,6 +411,10 @@ mpls_label_t ospf_sr_local_block_request_label(void)
}
}
+ if (srlb->current == size)
+ zlog_warn(
+ "SR: Warning, SRLB is depleted and next label request will fail");
+
return label;
}