isisd: Correction of subnets creation in the TED

Subnets may be incorrectly created in the IS-IS Traffic Engineering Database
(TED). Indeed, to be usable, the subnets advertised by IS-IS peers must be
adjusted to avoid misinterpretation. For example, consider R1 which is
connected to R2 with IP addresses 10.0.0.1/24 (R1) and 10.0.0.2/24 (R2).
R1 and R2 will advertize the prefix 10.0.0.0/24. By leaving the subnet with the
prefix 10.0.0.0/24 in the TED, it is not possible to determine whether
10.0.0.1 is attached to R1 or R2 or whether 10.0.0.3 exists.

So to avoid this, the subnet prefixes are adjusted with the IP addresses of the
local interface. But IS-IS can start to advertise the subnet when not all
adjacencies are up, especially when IPv4 and IPv6 are configured on the same
interface. This results in an uncorrected prefix, e.g. 10.0.0.0/24, remaining
in the TED when it should be removed.

This problem affects some isis-related tests such as the CSPF test.

This patch fixes this bug by removing the uncorrected prefix before adding the
the corrected version.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
This commit is contained in:
Olivier Dugeon 2023-03-30 17:53:33 +02:00
parent d246726b5e
commit 8ab42c4242

View File

@ -1075,9 +1075,21 @@ static int lsp_to_subnet_cb(const struct prefix *prefix, uint32_t metric,
}
if (!std)
prefix_copy(&p, prefix);
else
else {
/* Remove old subnet if any before prefix adjustment */
subnet = ls_find_subnet(args->ted, *prefix);
if (subnet) {
if (args->export) {
subnet->status = DELETE;
isis_te_export(LS_MSG_TYPE_PREFIX, subnet);
}
te_debug(" |- Remove subnet with prefix %pFX",
&subnet->key);
ls_subnet_del_all(args->ted, subnet);
}
te_debug(" |- Adjust prefix %pFX with local address to: %pFX",
prefix, &p);
}
/* Search existing Subnet in TED ... */
subnet = ls_find_subnet(args->ted, p);
@ -1085,6 +1097,7 @@ static int lsp_to_subnet_cb(const struct prefix *prefix, uint32_t metric,
if (!subnet) {
ls_pref = ls_prefix_new(vertex->node->adv, p);
subnet = ls_subnet_add(args->ted, ls_pref);
/* Stop processing if we are unable to create a new subnet */
if (!subnet)
return LSP_ITER_CONTINUE;
}