isisd: update struct sr_prefix_cfg with algorithm id

The information in prefix-sid has a new property
called algorithm id.  This is used to identify
the algorithm that separates it in the same IGP
network. This is used in Flex-Algo.In all other
cases, the algorithm id is basically 0.

Signed-off-by: Hiroki Shirokura <hiroki.shirokura@linecorp.com>
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
This commit is contained in:
Hiroki Shirokura 2021-12-11 02:21:30 +00:00 committed by Louis Scalbert
parent 329f87b310
commit 1f0d13e922
4 changed files with 36 additions and 13 deletions

View File

@ -907,7 +907,8 @@ static void lsp_build_ext_reach_ipv4(struct isis_lsp *lsp,
struct sr_prefix_cfg *pcfg = NULL;
if (area->srdb.enabled)
pcfg = isis_sr_cfg_prefix_find(area, ipv4);
pcfg = isis_sr_cfg_prefix_find(
area, ipv4, SR_ALGORITHM_SPF);
isis_tlvs_add_extended_ip_reach(lsp->tlvs, ipv4, metric,
true, pcfg);
@ -941,7 +942,8 @@ static void lsp_build_ext_reach_ipv6(struct isis_lsp *lsp,
struct sr_prefix_cfg *pcfg = NULL;
if (area->srdb.enabled)
pcfg = isis_sr_cfg_prefix_find(area, p);
pcfg = isis_sr_cfg_prefix_find(
area, p, SR_ALGORITHM_SPF);
isis_tlvs_add_ipv6_reach(lsp->tlvs,
isis_area_ipv6_topology(area),
@ -1205,7 +1207,8 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area)
if (area->srdb.enabled)
pcfg = isis_sr_cfg_prefix_find(
area, ipv4);
area, ipv4,
SR_ALGORITHM_SPF);
isis_tlvs_add_extended_ip_reach(
lsp->tlvs, ipv4, metric, false,
@ -1228,7 +1231,7 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area)
if (area->srdb.enabled)
pcfg = isis_sr_cfg_prefix_find(area,
ipv6);
ipv6, 0);
isis_tlvs_add_ipv6_reach(
lsp->tlvs,

View File

@ -2276,7 +2276,7 @@ int isis_instance_segment_routing_prefix_sid_map_prefix_sid_create(
area = nb_running_get_entry(args->dnode, NULL, true);
yang_dnode_get_prefix(&prefix, args->dnode, "./prefix");
pcfg = isis_sr_cfg_prefix_add(area, &prefix);
pcfg = isis_sr_cfg_prefix_add(area, &prefix, SR_ALGORITHM_SPF);
nb_running_set_entry(args->dnode, pcfg);
return NB_OK;

View File

@ -57,7 +57,17 @@ static void sr_adj_sid_del(struct sr_adjacency *sra);
static inline int sr_prefix_sid_cfg_compare(const struct sr_prefix_cfg *a,
const struct sr_prefix_cfg *b)
{
return prefix_cmp(&a->prefix, &b->prefix);
int ret;
ret = prefix_cmp(&a->prefix, &b->prefix);
if (ret != 0)
return ret;
ret = a->algorithm - b->algorithm;
if (ret != 0)
return ret;
return 0;
}
DECLARE_RBTREE_UNIQ(srdb_prefix_cfg, struct sr_prefix_cfg, entry,
sr_prefix_sid_cfg_compare);
@ -331,7 +341,8 @@ int isis_sr_cfg_srlb_update(struct isis_area *area, uint32_t lower_bound,
* @return Newly added Prefix-SID configuration structure
*/
struct sr_prefix_cfg *isis_sr_cfg_prefix_add(struct isis_area *area,
const struct prefix *prefix)
const struct prefix *prefix,
uint8_t algorithm)
{
struct sr_prefix_cfg *pcfg;
struct interface *ifp;
@ -341,6 +352,7 @@ struct sr_prefix_cfg *isis_sr_cfg_prefix_add(struct isis_area *area,
pcfg = XCALLOC(MTYPE_ISIS_SR_INFO, sizeof(*pcfg));
pcfg->prefix = *prefix;
pcfg->area = area;
pcfg->algorithm = algorithm;
/* Pull defaults from the YANG module. */
pcfg->sid_type = yang_get_default_enum(
@ -386,11 +398,13 @@ void isis_sr_cfg_prefix_del(struct sr_prefix_cfg *pcfg)
* @return Configured Prefix-SID structure if found, NULL otherwise
*/
struct sr_prefix_cfg *isis_sr_cfg_prefix_find(struct isis_area *area,
union prefixconstptr prefix)
union prefixconstptr prefix,
uint8_t algorithm)
{
struct sr_prefix_cfg pcfg = {};
prefix_copy(&pcfg.prefix, prefix.p);
pcfg.algorithm = algorithm;
return srdb_prefix_cfg_find(&area->srdb.config.prefix_sids, &pcfg);
}
@ -405,7 +419,7 @@ void isis_sr_prefix_cfg2subtlv(const struct sr_prefix_cfg *pcfg, bool external,
struct isis_prefix_sid *psid)
{
/* Set SID algorithm. */
psid->algorithm = SR_ALGORITHM_SPF;
psid->algorithm = pcfg->algorithm;
/* Set SID flags. */
psid->flags = 0;
@ -939,7 +953,8 @@ static int sr_if_new_hook(struct interface *ifp)
FOR_ALL_INTERFACES_ADDRESSES (ifp, connected, node) {
struct sr_prefix_cfg *pcfg;
pcfg = isis_sr_cfg_prefix_find(area, connected->address);
pcfg = isis_sr_cfg_prefix_find(area, connected->address,
SR_ALGORITHM_SPF);
if (!pcfg)
continue;

View File

@ -147,6 +147,9 @@ struct sr_prefix_cfg {
/* Backpointer to IS-IS area. */
struct isis_area *area;
/* SR Algorithm number */
uint8_t algorithm;
};
/* Per-area IS-IS Segment Routing Data Base (SRDB). */
@ -198,11 +201,13 @@ extern int isis_sr_cfg_srgb_update(struct isis_area *area, uint32_t lower_bound,
uint32_t upper_bound);
extern int isis_sr_cfg_srlb_update(struct isis_area *area, uint32_t lower_bound,
uint32_t upper_bound);
extern struct sr_prefix_cfg *
isis_sr_cfg_prefix_add(struct isis_area *area, const struct prefix *prefix);
extern struct sr_prefix_cfg *isis_sr_cfg_prefix_add(struct isis_area *area,
const struct prefix *prefix,
uint8_t algorithm);
extern void isis_sr_cfg_prefix_del(struct sr_prefix_cfg *pcfg);
extern struct sr_prefix_cfg *
isis_sr_cfg_prefix_find(struct isis_area *area, union prefixconstptr prefix);
isis_sr_cfg_prefix_find(struct isis_area *area, union prefixconstptr prefix,
uint8_t algorithm);
extern void isis_sr_prefix_cfg2subtlv(const struct sr_prefix_cfg *pcfg,
bool external,
struct isis_prefix_sid *psid);