From cb24fec45cb6f281263b0cc778e330a4eb710af1 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 27 Oct 2016 20:35:22 -0400 Subject: [PATCH] pimd: Clean up the interface deletion When cleaning up the interface, actually clean up data associated with that interface. Signed-off-by: Donald Sharp --- pimd/pim_iface.c | 11 +++-------- pimd/pim_ifchannel.c | 17 +++++++++++++++++ pimd/pim_ifchannel.h | 1 + pimd/pim_igmp.c | 16 ++++++++++++++++ pimd/pim_igmp.h | 2 +- 5 files changed, 38 insertions(+), 9 deletions(-) diff --git a/pimd/pim_iface.c b/pimd/pim_iface.c index 3f3629395c..50490fc9cb 100644 --- a/pimd/pim_iface.c +++ b/pimd/pim_iface.c @@ -185,16 +185,11 @@ void pim_if_delete(struct interface *ifp) if (pim_ifp->igmp_join_list) { pim_if_igmp_join_del_all(ifp); } - zassert(!pim_ifp->igmp_join_list); - zassert(pim_ifp->igmp_socket_list); - zassert(!listcount(pim_ifp->igmp_socket_list)); + pim_ifchannel_delete_all (ifp); + igmp_sock_delete_all (ifp); - zassert(pim_ifp->pim_neighbor_list); - zassert(!listcount(pim_ifp->pim_neighbor_list)); - - zassert(pim_ifp->pim_ifchannel_list); - zassert(!listcount(pim_ifp->pim_ifchannel_list)); + pim_neighbor_delete_all (ifp, "Interface removed from configuration"); if (PIM_MROUTE_IS_ENABLED) { pim_if_del_vif(ifp); diff --git a/pimd/pim_ifchannel.c b/pimd/pim_ifchannel.c index c2d27f1ec8..45d1d94344 100644 --- a/pimd/pim_ifchannel.c +++ b/pimd/pim_ifchannel.c @@ -143,6 +143,23 @@ void pim_ifchannel_delete(struct pim_ifchannel *ch) pim_ifchannel_free(ch); } + +void +pim_ifchannel_delete_all (struct interface *ifp) +{ + struct pim_interface *pim_ifp; + struct listnode *ifchannel_node; + struct listnode *ifchannel_nextnode; + struct pim_ifchannel *ifchannel; + + pim_ifp = ifp->info; + + for (ALL_LIST_ELEMENTS (pim_ifp->pim_ifchannel_list, ifchannel_node, + ifchannel_nextnode, ifchannel)) + { + pim_ifchannel_delete (ifchannel); + } +} static void delete_on_noinfo(struct pim_ifchannel *ch) { diff --git a/pimd/pim_ifchannel.h b/pimd/pim_ifchannel.h index 8c542d17f2..107762c652 100644 --- a/pimd/pim_ifchannel.h +++ b/pimd/pim_ifchannel.h @@ -100,6 +100,7 @@ struct pim_ifchannel { void pim_ifchannel_free(struct pim_ifchannel *ch); void pim_ifchannel_delete(struct pim_ifchannel *ch); +void pim_ifchannel_delete_all (struct interface *ifp); void pim_ifchannel_membership_clear(struct interface *ifp); void pim_ifchannel_delete_on_noinfo(struct interface *ifp); struct pim_ifchannel *pim_ifchannel_find(struct interface *ifp, diff --git a/pimd/pim_igmp.c b/pimd/pim_igmp.c index 5532dc1dd0..04689a030f 100644 --- a/pimd/pim_igmp.c +++ b/pimd/pim_igmp.c @@ -781,6 +781,22 @@ void igmp_sock_delete(struct igmp_sock *igmp) igmp_sock_free(igmp); } +void +igmp_sock_delete_all (struct interface *ifp) +{ + struct pim_interface *pim_ifp; + struct listnode *igmp_node, *igmp_nextnode; + struct igmp_sock *igmp; + + pim_ifp = ifp->info; + + for (ALL_LIST_ELEMENTS (pim_ifp->igmp_socket_list, igmp_node, + igmp_nextnode, igmp)) + { + igmp_sock_delete(igmp); + } +} + static struct igmp_sock *igmp_sock_new(int fd, struct in_addr ifaddr, struct interface *ifp) diff --git a/pimd/pim_igmp.h b/pimd/pim_igmp.h index fa2c255dd0..c9000e3fd9 100644 --- a/pimd/pim_igmp.h +++ b/pimd/pim_igmp.h @@ -101,7 +101,7 @@ struct igmp_sock *pim_igmp_sock_add(struct list *igmp_sock_list, struct interface *ifp); void igmp_sock_delete(struct igmp_sock *igmp); void igmp_sock_free(struct igmp_sock *igmp); - +void igmp_sock_delete_all (struct interface *ifp); int pim_igmp_packet(struct igmp_sock *igmp, char *buf, size_t len); void pim_igmp_general_query_on(struct igmp_sock *igmp); -- 2.39.5