]> git.puffer.fish Git - mirror/frr.git/commitdiff
pimd: Cleanup the deletion event a tiny bit
authorDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 11 May 2018 17:46:59 +0000 (13:46 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 11 May 2018 22:36:24 +0000 (18:36 -0400)
The pim_upstream_free command was leaving slag by
not deleting data associated with the upstream
data structure.  Modify the code to explicitly free
all data associated with an upstream on a pim instance
deletion event.  Additionally the end result is that
the pim_upstream_free command is not needed anymore

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
pimd/pim_upstream.c
pimd/pim_upstream.h

index b5f5f646d42aba7aebe4a61d71d9b848403bbb42..37dff2d05883a7f0a3b41aedf5d9cd71c7956b5b 100644 (file)
@@ -140,12 +140,6 @@ static struct pim_upstream *pim_upstream_find_parent(struct pim_instance *pim,
        return NULL;
 }
 
-void pim_upstream_free(struct pim_upstream *up)
-{
-       XFREE(MTYPE_PIM_UPSTREAM, up);
-       up = NULL;
-}
-
 static void upstream_channel_oil_detach(struct pim_upstream *up)
 {
        if (up->channel_oil) {
@@ -209,11 +203,6 @@ struct pim_upstream *pim_upstream_del(struct pim_instance *pim,
 
        list_delete_and_null(&up->ifchannels);
 
-       /*
-         notice that listnode_delete() can't be moved
-         into pim_upstream_free() because the later is
-         called by list_delete_all_node()
-       */
        if (up->parent && up->parent->sources)
                listnode_delete(up->parent->sources, up);
        up->parent = NULL;
@@ -237,7 +226,7 @@ struct pim_upstream *pim_upstream_del(struct pim_instance *pim,
        }
        pim_delete_tracked_nexthop(pim, &nht_p, up, NULL);
 
-       pim_upstream_free(up);
+       XFREE(MTYPE_PIM_UPSTREAM, up);
 
        return NULL;
 }
@@ -1545,8 +1534,15 @@ unsigned int pim_upstream_hash_key(void *arg)
 
 void pim_upstream_terminate(struct pim_instance *pim)
 {
-       if (pim->upstream_list)
+       struct listnode *node, *nnode;
+       struct pim_upstream *up;
+
+       if (pim->upstream_list) {
+               for (ALL_LIST_ELEMENTS(pim->upstream_list, node, nnode, up))
+                       pim_upstream_del(pim, up, __PRETTY_FUNCTION__);
+
                list_delete_and_null(&pim->upstream_list);
+       }
 
        if (pim->upstream_hash)
                hash_free(pim->upstream_hash);
@@ -1773,6 +1769,5 @@ void pim_upstream_init(struct pim_instance *pim)
                                              pim_upstream_equal, hash_name);
 
        pim->upstream_list = list_new();
-       pim->upstream_list->del = (void (*)(void *))pim_upstream_free;
        pim->upstream_list->cmp = pim_upstream_compare;
 }
index b75a5b9df376e74cfaab7c02096f08008ea3864e..ba133b39dd444a3a3508d501049389b9b11fdc4d 100644 (file)
@@ -137,7 +137,6 @@ struct pim_upstream {
        int64_t state_transition; /* Record current state uptime */
 };
 
-void pim_upstream_free(struct pim_upstream *up);
 struct pim_upstream *pim_upstream_find(struct pim_instance *pim,
                                       struct prefix_sg *sg);
 struct pim_upstream *pim_upstream_find_or_add(struct prefix_sg *sg,