diff options
| author | Hiroki Shirokura <hiroki.shirokura@linecorp.com> | 2022-01-04 01:31:45 +0000 | 
|---|---|---|
| committer | Louis Scalbert <louis.scalbert@6wind.com> | 2023-04-18 11:33:15 +0200 | 
| commit | 78774bbcd51b1cb461b2d8622545d4b8136f2344 (patch) | |
| tree | f750e0a072454063829ab09698487121a1a44021 /isisd/isis_lsp.c | |
| parent | 5749ac83a8adca45703e60ab56383e29ed732532 (diff) | |
isisd: add isis flex-algo lsp advertisement
Deal with the packing and unpacking of following Flex-Algo
Sub-Sub-TLVs:
- Router Capability (already defined TLV 242)
	- List of the Flex-Algo Definitions (Sub-TLV 26)
		- Exclude admin group (Sub-Sub-TLV 1)
                - Include-any admin group (Sub-Sub-TLV 2)
                - Include-all admin group (Sub-Sub-TLV 3)
                - Flags (for prefix-metric) (Sub-Sub-TLV 4)
This commit splits data into multiple router capability TLVs if needed
because a TLV cannot contains more than 255 bytes.
Note that the list of SR Algorithm (Sub-TLV 19) within Router Capability
(TLV 242) is already set in a previous commit.
Signed-off-by: Hiroki Shirokura <hiroki.shirokura@linecorp.com>
Signed-off-by: Eric Kinzie <ekinzie@labn.net>
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Diffstat (limited to 'isisd/isis_lsp.c')
| -rw-r--r-- | isisd/isis_lsp.c | 102 | 
1 files changed, 79 insertions, 23 deletions
diff --git a/isisd/isis_lsp.c b/isisd/isis_lsp.c index 08fa845e8e..c07083a06d 100644 --- a/isisd/isis_lsp.c +++ b/isisd/isis_lsp.c @@ -46,6 +46,7 @@  #include "isisd/fabricd.h"  #include "isisd/isis_tx_queue.h"  #include "isisd/isis_nb.h" +#include "isisd/isis_flex_algo.h"  DEFINE_MTYPE_STATIC(ISISD, ISIS_LSP, "ISIS LSP"); @@ -898,9 +899,15 @@ static void lsp_build_internal_reach_ipv4(struct isis_lsp *lsp,  			  area->area_tag, ipv4);  		if (area->srdb.enabled) -			for (int i = 0; i < SR_ALGORITHM_COUNT; i++) +			for (int i = 0; i < SR_ALGORITHM_COUNT; i++) { +#ifndef FABRICD +				if (flex_algo_id_valid(i) && +				    !isis_flex_algo_elected_supported(i, area)) +					continue; +#endif /* ifndef FABRICD */  				pcfgs[i] =  					isis_sr_cfg_prefix_find(area, ipv4, i); +			}  		isis_tlvs_add_extended_ip_reach(lsp->tlvs, ipv4, metric, false,  						pcfgs); @@ -918,8 +925,14 @@ static void lsp_build_internal_reach_ipv6(struct isis_lsp *lsp,  		  area->area_tag, ipv6);  	if (area->srdb.enabled) -		for (int i = 0; i < SR_ALGORITHM_COUNT; i++) +		for (int i = 0; i < SR_ALGORITHM_COUNT; i++) { +#ifndef FABRICD +			if (flex_algo_id_valid(i) && +			    !isis_flex_algo_elected_supported(i, area)) +				continue; +#endif /* ifndef FABRICD */  			pcfgs[i] = isis_sr_cfg_prefix_find(area, ipv6, i); +		}  	isis_tlvs_add_ipv6_reach(lsp->tlvs, isis_area_ipv6_topology(area), ipv6,  				 metric, false, pcfgs); @@ -955,9 +968,16 @@ static void lsp_build_ext_reach_ipv4(struct isis_lsp *lsp,  				NULL};  			if (area->srdb.enabled) -				for (int i = 0; i < SR_ALGORITHM_COUNT; i++) +				for (int i = 0; i < SR_ALGORITHM_COUNT; i++) { +#ifndef FABRICD +					if (flex_algo_id_valid(i) && +					    !isis_flex_algo_elected_supported( +						    i, area)) +						continue; +#endif /* ifndef FABRICD */  					pcfgs[i] = isis_sr_cfg_prefix_find(  						area, ipv4, i); +				}  			isis_tlvs_add_extended_ip_reach(lsp->tlvs, ipv4, metric,  							true, pcfgs); @@ -992,9 +1012,16 @@ static void lsp_build_ext_reach_ipv6(struct isis_lsp *lsp,  				NULL};  			if (area->srdb.enabled) -				for (int i = 0; i < SR_ALGORITHM_COUNT; i++) +				for (int i = 0; i < SR_ALGORITHM_COUNT; i++) { +#ifndef FABRICD +					if (flex_algo_id_valid(i) && +					    !isis_flex_algo_elected_supported( +						    i, area)) +						continue; +#endif /* ifndef FABRICD */  					pcfgs[i] = isis_sr_cfg_prefix_find(  						area, p, i); +				}  			isis_tlvs_add_ipv6_reach(lsp->tlvs,  						 isis_area_ipv6_topology(area), @@ -1115,13 +1142,30 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area)  	/* Add Router Capability TLV. */  	if (area->isis->router_id != 0) { -		struct isis_router_cap cap = {}; +		struct isis_router_cap *rcap; +#ifndef FABRICD +		struct isis_router_cap_fad *rcap_fad; +		struct listnode *node; +		struct flex_algo *fa; +#endif /* ifndef FABRICD */ -		/* init SR algo list content to the default value */ -		for (int i = 0; i < SR_ALGORITHM_COUNT; i++) -			cap.algo[i] = SR_ALGORITHM_UNSET; +		rcap = isis_tlvs_init_router_capability(lsp->tlvs); -		cap.router_id.s_addr = area->isis->router_id; +		rcap->router_id.s_addr = area->isis->router_id; + +#ifndef FABRICD +		/* Set flex-algo definitions */ +		for (ALL_LIST_ELEMENTS_RO(area->flex_algos->flex_algos, node, +					  fa)) { +			if (!fa->advertise_definition) +				continue; +			lsp_debug("ISIS (%s):   Flex-Algo Definition %u", +				  area->area_tag, fa->algorithm); +			isis_tlvs_set_router_capability_fad(lsp->tlvs, fa, +							    fa->algorithm, +							    area->isis->sysid); +		} +#endif /* ifndef FABRICD */  		/* Add SR Sub-TLVs if SR is enabled. */  		if (area->srdb.enabled) { @@ -1131,26 +1175,38 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area)  			/* SRGB first */  			range_size = srdb->config.srgb_upper_bound  				     - srdb->config.srgb_lower_bound + 1; -			cap.srgb.flags = ISIS_SUBTLV_SRGB_FLAG_I -					 | ISIS_SUBTLV_SRGB_FLAG_V; -			cap.srgb.range_size = range_size; -			cap.srgb.lower_bound = srdb->config.srgb_lower_bound; +			rcap->srgb.flags = ISIS_SUBTLV_SRGB_FLAG_I | +					   ISIS_SUBTLV_SRGB_FLAG_V; +			rcap->srgb.range_size = range_size; +			rcap->srgb.lower_bound = srdb->config.srgb_lower_bound;  			/* Then Algorithm */ -			cap.algo[0] = SR_ALGORITHM_SPF; -			cap.algo[1] = SR_ALGORITHM_UNSET; +			rcap->algo[0] = SR_ALGORITHM_SPF; +			rcap->algo[1] = SR_ALGORITHM_UNSET; +#ifndef FABRICD +			for (ALL_LIST_ELEMENTS_RO(area->flex_algos->flex_algos, +						  node, fa)) { +				if (fa->advertise_definition) +					rcap_fad = rcap->fads[fa->algorithm]; +				else +					rcap_fad = NULL; + +				if (!isis_flex_algo_elected_supported_local_fad( +					    fa->algorithm, area, &rcap_fad)) +					continue; +				lsp_debug("ISIS (%s):   SR Algorithm %u", +					  area->area_tag, fa->algorithm); +				rcap->algo[fa->algorithm] = fa->algorithm; +			} +#endif /* ifndef FABRICD */  			/* SRLB */ -			cap.srlb.flags = 0; +			rcap->srlb.flags = 0;  			range_size = srdb->config.srlb_upper_bound  				     - srdb->config.srlb_lower_bound + 1; -			cap.srlb.range_size = range_size; -			cap.srlb.lower_bound = srdb->config.srlb_lower_bound; +			rcap->srlb.range_size = range_size; +			rcap->srlb.lower_bound = srdb->config.srlb_lower_bound;  			/* And finally MSD */ -			cap.msd = srdb->config.msd; +			rcap->msd = srdb->config.msd;  		} - -		isis_tlvs_set_router_capability(lsp->tlvs, &cap); -		lsp_debug("ISIS (%s): Adding Router Capabilities information", -			  area->area_tag);  	}  	/* IPv4 address and TE router ID TLVs.  | 
