]> git.puffer.fish Git - mirror/frr.git/commitdiff
ospfd: Fix memory leaks
authorChirag Shah <chirag@cumulusnetworks.com>
Thu, 13 Jul 2017 20:33:29 +0000 (13:33 -0700)
committerChirag Shah <chirag@cumulusnetworks.com>
Thu, 27 Jul 2017 17:06:33 +0000 (10:06 -0700)
Verified  ospfd configuraiton with valgrind,

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
ospfd/ospf_memory.c
ospfd/ospf_memory.h
ospfd/ospf_zebra.c
ospfd/ospfd.c

index cdc9b929fa1f3b3f179b82a842b532faac6a2b8c..988991e35c1024b0db4c8b9d74e3163af6638e3c 100644 (file)
@@ -53,3 +53,6 @@ DEFINE_MTYPE(OSPFD, OSPF_IF_PARAMS, "OSPF if params")
 DEFINE_MTYPE(OSPFD, OSPF_MESSAGE, "OSPF message")
 DEFINE_MTYPE(OSPFD, OSPF_MPLS_TE, "OSPF MPLS parameters")
 DEFINE_MTYPE(OSPFD, OSPF_PCE_PARAMS, "OSPF PCE parameters")
+DEFINE_MTYPE(OSPFD, OSPF_EXTERNAL, "OSPF External route table")
+DEFINE_MTYPE(OSPFD, OSPF_REDISTRIBUTE, "OSPF Redistriute")
+
index 5f5960eec7cc48c01ffdd9ba047a5f587bd24335..d91cbd4111cceeb533cd0c46919d34a020ec427b 100644 (file)
@@ -52,5 +52,7 @@ DECLARE_MTYPE(OSPF_IF_PARAMS)
 DECLARE_MTYPE(OSPF_MESSAGE)
 DECLARE_MTYPE(OSPF_MPLS_TE)
 DECLARE_MTYPE(OSPF_PCE_PARAMS)
+DECLARE_MTYPE(OSPF_EXTERNAL)
+DECLARE_MTYPE(OSPF_REDISTRIBUTE)
 
 #endif /* _QUAGGA_OSPF_MEMORY_H */
index c6b0955dab0003c63a05f840b3e1346de848832f..5839eb40ec5b27b0b305d731f1a5d6e19249cb19 100644 (file)
@@ -628,7 +628,8 @@ struct ospf_external *ospf_external_add(u_char type, u_short instance)
                om->external[type] = list_new();
 
        ext_list = om->external[type];
-       ext = (struct ospf_external *)calloc(1, sizeof(struct ospf_external));
+       ext = (struct ospf_external *)XCALLOC(MTYPE_OSPF_EXTERNAL,
+                                             sizeof(struct ospf_external));
        ext->instance = instance;
        EXTERNAL_INFO(ext) = route_table_init();
 
@@ -652,6 +653,7 @@ void ospf_external_del(u_char type, u_short instance)
                        list_free(om->external[type]);
                        om->external[type] = NULL;
                }
+               XFREE(MTYPE_OSPF_EXTERNAL, ext);
        }
 }
 
@@ -687,7 +689,8 @@ struct ospf_redist *ospf_redist_add(struct ospf *ospf, u_char type,
                ospf->redist[type] = list_new();
 
        red_list = ospf->redist[type];
-       red = (struct ospf_redist *)calloc(1, sizeof(struct ospf_redist));
+       red = (struct ospf_redist *)XCALLOC(MTYPE_OSPF_REDISTRIBUTE,
+                                           sizeof(struct ospf_redist));
        red->instance = instance;
        red->dmetric.type = -1;
        red->dmetric.value = -1;
@@ -709,6 +712,7 @@ void ospf_redist_del(struct ospf *ospf, u_char type, u_short instance)
                        list_free(ospf->redist[type]);
                        ospf->redist[type] = NULL;
                }
+               XFREE(MTYPE_OSPF_REDISTRIBUTE, red);
        }
 }
 
index cee2244dd99f2c0579c4d78c1bbda5196352f7c6..77378512e549fbe412392834472814632bb698da 100644 (file)
@@ -590,6 +590,7 @@ static void ospf_finish_final(struct ospf *ospf)
                        route_unlock_node(rn);
                }
        }
+       route_table_finish(ospf->networks);
 
        for (ALL_LIST_ELEMENTS(ospf->areas, node, nnode, area)) {
                listnode_delete(ospf->areas, area);
@@ -655,6 +656,8 @@ static void ospf_finish_final(struct ospf *ospf)
        }
 
        list_delete(ospf->areas);
+       list_delete(ospf->oi_write_q);
+       list_delete(ospf->oiflist);
 
        for (i = ZEBRA_ROUTE_SYSTEM; i <= ZEBRA_ROUTE_MAX; i++) {
                struct list *ext_list;
@@ -752,6 +755,7 @@ static void ospf_area_free(struct ospf_area *area)
        LSDB_LOOP(OPAQUE_LINK_LSDB(area), rn, lsa)
        ospf_discard_from_db(area->ospf, area->lsdb, lsa);
 
+       ospf_opaque_type10_lsa_term(area);
        ospf_lsdb_delete_all(area->lsdb);
        ospf_lsdb_free(area->lsdb);