Skip to content

Commit

Permalink
isisd: When the metric-type is configured as "wide", the IS-IS genera…
Browse files Browse the repository at this point in the history
…tes incorrect metric values for IPv4 directly connected routes.

The IPv4 directly connected route prefix exists in both the root LSP and the root's neighbor LSP:

When generating vertices for directly connected route prefixes with a metric of 0 based on the root LSP, the isis_spf_preload_tent_ip_reach_cb function only generates vertices of type VTYPE_IPREACH_INTERNAL without distinguishing between area->oldmetric and area->newmetric.
When generating vertices for the directly connected route prefix based on the neighbor LSP, the isis_spf_process_lsp function will generate vertices of type VTYPE_IPREACH_INTERNAL and VTYPE_IPREACH_TE based on area->oldmetric and area->newmetric, where the vertex metric is the sum of the metric from the root IS to the neighbor IS and from the neighbor IS to the root IS, respectively.
If area->newmetric==1, the same directly connected route prefix will have both VTYPE_IPREACH_INTERNAL vertices with a metric of 0 and VTYPE_IPREACH_TE vertices with a non-zero metric. During route generation, the isis_spf_loop function will prioritize selecting VTYPE_IPREACH_TE vertices, leading to incorrect metrics for the directly connected routes.

Supplement topotest modifications. Directly connected routes with incorrect ISIS cost calculations should not appear in the RIB.

Signed-off-by: zhou-run <zhou.run@h3c.com>
  • Loading branch information
zhou-run committed Aug 26, 2024
1 parent 6186368 commit 512f6f9
Show file tree
Hide file tree
Showing 224 changed files with 169 additions and 11,958 deletions.
24 changes: 20 additions & 4 deletions isisd/isis_spf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1265,7 +1265,7 @@ static int isis_spf_preload_tent_ip_reach_cb(const struct prefix *prefix,
struct isis_vertex *parent = args->parent;
struct prefix_pair ip_info;
enum vertextype vtype;
bool has_valid_psid = false;
bool has_valid_psid = false, transition = false;

if (external)
return LSP_ITER_CONTINUE;
Expand All @@ -1275,10 +1275,17 @@ static int isis_spf_preload_tent_ip_reach_cb(const struct prefix *prefix,
prefix_copy(&ip_info.dest, prefix);
apply_mask(&ip_info.dest);

if (prefix->family == AF_INET)
if (prefix->family == AF_INET) {
vtype = VTYPE_IPREACH_INTERNAL;
else

if (spftree->area->newmetric)
vtype = VTYPE_IPREACH_TE;

if (spftree->area->oldmetric && spftree->area->newmetric)
transition = true;
} else {
vtype = VTYPE_IP6REACH_INTERNAL;
}

/* Parse list of Prefix-SID subTLVs if SR is enabled */
if (spftree->area->srdb.enabled && subtlvs) {
Expand All @@ -1293,6 +1300,11 @@ static int isis_spf_preload_tent_ip_reach_cb(const struct prefix *prefix,
has_valid_psid = true;
isis_spf_add_local(spftree, vtype, &ip_info, NULL, 0,
psid, parent);
if (transition)
isis_spf_add_local(spftree,
VTYPE_IPREACH_INTERNAL,
&ip_info, NULL, 0, psid,
parent);

/*
* Stop the Prefix-SID iteration since we only support
Expand All @@ -1301,9 +1313,13 @@ static int isis_spf_preload_tent_ip_reach_cb(const struct prefix *prefix,
break;
}
}
if (!has_valid_psid)
if (!has_valid_psid) {
isis_spf_add_local(spftree, vtype, &ip_info, NULL, 0, NULL,
parent);
if (transition)
isis_spf_add_local(spftree, VTYPE_IPREACH_INTERNAL,
&ip_info, NULL, 0, NULL, parent);
}

return LSP_ITER_CONTINUE;
}
Expand Down
150 changes: 75 additions & 75 deletions tests/isisd/test_isis_spf.refout

Large diffs are not rendered by default.

20 changes: 0 additions & 20 deletions tests/topotests/isis_lsp_bits_topo1/rt1/step1/show_ip_route.ref
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,5 @@
}
]
}
],
"10.0.1.0\/24":[
{
"prefix":"10.0.1.0\/24",
"protocol":"isis",
"distance":115,
"metric":20,
"nexthops":[
{
"ip":"10.0.1.2",
"afi":"ipv4",
"interfaceName":"eth-sw1"
},
{
"ip":"10.0.1.3",
"afi":"ipv4",
"interfaceName":"eth-sw1"
}
]
}
]
}
20 changes: 0 additions & 20 deletions tests/topotests/isis_lsp_bits_topo1/rt1/step2/show_ip_route.ref
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,5 @@
}
]
}
],
"10.0.1.0\/24":[
{
"prefix":"10.0.1.0\/24",
"protocol":"isis",
"distance":115,
"metric":20,
"nexthops":[
{
"ip":"10.0.1.2",
"afi":"ipv4",
"interfaceName":"eth-sw1"
},
{
"ip":"10.0.1.3",
"afi":"ipv4",
"interfaceName":"eth-sw1"
}
]
}
]
}
20 changes: 0 additions & 20 deletions tests/topotests/isis_lsp_bits_topo1/rt1/step3/show_ip_route.ref
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,5 @@
}
]
}
],
"10.0.1.0\/24":[
{
"prefix":"10.0.1.0\/24",
"protocol":"isis",
"distance":115,
"metric":20,
"nexthops":[
{
"ip":"10.0.1.2",
"afi":"ipv4",
"interfaceName":"eth-sw1"
},
{
"ip":"10.0.1.3",
"afi":"ipv4",
"interfaceName":"eth-sw1"
}
]
}
]
}
20 changes: 0 additions & 20 deletions tests/topotests/isis_lsp_bits_topo1/rt1/step4/show_ip_route.ref
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,5 @@
}
]
}
],
"10.0.1.0\/24":[
{
"prefix":"10.0.1.0\/24",
"protocol":"isis",
"distance":115,
"metric":20,
"nexthops":[
{
"ip":"10.0.1.2",
"afi":"ipv4",
"interfaceName":"eth-sw1"
},
{
"ip":"10.0.1.3",
"afi":"ipv4",
"interfaceName":"eth-sw1"
}
]
}
]
}
35 changes: 0 additions & 35 deletions tests/topotests/isis_lsp_bits_topo1/rt2/step1/show_ip_route.ref
Original file line number Diff line number Diff line change
Expand Up @@ -38,40 +38,5 @@
}
]
}
],
"10.0.1.0\/24":[
{
"prefix":"10.0.1.0\/24",
"protocol":"isis",
"distance":115,
"metric":20,
"nexthops":[
{
"ip":"10.0.1.1",
"afi":"ipv4",
"interfaceName":"eth-sw1"
},
{
"ip":"10.0.1.3",
"afi":"ipv4",
"interfaceName":"eth-sw1"
}
]
}
],
"10.0.2.0\/24":[
{
"prefix":"10.0.2.0\/24",
"protocol":"isis",
"distance":115,
"metric":20,
"nexthops":[
{
"ip":"10.0.2.4",
"afi":"ipv4",
"interfaceName":"eth-rt4"
}
]
}
]
}
35 changes: 0 additions & 35 deletions tests/topotests/isis_lsp_bits_topo1/rt3/step1/show_ip_route.ref
Original file line number Diff line number Diff line change
Expand Up @@ -58,40 +58,5 @@
}
]
}
],
"10.0.1.0\/24":[
{
"prefix":"10.0.1.0\/24",
"protocol":"isis",
"distance":115,
"metric":20,
"nexthops":[
{
"ip":"10.0.1.1",
"afi":"ipv4",
"interfaceName":"eth-sw1"
},
{
"ip":"10.0.1.2",
"afi":"ipv4",
"interfaceName":"eth-sw1"
}
]
}
],
"10.0.4.0\/24":[
{
"prefix":"10.0.4.0\/24",
"protocol":"isis",
"distance":115,
"metric":20,
"nexthops":[
{
"ip":"10.0.4.5",
"afi":"ipv4",
"interfaceName":"eth-rt5"
}
]
}
]
}
45 changes: 0 additions & 45 deletions tests/topotests/isis_lsp_bits_topo1/rt4/step1/show_ip_route.ref
Original file line number Diff line number Diff line change
Expand Up @@ -19,51 +19,6 @@
]
}
],
"10.0.2.0\/24":[
{
"prefix":"10.0.2.0\/24",
"protocol":"isis",
"distance":115,
"metric":20,
"nexthops":[
{
"ip":"10.0.2.2",
"afi":"ipv4",
"interfaceName":"eth-rt2"
}
]
}
],
"10.0.6.0\/24":[
{
"prefix":"10.0.6.0\/24",
"protocol":"isis",
"distance":115,
"metric":20,
"nexthops":[
{
"ip":"10.0.6.5",
"afi":"ipv4",
"interfaceName":"eth-rt5"
}
]
}
],
"10.0.7.0\/24":[
{
"prefix":"10.0.7.0\/24",
"protocol":"isis",
"distance":115,
"metric":20,
"nexthops":[
{
"ip":"10.0.7.6",
"afi":"ipv4",
"interfaceName":"eth-rt6"
}
]
}
],
"10.0.8.0\/24":[
{
"prefix":"10.0.8.0\/24",
Expand Down
46 changes: 0 additions & 46 deletions tests/topotests/isis_lsp_bits_topo1/rt5/step1/show_ip_route.ref
Original file line number Diff line number Diff line change
Expand Up @@ -39,36 +39,6 @@
]
}
],
"10.0.4.0\/24":[
{
"prefix":"10.0.4.0\/24",
"protocol":"isis",
"distance":115,
"metric":20,
"nexthops":[
{
"ip":"10.0.4.3",
"afi":"ipv4",
"interfaceName":"eth-rt3"
}
]
}
],
"10.0.6.0\/24":[
{
"prefix":"10.0.6.0\/24",
"protocol":"isis",
"distance":115,
"metric":20,
"nexthops":[
{
"ip":"10.0.6.4",
"afi":"ipv4",
"interfaceName":"eth-rt4"
}
]
}
],
"10.0.7.0\/24":[
{
"prefix":"10.0.7.0\/24",
Expand Down Expand Up @@ -96,21 +66,5 @@
}
]
}
],
"10.0.8.0\/24":[
{
"prefix":"10.0.8.0\/24",
"protocol":"isis",
"distance":115,
"metric":20,
"nexthops":[
{
"ip":"10.0.8.6",
"afi":"ipv4",
"interfaceName":"eth-rt6",
"weight":1
}
]
}
]
}
30 changes: 0 additions & 30 deletions tests/topotests/isis_lsp_bits_topo1/rt6/step1/show_ip_route.ref
Original file line number Diff line number Diff line change
Expand Up @@ -72,35 +72,5 @@
}
]
}
],
"10.0.7.0\/24":[
{
"prefix":"10.0.7.0\/24",
"protocol":"isis",
"distance":115,
"metric":20,
"nexthops":[
{
"ip":"10.0.7.4",
"afi":"ipv4",
"interfaceName":"eth-rt4"
}
]
}
],
"10.0.8.0\/24":[
{
"prefix":"10.0.8.0\/24",
"protocol":"isis",
"distance":115,
"metric":20,
"nexthops":[
{
"ip":"10.0.8.5",
"afi":"ipv4",
"interfaceName":"eth-rt5"
}
]
}
]
}
Loading

0 comments on commit 512f6f9

Please sign in to comment.