Don't rearm rs timer if callback is not set
[project/odhcpd.git] / src / router.c
index 7b81f71..dfbcf60 100644 (file)
@@ -345,11 +345,6 @@ static void send_router_advert(struct uloop_timeout *event)
                adv.h.nd_ra_router_lifetime = 0;
        }
 
                adv.h.nd_ra_router_lifetime = 0;
        }
 
-       if (have_public && iface->deprecate_ula_if_public_avail)
-               for (size_t i = 0; i < cnt; ++i)
-                       if ((adv.prefix[i].nd_opt_pi_prefix.s6_addr[0] & 0xfe) == 0xfc)
-                               adv.prefix[i].nd_opt_pi_preferred_time = 0;
-
        // DNS Recursive DNS
        if (iface->dns_cnt > 0) {
                dns_addr = iface->dns;
        // DNS Recursive DNS
        if (iface->dns_cnt > 0) {
                dns_addr = iface->dns;
@@ -456,12 +451,14 @@ static void send_router_advert(struct uloop_timeout *event)
        odhcpd_send(router_event.uloop.fd,
                        &all_nodes, iov, ARRAY_SIZE(iov), iface);
 
        odhcpd_send(router_event.uloop.fd,
                        &all_nodes, iov, ARRAY_SIZE(iov), iface);
 
-       // Rearm timer
-       int msecs;
-       odhcpd_urandom(&msecs, sizeof(msecs));
-       msecs = (labs(msecs) % (1000 * (MaxRtrAdvInterval
-                       - MinRtrAdvInterval))) + (MinRtrAdvInterval * 1000);
-       uloop_timeout_set(&iface->timer_rs, msecs);
+       // Rearm timer if not shut down
+       if (event->cb) {
+               int msecs;
+               odhcpd_urandom(&msecs, sizeof(msecs));
+               msecs = (labs(msecs) % (1000 * (MaxRtrAdvInterval
+                               - MinRtrAdvInterval))) + (MinRtrAdvInterval * 1000);
+               uloop_timeout_set(&iface->timer_rs, msecs);
+       }
 }
 
 
 }