From f73fe7b75dd7a40e0e9bca3b7414d0b43e1bd1ef Mon Sep 17 00:00:00 2001 From: Sososhas <1248756005hfh@gmail.com> Date: Thu, 19 Oct 2023 23:39:24 +0300 Subject: [PATCH] isisd: added l1 to l2 distibution added adding prefixes with the best metric from the level-1 db to the level-2 db on l1_l2 end system Signed-off-by: Sososhas <1248756005hfh@gmail.com> --- isisd/isis_lsp.c | 68 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 61 insertions(+), 7 deletions(-) diff --git a/isisd/isis_lsp.c b/isisd/isis_lsp.c index 1b3491f5d38e..ffb7174b6080 100644 --- a/isisd/isis_lsp.c +++ b/isisd/isis_lsp.c @@ -1317,6 +1317,15 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area) false, false, false); } + struct isis_adjacency* adj; + bool flag = false; + for (ALL_LIST_ELEMENTS_RO(area->adjacency_list, node, adj)) { + if (adj->level == IS_LEVEL_2) + flag = true; + } + + + struct isis_circuit *circuit; for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) { if (!circuit->interface) @@ -1348,6 +1357,7 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area) ? circuit->metric[level - 1] : circuit->te_metric[level - 1]; + if (circuit->ip_router && circuit->ip_addrs->count > 0) { lsp_debug( "ISIS (%s): Circuit has IPv4 active, adding respective TLVs.", @@ -1360,14 +1370,58 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area) metric); } - if (circuit->ipv6_router && circuit->ipv6_non_link->count > 0) { - struct listnode *ipnode; - struct prefix_ipv6 *ipv6; - for (ALL_LIST_ELEMENTS_RO(circuit->ipv6_non_link, - ipnode, ipv6)) - lsp_build_internal_reach_ipv6(lsp, area, ipv6, - metric); + if (circuit->ipv6_router && circuit->ipv6_non_link->count > 0) { + struct listnode *ipnode; + struct prefix_ipv6 *ipv6; + char prefixbuf[PREFIX2STR_BUFFER]; + for (ALL_LIST_ELEMENTS_RO(circuit->ipv6_non_link, + ipnode, ipv6)) { + lsp_build_internal_reach_ipv6(lsp, area, ipv6, + metric); + } + } + + if(flag && (lsp->level == IS_LEVEL_2) && (area->is_type == 3) && (lsp->hdr.lsp_bits != LSPBIT_ATT)) { + struct isis_lsp* lsp_tmp; + struct lspdb_head *head_tmp = &area->lspdb[0]; + if(head_tmp) { + frr_each (lspdb, head_tmp, lsp_tmp) { + if (strcmp(lsp->tlvs->hostname, lsp_tmp->tlvs->hostname) != 0) { + for (struct isis_item* i = lsp_tmp->tlvs->extended_ip_reach.head; i; i = i->next){ + struct isis_extended_ip_reach *r = (struct isis_extended_ip_reach *)i; + int count = 0; + for (struct isis_item* l = lsp->tlvs->extended_ip_reach.head; l; l = l->next) { + struct isis_extended_ip_reach *rt = (struct isis_extended_ip_reach *)l; + if(r->prefix.prefix.s_addr == rt->prefix.prefix.s_addr) { + if ((r->metric > rt->metric) || (r->metric == rt->metric)) + count++; + break; + } + } + if (count == 0) { + lsp_build_internal_reach_ipv4(lsp, area, &r->prefix , r->metric); + } + } + for (struct isis_item* i = lsp_tmp->tlvs->ipv6_reach.head; i; i = i->next){ + struct isis_ipv6_reach *r = (struct isis_ipv6_reach *)i; + int count = 0; + for (struct isis_item* l = lsp->tlvs->ipv6_reach.head; l; l = l->next) { + struct isis_ipv6_reach *rt = (struct isis_ipv6_reach *)l; + char prefixbuf_1[PREFIX2STR_BUFFER]; + char prefixbuf_2[PREFIX2STR_BUFFER]; + if(strcmp(prefix2str(&r->prefix, prefixbuf_1, sizeof(prefixbuf_1)), prefix2str(&rt->prefix, prefixbuf_2, sizeof(prefixbuf_2))) == 0){ + if ((r->metric > rt->metric) || (r->metric == rt->metric)) + count++; + break; + } + } + if (count == 0) + lsp_build_internal_reach_ipv6(lsp, area, &r->prefix, r->metric); + } + } + } + } } switch (circuit->circ_type) {