From bdaafbf8344debcb24498c69d9024f9fc7cff56a Mon Sep 17 00:00:00 2001 From: Hiroki Shirokura Date: Tue, 4 Jan 2022 08:15:56 +0000 Subject: isisd: update struct isis_sr_psid_info with nh context Prefix-SID nexthops and backup nexthops are stored respectively in isis_route_info->nexthops and isis_route_info->backup->nexthops. With Flex-Algo, there are multiple Prefix-SIDs for a single prefix in different algorithms. Each of these Prefix-SIDs performs SPF calculation with a separate contract and sets a nexthops, so it is necessary to store a different set nexthops for each Prefix-SID. Add a nexthops and backup nethops list into the Prefix-SID isis_sr_psid_info struct and use these lists instead of the when needed After this commit, the nexthops for each Prefix-SID is not taken from route_info, but the nexthop set inside the Prefix-SID is taken. This works for backup nexthops as well. Signed-off-by: Hiroki Shirokura Signed-off-by: Louis Scalbert --- isisd/isis_route.c | 13 ++++++++++++- isisd/isis_sr.h | 3 +++ isisd/isis_zebra.c | 9 ++++----- isisd/isis_zebra.h | 1 - 4 files changed, 19 insertions(+), 7 deletions(-) (limited to 'isisd') diff --git a/isisd/isis_route.c b/isisd/isis_route.c index 9a12df2fa..20d30a148 100644 --- a/isisd/isis_route.c +++ b/isisd/isis_route.c @@ -239,6 +239,9 @@ isis_route_info_new(struct prefix *prefix, struct prefix_ipv6 *src_p, rinfo->cost = cost; rinfo->depth = depth; rinfo->sr = *sr; + rinfo->sr.nexthops = rinfo->nexthops; + rinfo->sr.nexthops_backup = + rinfo->backup ? rinfo->backup->nexthops : NULL; return rinfo; } @@ -489,8 +492,9 @@ static void isis_route_update(struct isis_area *area, struct prefix *prefix, route_info); /* Install/reinstall Prefix-SID label. */ if (route_info->sr.present) - isis_zebra_prefix_sid_install(area, prefix, route_info, + isis_zebra_prefix_sid_install(area, prefix, &route_info->sr); + hook_call(isis_route_update_hook, area, prefix, route_info); SET_FLAG(route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED); @@ -541,10 +545,13 @@ static void _isis_route_verify_table(struct isis_area *area, src_p); if (rnode_bck) { rinfo->backup = rnode_bck->info; + rinfo->sr.nexthops_backup = + rinfo->backup->nexthops; UNSET_FLAG(rinfo->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED); } else if (rinfo->backup) { rinfo->backup = NULL; + rinfo->sr.nexthops_backup = NULL; UNSET_FLAG(rinfo->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED); } @@ -658,10 +665,13 @@ void isis_route_verify_merge(struct isis_area *area, tables_backup[level - 1], prefix, src_p); if (rnode_bck) { rinfo->backup = rnode_bck->info; + rinfo->sr.nexthops_backup = + rinfo->backup->nexthops; UNSET_FLAG(rinfo->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED); } else if (rinfo->backup) { rinfo->backup = NULL; + rinfo->sr.nexthops_backup = NULL; UNSET_FLAG(rinfo->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED); } @@ -720,6 +730,7 @@ void isis_route_invalidate_table(struct isis_area *area, if (rinfo->backup) { rinfo->backup = NULL; + rinfo->sr.nexthops_backup = NULL; /* * For now, always force routes that have backup * nexthops to be reinstalled. diff --git a/isisd/isis_sr.h b/isisd/isis_sr.h index 7c0222401..f5f0adf24 100644 --- a/isisd/isis_sr.h +++ b/isisd/isis_sr.h @@ -63,6 +63,9 @@ struct isis_sr_psid_info { bool present; uint8_t algorithm; + + struct list *nexthops; + struct list *nexthops_backup; }; /* Segment Routing Local Block allocation */ diff --git a/isisd/isis_zebra.c b/isisd/isis_zebra.c index c1f02361b..59b80c1e2 100644 --- a/isisd/isis_zebra.c +++ b/isisd/isis_zebra.c @@ -327,7 +327,6 @@ void isis_zebra_route_del_route(struct isis *isis, */ void isis_zebra_prefix_sid_install(struct isis_area *area, struct prefix *prefix, - struct isis_route_info *rinfo, struct isis_sr_psid_info *psid) { struct zapi_labels zl; @@ -342,7 +341,7 @@ void isis_zebra_prefix_sid_install(struct isis_area *area, zl.local_label = psid->label; /* Local routes don't have any nexthop and require special handling. */ - if (list_isempty(rinfo->nexthops)) { + if (list_isempty(psid->nexthops)) { struct zapi_nexthop *znh; struct interface *ifp; @@ -361,9 +360,9 @@ void isis_zebra_prefix_sid_install(struct isis_area *area, znh->labels[0] = MPLS_LABEL_IMPLICIT_NULL; } else { /* Add backup nexthops first. */ - if (rinfo->backup) { + if (psid->nexthops_backup) { count = isis_zebra_add_nexthops( - area->isis, rinfo->backup->nexthops, + area->isis, psid->nexthops_backup, zl.backup_nexthops, ISIS_NEXTHOP_BACKUP, true, 0); if (count > 0) { @@ -373,7 +372,7 @@ void isis_zebra_prefix_sid_install(struct isis_area *area, } /* Add primary nexthops. */ - count = isis_zebra_add_nexthops(area->isis, rinfo->nexthops, + count = isis_zebra_add_nexthops(area->isis, psid->nexthops, zl.nexthops, ISIS_NEXTHOP_MAIN, true, count); if (!count) diff --git a/isisd/isis_zebra.h b/isisd/isis_zebra.h index 359e39b59..045c75874 100644 --- a/isisd/isis_zebra.h +++ b/isisd/isis_zebra.h @@ -36,7 +36,6 @@ void isis_zebra_route_del_route(struct isis *isis, struct isis_route_info *route_info); void isis_zebra_prefix_sid_install(struct isis_area *area, struct prefix *prefix, - struct isis_route_info *rinfo, struct isis_sr_psid_info *psid); void isis_zebra_prefix_sid_uninstall(struct isis_area *area, struct prefix *prefix, -- cgit v1.2.3