summaryrefslogtreecommitdiff
path: root/isisd/isis_te.c
diff options
context:
space:
mode:
authorOlivier Dugeon <olivier.dugeon@orange.com>2022-08-05 16:00:48 +0200
committerOlivier Dugeon <olivier.dugeon@orange.com>2022-09-02 15:04:35 +0200
commit1fa6385040df57f2d175cd628d7775af2f6c7561 (patch)
treeb4f9542aff901c9c65d32cdb8aa570ab35d79f21 /isisd/isis_te.c
parent1011b31a1c72f0fd92a508c486406f3287a6c8e4 (diff)
isisd: Correct Valgrind errors
Runing most of isisd tests with --valgrind-memleaks give many memory errors. This is due to the way isisd is stopped: performing a "no router isis XXX" through CLI solves most of them. Indeed, isis_finish() doesn't call isis_area_destroy() leaving many allocated memory unfreed. This patch adds call to appropriate delete function or XFREE() when necessary to properly free all alocated memory before terminating isisd. Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
Diffstat (limited to 'isisd/isis_te.c')
-rw-r--r--isisd/isis_te.c105
1 files changed, 105 insertions, 0 deletions
diff --git a/isisd/isis_te.c b/isisd/isis_te.c
index 3faff1cc4d..0093279cde 100644
--- a/isisd/isis_te.c
+++ b/isisd/isis_te.c
@@ -64,10 +64,115 @@
#include "isisd/isis_te.h"
#include "isisd/isis_zebra.h"
+DEFINE_MTYPE_STATIC(ISISD, ISIS_MPLS_TE, "ISIS MPLS_TE parameters");
+
/*------------------------------------------------------------------------*
* Following are control functions for MPLS-TE parameters management.
*------------------------------------------------------------------------*/
+/**
+ * Create MPLS Traffic Engineering structure which belongs to given area.
+ *
+ * @param area IS-IS Area
+ */
+void isis_mpls_te_create(struct isis_area *area)
+{
+ struct listnode *node;
+ struct isis_circuit *circuit;
+
+ if (!area)
+ return;
+
+ if (area->mta == NULL) {
+
+ struct mpls_te_area *new;
+
+ zlog_debug("ISIS-TE(%s): Initialize MPLS Traffic Engineering",
+ area->area_tag);
+
+ new = XCALLOC(MTYPE_ISIS_MPLS_TE, sizeof(struct mpls_te_area));
+
+ /* Initialize MPLS_TE structure */
+ new->status = enable;
+ new->level = 0;
+ new->inter_as = off;
+ new->interas_areaid.s_addr = 0;
+ new->router_id.s_addr = 0;
+ new->ted = ls_ted_new(1, "ISIS", 0);
+ if (!new->ted)
+ zlog_warn("Unable to create Link State Data Base");
+
+ area->mta = new;
+ } else {
+ area->mta->status = enable;
+ }
+
+ /* Initialize Link State Database */
+ if (area->mta->ted)
+ isis_te_init_ted(area);
+
+ /* Update Extended TLVs according to Interface link parameters */
+ for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit))
+ isis_link_params_update(circuit, circuit->interface);
+}
+
+/**
+ * Disable MPLS Traffic Engineering structure which belongs to given area.
+ *
+ * @param area IS-IS Area
+ */
+void isis_mpls_te_disable(struct isis_area *area)
+{
+ struct listnode *node;
+ struct isis_circuit *circuit;
+
+ if (!area->mta)
+ return;
+
+ area->mta->status = disable;
+
+ /* Remove Link State Database */
+ ls_ted_del_all(&area->mta->ted);
+
+ /* Disable Extended SubTLVs on all circuit */
+ for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) {
+ if (!IS_EXT_TE(circuit->ext))
+ continue;
+
+ /* disable MPLS_TE Circuit keeping SR one's */
+ if (IS_SUBTLV(circuit->ext, EXT_ADJ_SID))
+ circuit->ext->status = EXT_ADJ_SID;
+ else if (IS_SUBTLV(circuit->ext, EXT_LAN_ADJ_SID))
+ circuit->ext->status = EXT_LAN_ADJ_SID;
+ else
+ circuit->ext->status = 0;
+ }
+}
+
+void isis_mpls_te_term(struct isis_area *area)
+{
+ struct listnode *node;
+ struct isis_circuit *circuit;
+
+ if (!area->mta)
+ return;
+
+ zlog_info("TE(%s): Terminate MPLS TE", __func__);
+ /* Remove Link State Database */
+ ls_ted_del_all(&area->mta->ted);
+
+ /* Remove Extended SubTLVs */
+ zlog_info(" |- Remove Extended SubTLVS for all circuit");
+ for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) {
+ zlog_info(" |- Call isis_del_ext_subtlvs()");
+ isis_del_ext_subtlvs(circuit->ext);
+ circuit->ext = NULL;
+ }
+
+ zlog_info(" |- Free MTA structure at %p", area->mta);
+ XFREE(MTYPE_ISIS_MPLS_TE, area->mta);
+}
+
/* Main initialization / update function of the MPLS TE Circuit context */
/* Call when interface TE Link parameters are modified */
void isis_link_params_update(struct isis_circuit *circuit,