mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-11 10:46:53 +00:00
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>
This commit is contained in:
parent
4e10b4dfba
commit
37a331f8c2
@ -385,9 +385,10 @@ mpls_label_t ospf_sr_local_block_request_label(void)
|
|||||||
mpls_label_t label;
|
mpls_label_t label;
|
||||||
uint32_t index;
|
uint32_t index;
|
||||||
uint32_t pos;
|
uint32_t pos;
|
||||||
|
uint32_t size = srlb->end - srlb->start + 1;
|
||||||
|
|
||||||
/* Check if we ran out of available labels */
|
/* Check if we ran out of available labels */
|
||||||
if (srlb->current >= srlb->end)
|
if (srlb->current >= size)
|
||||||
return MPLS_INVALID_LABEL;
|
return MPLS_INVALID_LABEL;
|
||||||
|
|
||||||
/* Get first available label and mark it used */
|
/* 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 */
|
/* Jump to the next free position */
|
||||||
srlb->current++;
|
srlb->current++;
|
||||||
pos = srlb->current % SRLB_BLOCK_SIZE;
|
pos = srlb->current % SRLB_BLOCK_SIZE;
|
||||||
while (srlb->current < srlb->end) {
|
while (srlb->current < size) {
|
||||||
if (pos == 0)
|
if (pos == 0)
|
||||||
index++;
|
index++;
|
||||||
if (!((1ULL << pos) & srlb->used_mark[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;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user