From 8ab42c424299d0d73a8c1b9a0863294753382a42 Mon Sep 17 00:00:00 2001 From: Olivier Dugeon Date: Thu, 30 Mar 2023 17:53:33 +0200 Subject: [PATCH 1/2] 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 --- isisd/isis_te.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/isisd/isis_te.c b/isisd/isis_te.c index 45d763fd69..c0b5f35f47 100644 --- a/isisd/isis_te.c +++ b/isisd/isis_te.c @@ -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; } From b10e5cf28e339740d7104edf24be93e19ea20aec Mon Sep 17 00:00:00 2001 From: Olivier Dugeon Date: Thu, 30 Mar 2023 18:15:57 +0200 Subject: [PATCH 2/2] sharpd: Adjust TED builder Following correction of IS-IS subnet creation, this patch adjust the way the TED is created in sharpd to automatically adjust subnet deletion. Signed-off-by: Olivier Dugeon --- sharpd/sharp_zebra.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sharpd/sharp_zebra.c b/sharpd/sharp_zebra.c index 17ad705969..91fb7f03b1 100644 --- a/sharpd/sharp_zebra.c +++ b/sharpd/sharp_zebra.c @@ -790,7 +790,7 @@ static int sharp_opaque_handler(ZAPI_CALLBACK_ARGS) zclient->session_id, info.type); if (info.type == LINK_STATE_UPDATE) { - lse = ls_stream2ted(sg.ted, s, false); + lse = ls_stream2ted(sg.ted, s, true); if (lse) { zlog_debug(" |- Got %s %s from Link State Database", status2txt[lse->status],