From: Rafael Zalamena Date: Wed, 23 Jan 2019 12:25:30 +0000 (-0200) Subject: ospf6d: keep track of the socket set thread X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=c9a8a856a71907c772790fcb4dc91d40dbcf72bb;p=matthieu%2Ffrr.git ospf6d: keep track of the socket set thread When using the timer to set the socket multicast options, keep track of the thread pointer. If we lose the thread reference we might have situations where multicast is enabled when it should be disabled and vice versa. Signed-off-by: Rafael Zalamena (cherry picked from commit f80003b0e12a090b34e2ab9547ed072ff02c33ba) --- diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c index 4916fd2e84..9aafb6d813 100644 --- a/ospf6d/ospf6_interface.c +++ b/ospf6d/ospf6_interface.c @@ -246,6 +246,7 @@ void ospf6_interface_delete(struct ospf6_interface *oi) THREAD_OFF(oi->thread_send_hello); THREAD_OFF(oi->thread_send_lsupdate); THREAD_OFF(oi->thread_send_lsack); + THREAD_OFF(oi->thread_sso); ospf6_lsdb_remove_all(oi->lsdb); ospf6_lsdb_remove_all(oi->lsupdate_list); @@ -291,6 +292,7 @@ void ospf6_interface_disable(struct ospf6_interface *oi) THREAD_OFF(oi->thread_send_hello); THREAD_OFF(oi->thread_send_lsupdate); THREAD_OFF(oi->thread_send_lsack); + THREAD_OFF(oi->thread_sso); THREAD_OFF(oi->thread_network_lsa); THREAD_OFF(oi->thread_link_lsa); @@ -679,6 +681,12 @@ int interface_up(struct thread *thread) oi = (struct ospf6_interface *)THREAD_ARG(thread); assert(oi && oi->interface); + /* + * Remove old pointer. If this thread wasn't a timer this + * operation won't make a difference, because it is already NULL. + */ + oi->thread_sso = NULL; + if (IS_OSPF6_DEBUG_INTERFACE) zlog_debug("Interface Event %s: [InterfaceUp]", oi->interface->name); @@ -729,7 +737,8 @@ int interface_up(struct thread *thread) "Scheduling %s for sso retry, trial count: %d", oi->interface->name, oi->sso_try_cnt); thread_add_timer(master, interface_up, oi, - OSPF6_INTERFACE_SSO_RETRY_INT, NULL); + OSPF6_INTERFACE_SSO_RETRY_INT, + &oi->thread_sso); } return 0; } @@ -830,6 +839,9 @@ int interface_down(struct thread *thread) /* Stop Hellos */ THREAD_OFF(oi->thread_send_hello); + /* Stop trying to set socket options. */ + THREAD_OFF(oi->thread_sso); + /* Leave AllSPFRouters */ if (oi->state > OSPF6_INTERFACE_DOWN) ospf6_sso(oi->interface->ifindex, &allspfrouters6, @@ -1602,6 +1614,7 @@ DEFUN (ipv6_ospf6_passive, SET_FLAG(oi->flag, OSPF6_INTERFACE_PASSIVE); THREAD_OFF(oi->thread_send_hello); + THREAD_OFF(oi->thread_sso); for (ALL_LIST_ELEMENTS(oi->neighbor_list, node, nnode, on)) { THREAD_OFF(on->inactivity_timer); @@ -1631,7 +1644,7 @@ DEFUN (no_ipv6_ospf6_passive, UNSET_FLAG(oi->flag, OSPF6_INTERFACE_PASSIVE); THREAD_OFF(oi->thread_send_hello); - oi->thread_send_hello = NULL; + THREAD_OFF(oi->thread_sso); thread_add_event(master, ospf6_hello_send, oi, 0, &oi->thread_send_hello); diff --git a/ospf6d/ospf6_interface.h b/ospf6d/ospf6_interface.h index 8fd43f099a..e0c39a29b4 100644 --- a/ospf6d/ospf6_interface.h +++ b/ospf6d/ospf6_interface.h @@ -80,6 +80,7 @@ struct ospf6_interface { /* Interface socket setting trial counter, resets on success */ uint8_t sso_try_cnt; + struct thread *thread_sso; /* OSPF6 Interface flag */ char flag;