pimd: Fix ifchannel being left around

In some situations, the deletion of the ifchannel would
not ocurr if the last flag cleared was the assert flag.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2016-10-14 11:22:12 -04:00
parent 0da1854cee
commit 1be8f9d323

View File

@ -143,27 +143,13 @@ void pim_ifchannel_delete(struct pim_ifchannel *ch)
pim_ifchannel_free(ch); pim_ifchannel_free(ch);
} }
#define IFCHANNEL_NOINFO(ch) \
( \
((ch)->local_ifmembership == PIM_IFMEMBERSHIP_NOINFO) \
&& \
((ch)->ifjoin_state == PIM_IFJOIN_NOINFO) \
&& \
((ch)->ifassert_state == PIM_IFASSERT_NOINFO) \
)
static void delete_on_noinfo(struct pim_ifchannel *ch) static void delete_on_noinfo(struct pim_ifchannel *ch)
{ {
if (IFCHANNEL_NOINFO(ch)) { if (ch->local_ifmembership == PIM_IFMEMBERSHIP_NOINFO &&
ch->ifjoin_state == PIM_IFJOIN_NOINFO)
/* In NOINFO state, timers should have been cleared */
zassert(!ch->t_ifjoin_expiry_timer);
zassert(!ch->t_ifjoin_prune_pending_timer);
zassert(!ch->t_ifassert_timer);
pim_ifchannel_delete(ch); pim_ifchannel_delete(ch);
}
} }
void pim_ifchannel_ifjoin_switch(const char *caller, void pim_ifchannel_ifjoin_switch(const char *caller,
@ -191,11 +177,8 @@ void pim_ifchannel_ifjoin_switch(const char *caller,
ch->ifjoin_state = new_state; ch->ifjoin_state = new_state;
/* Transition to/from NOINFO ? */ /* Transition to/from NOINFO ? */
if ( if ((old_state == PIM_IFJOIN_NOINFO) ||
(old_state == PIM_IFJOIN_NOINFO) (new_state == PIM_IFJOIN_NOINFO)) {
||
(new_state == PIM_IFJOIN_NOINFO)
) {
if (PIM_DEBUG_PIM_EVENTS) { if (PIM_DEBUG_PIM_EVENTS) {
zlog_debug("PIM_IFCHANNEL_%s: (S,G)=%s on interface %s", zlog_debug("PIM_IFCHANNEL_%s: (S,G)=%s on interface %s",
@ -432,8 +415,6 @@ pim_ifchannel_add(struct interface *ifp,
/* Attach to list */ /* Attach to list */
listnode_add_sort(pim_ifp->pim_ifchannel_list, ch); listnode_add_sort(pim_ifp->pim_ifchannel_list, ch);
zassert(IFCHANNEL_NOINFO(ch));
return ch; return ch;
} }
@ -695,8 +676,6 @@ void pim_ifchannel_join_add(struct interface *ifp,
break; break;
} }
zassert(!IFCHANNEL_NOINFO(ch));
if (holdtime != 0xFFFF) { if (holdtime != 0xFFFF) {
THREAD_TIMER_ON(master, ch->t_ifjoin_expiry_timer, THREAD_TIMER_ON(master, ch->t_ifjoin_expiry_timer,
on_ifjoin_expiry_timer, on_ifjoin_expiry_timer,
@ -782,8 +761,6 @@ void pim_ifchannel_local_membership_add(struct interface *ifp,
ifmembership_set(ch, PIM_IFMEMBERSHIP_INCLUDE); ifmembership_set(ch, PIM_IFMEMBERSHIP_INCLUDE);
zassert(!IFCHANNEL_NOINFO(ch));
if (sg->src.s_addr == INADDR_ANY) if (sg->src.s_addr == INADDR_ANY)
{ {
struct pim_upstream *up = pim_upstream_find (sg); struct pim_upstream *up = pim_upstream_find (sg);