]> git.puffer.fish Git - matthieu/frr.git/commitdiff
ospf6d: keep track of the socket set thread
authorRafael Zalamena <rzalamena@opensourcerouting.org>
Wed, 23 Jan 2019 12:25:30 +0000 (10:25 -0200)
committerMartin Winter <mwinter@opensourcerouting.org>
Sun, 2 Jun 2019 14:49:44 +0000 (16:49 +0200)
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 <rzalamena@opensourcerouting.org>
(cherry picked from commit f80003b0e12a090b34e2ab9547ed072ff02c33ba)

ospf6d/ospf6_interface.c
ospf6d/ospf6_interface.h

index 4916fd2e846c3af9a528d1b27320ca6d6ad97cd5..9aafb6d813f2ccce74a61e910195732658a59d9a 100644 (file)
@@ -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);
 
index 8fd43f099a03c0b3bca4c549e4d3afdc543afc88..e0c39a29b40a83e9bb8c0be28bb4e71a3d828f70 100644 (file)
@@ -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;