diff options
author | Louis Scalbert <louis.scalbert@6wind.com> | 2022-04-14 15:32:17 +0200 |
---|---|---|
committer | Louis Scalbert <louis.scalbert@6wind.com> | 2022-05-24 10:06:05 +0200 |
commit | e45958e9cfccd6dfc108a7ef5cb73775e8ef2e68 (patch) | |
tree | 9fcc9072645bcc8b91cea07948718fb6c4f810d2 /isisd | |
parent | topotests: isis-tilfa add a switchover test after BFD down (diff) | |
download | frr-e45958e9cfccd6dfc108a7ef5cb73775e8ef2e68.tar.xz frr-e45958e9cfccd6dfc108a7ef5cb73775e8ef2e68.zip |
isisd: fix metric calculation of classic lfa backup prefixes
The isis-lfa-topo1 topotest shows backup routes with lower metrics than
the primary ones.
> rt1# show isis route
> Area 1:
> IS-IS L1 IPv6 routing table:
>
> Prefix Metric Interface Nexthop Label(s)
> ------------------------------------------------------------------------------
> 2001:db8:1000::1/128 0 - - -
> 2001:db8:1000::2/128 20 eth-rt2 fe80::d091:eeff:fe09:31cd -
> 2001:db8:1000::3/128 20 eth-rt3 fe80::946b:d4ff:fe5b:414b -
> 2001:db8:1000::4/128 20 eth-rt4 fe80::5ced:29ff:feed:59c4 -
> (...)
>
> rt1# show isis route backup
> Area 1:
> IS-IS L1 IPv6 routing table:
>
> Prefix Metric Interface Nexthop Label(s)
> ------------------------------------------------------------------------------
> 2001:db8:1000::2/128 15 eth-rt3 fe80::946b:d4ff:fe5b:414b -
> eth-rt5 fe80::847d:feff:fe74:bdde -
> eth-rt6 fe80::ac8c:dff:feac:8a8d -
> 2001:db8:1000::3/128 15 eth-rt2 fe80::d091:eeff:fe09:31cd -
> eth-rt5 fe80::847d:feff:fe74:bdde -
> 2001:db8:1000::4/128 45 eth-rt5 fe80::847d:feff:fe74:bdde -
> (...)
Backup routes metrics are incorrect because they only take into account
the path metric but not the prefix metric.
Add the prefix metric to the path metric on backup routes.
After the patch with a prefix metric of 10:
> rt1# show isis route backup
> Area 1:
> IS-IS L1 IPv6 routing table:
>
> Area 1:
> IS-IS L1 IPv6 routing table:
>
> Prefix Metric Interface Nexthop Label(s)
> ------------------------------------------------------------------------------
> 2001:db8:1000::2/128 25 eth-rt3 fe80::8c6f:8aff:fe10:ad0d -
> eth-rt5 fe80::b08e:5cff:fe90:62dd -
> eth-rt6 fe80::4810:47ff:fe81:2b9a -
> 2001:db8:1000::3/128 25 eth-rt2 fe80::e855:12ff:fe31:5765 -
> eth-rt5 fe80::b08e:5cff:fe90:62dd -
> 2001:db8:1000::4/128 55 eth-rt5 fe80::b08e:5cff:fe90:62dd -
Fixes: e886416f81 ("isisd: add support for classic LFA (RFC 5286)")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Diffstat (limited to 'isisd')
-rw-r--r-- | isisd/isis_lfa.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/isisd/isis_lfa.c b/isisd/isis_lfa.c index 800cac852..b348c876d 100644 --- a/isisd/isis_lfa.c +++ b/isisd/isis_lfa.c @@ -1836,7 +1836,7 @@ static bool clfa_loop_free_check(struct isis_spftree *spftree, struct isis_vertex *vertex_S_D, struct isis_spf_adj *sadj_primary, struct isis_spf_adj *sadj_N, - uint32_t *lfa_metric) + uint32_t *path_metric) { struct isis_spf_node *node_N; uint32_t dist_N_D; @@ -1882,7 +1882,7 @@ static bool clfa_loop_free_check(struct isis_spftree *spftree, dist_N_S, dist_S_D); if (dist_N_D < (dist_N_S + dist_S_D)) { - *lfa_metric = sadj_N->metric + dist_N_D; + *path_metric = sadj_N->metric + dist_N_D; return true; } @@ -2082,7 +2082,7 @@ void isis_lfa_compute(struct isis_area *area, struct isis_circuit *circuit, struct isis_spftree *spftree, struct lfa_protected_resource *resource) { - struct isis_vertex *vertex; + struct isis_vertex *vertex, *parent_vertex; struct listnode *vnode, *snode; int level = spftree->level; @@ -2099,7 +2099,7 @@ void isis_lfa_compute(struct isis_area *area, struct isis_circuit *circuit, struct isis_vertex_adj *vadj_primary; struct isis_spf_adj *sadj_primary; bool allow_ecmp; - uint32_t best_metric = UINT32_MAX; + uint32_t prefix_metric, best_metric = UINT32_MAX; char buf[VID2STR_BUFFER]; if (!VTYPE_IP(vertex->type)) @@ -2133,6 +2133,9 @@ void isis_lfa_compute(struct isis_area *area, struct isis_circuit *circuit, vadj_primary = listnode_head(vertex->Adj_N); sadj_primary = vadj_primary->sadj; + parent_vertex = listnode_head(vertex->parents); + prefix_metric = vertex->d_N - parent_vertex->d_N; + /* * Loop over list of SPF adjacencies and compute a list of * preliminary LFAs. @@ -2140,7 +2143,7 @@ void isis_lfa_compute(struct isis_area *area, struct isis_circuit *circuit, lfa_list = list_new(); lfa_list->del = isis_vertex_adj_free; for (ALL_LIST_ELEMENTS_RO(spftree->sadj_list, snode, sadj_N)) { - uint32_t lfa_metric; + uint32_t lfa_metric, path_metric; struct isis_vertex_adj *lfa; struct isis_prefix_sid *psid = NULL; bool last_hop = false; @@ -2190,7 +2193,7 @@ void isis_lfa_compute(struct isis_area *area, struct isis_circuit *circuit, /* Check loop-free criterion. */ if (!clfa_loop_free_check(spftree, vertex, sadj_primary, - sadj_N, &lfa_metric)) { + sadj_N, &path_metric)) { if (IS_DEBUG_LFA) zlog_debug( "ISIS-LFA: LFA condition not met for %s", @@ -2198,6 +2201,7 @@ void isis_lfa_compute(struct isis_area *area, struct isis_circuit *circuit, continue; } + lfa_metric = path_metric + prefix_metric; if (lfa_metric < best_metric) best_metric = lfa_metric; @@ -2208,7 +2212,7 @@ void isis_lfa_compute(struct isis_area *area, struct isis_circuit *circuit, if (vertex->N.ip.sr.present) { psid = &vertex->N.ip.sr.sid; - if (lfa_metric == sadj_N->metric) + if (path_metric == sadj_N->metric) last_hop = true; } lfa = isis_vertex_adj_add(spftree, vertex, lfa_list, |