]> git.proxmox.com Git - mirror_frr.git/blobdiff - isisd/isis_lsp.c
zebra: Fix label manager memory leak (#5680)
[mirror_frr.git] / isisd / isis_lsp.c
index 1991666954b96f34f2641812e6920ee6d3ee8002..c0b90e8439cea1436fb88b221a78c53359a11272 100644 (file)
 #include "isisd/isis_csm.h"
 #include "isisd/isis_adjacency.h"
 #include "isisd/isis_spf.h"
-#include "isisd/isis_te.h"
 #include "isisd/isis_mt.h"
 #include "isisd/isis_tlvs.h"
+#include "isisd/isis_te.h"
 #include "isisd/fabricd.h"
 #include "isisd/isis_tx_queue.h"
+#include "isisd/isis_nb.h"
 
 static int lsp_refresh(struct thread *thread);
 static int lsp_l1_refresh_pseudo(struct thread *thread);
@@ -574,7 +575,7 @@ void lsp_build_list_nonzero_ht(struct lspdb_head *head, const uint8_t *start_id,
        memcpy(&searchfor.hdr.lsp_id, start_id, sizeof(searchfor.hdr.lsp_id));
 
        start = lspdb_find_gteq(head, &searchfor);
-       for_each_from (lspdb, head, lsp, start) {
+       frr_each_from (lspdb, head, lsp, start) {
                if (memcmp(lsp->hdr.lsp_id, stop_id,
                           ISIS_SYS_ID_LEN + 2) > 0)
                        break;
@@ -682,12 +683,12 @@ int lsp_print_all(struct vty *vty, struct lspdb_head *head, char detail,
        int lsp_count = 0;
 
        if (detail == ISIS_UI_LEVEL_BRIEF) {
-               for_each (lspdb, head, lsp) {
+               frr_each (lspdb, head, lsp) {
                        lsp_print(lsp, vty, dynhost);
                        lsp_count++;
                }
        } else if (detail == ISIS_UI_LEVEL_DETAIL) {
-               for_each (lspdb, head, lsp) {
+               frr_each (lspdb, head, lsp) {
                        lsp_print_detail(lsp, vty, dynhost);
                        lsp_count++;
                }
@@ -781,8 +782,8 @@ static void lsp_build_ext_reach_ipv6(struct isis_lsp *lsp,
                if (!rn->info)
                        continue;
                struct isis_ext_info *info = rn->info;
-
                struct prefix_ipv6 *p, *src_p;
+
                srcdest_rnode_prefixes(rn, (const struct prefix **)&p,
                                       (const struct prefix **)&src_p);
 
@@ -863,6 +864,7 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area)
        /* Protocols Supported */
        if (area->ip_circuits > 0 || area->ipv6_circuits > 0) {
                struct nlpids nlpids = {.count = 0};
+
                if (area->ip_circuits > 0) {
                        lsp_debug(
                                "ISIS (%s): Found IPv4 circuit, adding IPv4 to NLPIDs",
@@ -908,10 +910,12 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area)
                          area->area_tag);
        }
 
-       /* IPv4 address and TE router ID TLVs. In case of the first one we don't
-        * follow "C" vendor, but "J" vendor behavior - one IPv4 address is put
-        * into
-        * LSP and this address is same as router id. */
+       /* IPv4 address and TE router ID TLVs.
+        * In case of the first one we don't follow "C" vendor,
+        * but "J" vendor behavior - one IPv4 address is put
+        * into LSP. TE router ID will be the same if MPLS-TE
+        * is not activate or MPLS-TE router-id not specified
+        */
        if (isis->router_id != 0) {
                struct in_addr id = {.s_addr = isis->router_id};
                inet_ntop(AF_INET, &id, buf, sizeof(buf));
@@ -919,11 +923,14 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area)
                          area->area_tag, buf);
                isis_tlvs_add_ipv4_address(lsp->tlvs, &id);
 
-               /* Exactly same data is put into TE router ID TLV, but only if
-                * new style
-                * TLV's are in use. */
+               /* If new style TLV's are in use, add TE router ID TLV
+                * Check if MPLS-TE is activate and mpls-te router-id set
+                * otherwise add exactly same data as for IPv4 address
+                */
                if (area->newmetric) {
-
+                       if (IS_MPLS_TE(area->mta)
+                           && area->mta->router_id.s_addr != 0)
+                               id.s_addr = area->mta->router_id.s_addr;
                        lsp_debug(
                                "ISIS (%s): Adding router ID also as TE router ID tlv.",
                                area->area_tag);
@@ -1004,6 +1011,7 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area)
                    && 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_debug(
@@ -1036,25 +1044,10 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area)
                                                        lsp->tlvs, ne_id,
                                                        metric);
                                        }
-                                       if (area->newmetric) {
-                                               uint8_t subtlvs[256];
-                                               uint8_t subtlv_len;
-
-                                               if (IS_MPLS_TE(area->mta)
-                                                   && circuit->interface
-                                                   && HAS_LINK_PARAMS(
-                                                              circuit->interface))
-                                                       subtlv_len = add_te_subtlvs(
-                                                               subtlvs,
-                                                               circuit->mtc);
-                                               else
-                                                       subtlv_len = 0;
-
+                                       if (area->newmetric)
                                                tlvs_add_mt_bcast(
                                                        lsp->tlvs, circuit,
-                                                       level, ne_id, metric,
-                                                       subtlvs, subtlv_len);
-                                       }
+                                                       level, ne_id, metric);
                                }
                        } else {
                                lsp_debug(
@@ -1079,36 +1072,6 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area)
                                                lsp->tlvs, ne_id, metric);
                                }
                                if (area->newmetric) {
-                                       uint8_t subtlvs[256];
-                                       uint8_t subtlv_len;
-
-                                       if (IS_MPLS_TE(area->mta)
-                                           && circuit->interface != NULL
-                                           && HAS_LINK_PARAMS(
-                                                      circuit->interface))
-                                               /* Update Local and Remote IP
-                                                * address for MPLS TE circuit
-                                                * parameters */
-                                               /* NOTE sure that it is the
-                                                * pertinent place for that
-                                                * updates */
-                                               /* Local IP address could be
-                                                * updated in isis_circuit.c -
-                                                * isis_circuit_add_addr() */
-                                               /* But, where update remote IP
-                                                * address ? in isis_pdu.c -
-                                                * process_p2p_hello() ? */
-
-                                               /* Add SubTLVs & Adjust real
-                                                * size of SubTLVs */
-                                               subtlv_len = add_te_subtlvs(
-                                                       subtlvs, circuit->mtc);
-                                       else
-                                               /* Or keep only TE metric with
-                                                * no SubTLVs if MPLS_TE is off
-                                                */
-                                               subtlv_len = 0;
-
                                        uint32_t neighbor_metric;
                                        if (fabricd_tier(area) == 0) {
                                                neighbor_metric = 0xffe;
@@ -1117,8 +1080,7 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area)
                                        }
 
                                        tlvs_add_mt_p2p(lsp->tlvs, circuit,
-                                                       ne_id, neighbor_metric,
-                                                       subtlvs, subtlv_len);
+                                                       ne_id, neighbor_metric);
                                }
                        } else {
                                lsp_debug(
@@ -1512,7 +1474,7 @@ static void lsp_build_pseudo(struct isis_lsp *lsp, struct isis_circuit *circuit,
        }
        if (circuit->area->newmetric) {
                isis_tlvs_add_extended_reach(lsp->tlvs, ISIS_MT_IPV4_UNICAST,
-                                            ne_id, 0, NULL, 0);
+                                            ne_id, 0, circuit->ext);
                lsp_debug(
                        "ISIS (%s): Adding %s.%02x as te-style neighbor (self)",
                        area->area_tag, sysid_print(ne_id),
@@ -1554,7 +1516,7 @@ static void lsp_build_pseudo(struct isis_lsp *lsp, struct isis_circuit *circuit,
                if (circuit->area->newmetric) {
                        isis_tlvs_add_extended_reach(lsp->tlvs,
                                                     ISIS_MT_IPV4_UNICAST,
-                                                    ne_id, 0, NULL, 0);
+                                                    ne_id, 0, circuit->ext);
                        lsp_debug(
                                "ISIS (%s): Adding %s.%02x as te-style neighbor (peer)",
                                area->area_tag, sysid_print(ne_id),
@@ -1855,7 +1817,7 @@ int lsp_tick(struct thread *thread)
         */
        for (level = 0; level < ISIS_LEVELS; level++) {
                struct isis_lsp *next = lspdb_first(&area->lspdb[level]);
-               for_each_from (lspdb, &area->lspdb[level], lsp, next) {
+               frr_each_from (lspdb, &area->lspdb[level], lsp, next) {
                        /*
                         * The lsp rem_lifetime is kept at 0 for MaxAge
                         * or