Skip to content

Commit

Permalink
isisd: update struct isis_sr_psid_info with nh context
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Louis Scalbert <[email protected]>
  • Loading branch information
slankdev authored and louis-6wind committed Apr 18, 2023
1 parent 484ab40 commit bdaafbf
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
13 changes: 12 additions & 1 deletion isisd/isis_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions isisd/isis_sr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
9 changes: 4 additions & 5 deletions isisd/isis_zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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) {
Expand All @@ -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)
Expand Down
1 change: 0 additions & 1 deletion isisd/isis_zebra.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit bdaafbf

Please sign in to comment.