pimd: Clean up the interface deletion

When cleaning up the interface, actually clean up
data associated with that interface.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2016-10-27 20:35:22 -04:00
parent f4075cb472
commit cb24fec45c
5 changed files with 38 additions and 9 deletions

View File

@ -185,16 +185,11 @@ void pim_if_delete(struct interface *ifp)
if (pim_ifp->igmp_join_list) { if (pim_ifp->igmp_join_list) {
pim_if_igmp_join_del_all(ifp); pim_if_igmp_join_del_all(ifp);
} }
zassert(!pim_ifp->igmp_join_list);
zassert(pim_ifp->igmp_socket_list); pim_ifchannel_delete_all (ifp);
zassert(!listcount(pim_ifp->igmp_socket_list)); igmp_sock_delete_all (ifp);
zassert(pim_ifp->pim_neighbor_list); pim_neighbor_delete_all (ifp, "Interface removed from configuration");
zassert(!listcount(pim_ifp->pim_neighbor_list));
zassert(pim_ifp->pim_ifchannel_list);
zassert(!listcount(pim_ifp->pim_ifchannel_list));
if (PIM_MROUTE_IS_ENABLED) { if (PIM_MROUTE_IS_ENABLED) {
pim_if_del_vif(ifp); pim_if_del_vif(ifp);

View File

@ -143,6 +143,23 @@ void pim_ifchannel_delete(struct pim_ifchannel *ch)
pim_ifchannel_free(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) static void delete_on_noinfo(struct pim_ifchannel *ch)
{ {

View File

@ -100,6 +100,7 @@ struct pim_ifchannel {
void pim_ifchannel_free(struct pim_ifchannel *ch); void pim_ifchannel_free(struct pim_ifchannel *ch);
void pim_ifchannel_delete(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_membership_clear(struct interface *ifp);
void pim_ifchannel_delete_on_noinfo(struct interface *ifp); void pim_ifchannel_delete_on_noinfo(struct interface *ifp);
struct pim_ifchannel *pim_ifchannel_find(struct interface *ifp, struct pim_ifchannel *pim_ifchannel_find(struct interface *ifp,

View File

@ -781,6 +781,22 @@ void igmp_sock_delete(struct igmp_sock *igmp)
igmp_sock_free(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, static struct igmp_sock *igmp_sock_new(int fd,
struct in_addr ifaddr, struct in_addr ifaddr,
struct interface *ifp) struct interface *ifp)

View File

@ -101,7 +101,7 @@ struct igmp_sock *pim_igmp_sock_add(struct list *igmp_sock_list,
struct interface *ifp); struct interface *ifp);
void igmp_sock_delete(struct igmp_sock *igmp); void igmp_sock_delete(struct igmp_sock *igmp);
void igmp_sock_free(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); int pim_igmp_packet(struct igmp_sock *igmp, char *buf, size_t len);
void pim_igmp_general_query_on(struct igmp_sock *igmp); void pim_igmp_general_query_on(struct igmp_sock *igmp);