diff options
| author | Philippe Guibert <philippe.guibert@6wind.com> | 2023-10-03 10:22:05 +0200 | 
|---|---|---|
| committer | Philippe Guibert <philippe.guibert@6wind.com> | 2023-10-18 09:41:02 +0200 | 
| commit | fccda55eacd7f1d9b6745038a2f11b1ba9354b4c (patch) | |
| tree | 7cc2752d7f6cda14c6dcef32f7ed1f013d09ce7f /zebra/label_manager.c | |
| parent | 7a7c4bc80ac413d4841c31abb3e22c590ad4cdb2 (diff) | |
zebra: add label chunk allocation in the dynamic block range
This commit adds support for the label chunk allocation in
the configured dynamic block range.
An additional check ensures the upper bound does not go
over the upper bound of the dynamic-block.
Otherwise, a chunk is created with the lower bound set
to the first label element available in the defined
range.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Diffstat (limited to 'zebra/label_manager.c')
| -rw-r--r-- | zebra/label_manager.c | 20 | 
1 files changed, 13 insertions, 7 deletions
diff --git a/zebra/label_manager.c b/zebra/label_manager.c index bb722f4313..24968f6509 100644 --- a/zebra/label_manager.c +++ b/zebra/label_manager.c @@ -400,6 +400,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 = lbl_mgr.dynamic_block_start - 1; +	struct label_manager_chunk *lmc_block_last = NULL;  	/* handle chunks request with a specific base label  	 * - static label requests: BGP hardset value, Pathd @@ -416,7 +417,9 @@ assign_label_chunk(uint8_t proto, unsigned short instance, uint32_t session_id,  	for (ALL_LIST_ELEMENTS_RO(lbl_mgr.lc_list, node, lmc)) {  		if (lmc->start <= prev_end)  			continue; -		if (lmc->proto == NO_PROTO && lmc->end - lmc->start + 1 == size) { +		if (lmc->proto == NO_PROTO && +		    lmc->end - lmc->start + 1 == size && +		    lmc->end <= lbl_mgr.dynamic_block_end) {  			lmc->proto = proto;  			lmc->instance = instance;  			lmc->session_id = session_id; @@ -426,7 +429,8 @@ 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 > size) { +		if (lmc->start - prev_end > size && +		    prev_end + 1 + size <= lbl_mgr.dynamic_block_end) {  			lmc = create_label_chunk(proto, instance, session_id,  						 keep, prev_end + 1,  						 prev_end + size, true); @@ -434,17 +438,19 @@ assign_label_chunk(uint8_t proto, unsigned short instance, uint32_t session_id,  			return lmc;  		}  		prev_end = lmc->end; + +		/* check if we have a chunk that goes over the end block */ +		if (lmc->end > lbl_mgr.dynamic_block_end) +			continue; +		lmc_block_last = lmc;  	}  	/* otherwise create a new one */  	uint32_t start_free; -	if (list_isempty(lbl_mgr.lc_list)) +	if (lmc_block_last == NULL)  		start_free = lbl_mgr.dynamic_block_start;  	else -		start_free = ((struct label_manager_chunk *)listgetdata( -				      listtail(lbl_mgr.lc_list))) -				     ->end -			     + 1; +		start_free = lmc_block_last->end + 1;  	if (start_free > lbl_mgr.dynamic_block_end - size + 1) {  		flog_err(EC_ZEBRA_LM_EXHAUSTED_LABELS,  | 
