Skip to content

Commit

Permalink
isisd: calculate flex-algo constraint spf
Browse files Browse the repository at this point in the history
Take into account the flex-algo affinity constraints to compute the SPF
tree.

Signed-off-by: Hiroki Shirokura <hiroki.shirokura@linecorp.com>
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
  • Loading branch information
slankdev authored and louis-6wind committed Sep 12, 2022
1 parent b4db55d commit a85f482
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 4 deletions.
75 changes: 71 additions & 4 deletions isisd/isis_spf.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#include "isis_csm.h"
#include "isis_mt.h"
#include "isis_tlvs.h"
#include "isis_flex_algo.h"
#include "isis_zebra.h"
#include "fabricd.h"
#include "isis_spf_private.h"
Expand Down Expand Up @@ -611,6 +612,16 @@ isis_spf_add2tent(struct isis_spftree *spftree, enum vertextype vtype, void *id,
if (vertex->N.ip.sr.label != MPLS_INVALID_LABEL)
vertex->N.ip.sr.present = true;

if (is_flex_algo(spftree->algorithm)) {
if (!isis_flex_algo_elected(
spftree->algorithm,
spftree->area)) {
vertex->N.ip.sr.present = false;
vertex->N.ip.sr.label =
MPLS_INVALID_LABEL;
}
}

(void)hash_get(spftree->prefix_sids, vertex,
hash_alloc_intern);
}
Expand Down Expand Up @@ -912,6 +923,16 @@ static int isis_spf_process_lsp(struct isis_spftree *spftree,
&& !memcmp(er->id, null_sysid,
ISIS_SYS_ID_LEN))
continue;

if (is_flex_algo(spftree->algorithm)) {
if (!sr_algorithm_participated(
lsp, spftree->algorithm))
continue;
if (isis_flex_algo_constraint_drop(
spftree, er->subtlvs))
continue;
}

dist = cost
+ (CHECK_FLAG(spftree->flags,
F_SPFTREE_HOPCOUNT_METRIC)
Expand Down Expand Up @@ -989,8 +1010,18 @@ static int isis_spf_process_lsp(struct isis_spftree *spftree,
(struct isis_prefix_sid *)i;

if (psid->algorithm !=
spftree->algorithm) {
spftree->algorithm)
continue;

if (is_flex_algo(spftree->algorithm)) {
if (!sr_algorithm_participated(
lsp,
spftree->algorithm))
continue;
if (!isis_flex_algo_elected(
spftree->algorithm,
spftree->area))
continue;
}

has_valid_psid = true;
Expand Down Expand Up @@ -1058,9 +1089,21 @@ static int isis_spf_process_lsp(struct isis_spftree *spftree,
struct isis_prefix_sid *psid =
(struct isis_prefix_sid *)i;

if (psid->algorithm != SR_ALGORITHM_SPF)
if (psid->algorithm !=
spftree->algorithm)
continue;

if (is_flex_algo(spftree->algorithm)) {
if (!sr_algorithm_participated(
lsp,
spftree->algorithm))
continue;
if (!isis_flex_algo_elected(
spftree->algorithm,
spftree->area))
continue;
}

has_valid_psid = true;
process_N(spftree, vtype, &ip_info,
dist, depth + 1, psid,
Expand Down Expand Up @@ -1444,6 +1487,16 @@ static void spf_adj_list_parse_lsp(struct isis_spftree *spftree,
for (struct isis_extended_reach *reach =
(struct isis_extended_reach *)head;
reach; reach = reach->next) {

/*
* cutting out adjacency by flex-algo link
* affinity attribute
*/
if (is_flex_algo(spftree->algorithm))
if (isis_flex_algo_constraint_drop(
spftree, reach->subtlvs))
continue;

spf_adj_list_parse_tlv(
spftree, adj_list, reach->id,
pseudo_nodeid, pseudo_metric,
Expand Down Expand Up @@ -1871,6 +1924,10 @@ static void isis_run_spf_cb(struct thread *thread)
struct isis_area *area = run->area;
int level = run->level;
int have_run = 0;
struct listnode *node;
struct isis_circuit *circuit;
struct flex_algo *fa;
struct isis_flex_algo_data *data;

XFREE(MTYPE_ISIS_SPF_RUN, run);

Expand All @@ -1891,11 +1948,23 @@ static void isis_run_spf_cb(struct thread *thread)
if (area->ip_circuits) {
isis_run_spf_with_protection(
area, area->spftree[SPFTREE_IPV4][level - 1]);
for (ALL_LIST_ELEMENTS_RO(area->flex_algos->flex_algos, node,
fa)) {
data = fa->data;
isis_run_spf_with_protection(
area, data->spftree[SPFTREE_IPV4][level - 1]);
}
have_run = 1;
}
if (area->ipv6_circuits) {
isis_run_spf_with_protection(
area, area->spftree[SPFTREE_IPV6][level - 1]);
for (ALL_LIST_ELEMENTS_RO(area->flex_algos->flex_algos, node,
fa)) {
data = fa->data;
isis_run_spf_with_protection(
area, data->spftree[SPFTREE_IPV6][level - 1]);
}
have_run = 1;
}
if (area->ipv6_circuits && isis_area_ipv6_dstsrc_enabled(area)) {
Expand All @@ -1910,8 +1979,6 @@ static void isis_run_spf_cb(struct thread *thread)
isis_area_verify_routes(area);

/* walk all circuits and reset any spf specific flags */
struct listnode *node;
struct isis_circuit *circuit;
for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit))
UNSET_FLAG(circuit->flags, ISIS_CIRCUIT_FLAPPED_AFTER_SPF);

Expand Down
27 changes: 27 additions & 0 deletions isisd/isisd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3077,11 +3077,22 @@ int isis_area_passwd_hmac_md5_set(struct isis_area *area, int level,
void isis_area_invalidate_routes(struct isis_area *area, int levels)
{
for (int level = ISIS_LEVEL1; level <= ISIS_LEVEL2; level++) {
struct flex_algo *fa;
struct listnode *node;
struct isis_flex_algo_data *data;

if (!(level & levels))
continue;
for (int tree = SPFTREE_IPV4; tree < SPFTREE_COUNT; tree++) {
isis_spf_invalidate_routes(
area->spftree[tree][level - 1]);

for (ALL_LIST_ELEMENTS_RO(area->flex_algos->flex_algos,
node, fa)) {
data = fa->data;
isis_spf_invalidate_routes(
data->spftree[tree][level - 1]);
}
}
}
}
Expand All @@ -3106,6 +3117,22 @@ static void area_resign_level(struct isis_area *area, int level)
}
}

struct flex_algo *fa;
struct listnode *node;
struct isis_flex_algo_data *data;

for (int tree = SPFTREE_IPV4; tree < SPFTREE_COUNT; tree++) {
for (ALL_LIST_ELEMENTS_RO(area->flex_algos->flex_algos, node,
fa)) {
data = fa->data;
if (data->spftree[level - 1]) {
isis_spftree_del(
data->spftree[tree][level - 1]);
data->spftree[tree][level - 1] = NULL;
}
}
}

if (area->spf_timer[level - 1])
isis_spf_timer_free(THREAD_ARG(area->spf_timer[level - 1]));

Expand Down

0 comments on commit a85f482

Please sign in to comment.