]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-ndisc.c: Move Router Solicitation sending after timer computaion
authorPatrik Flykt <patrik.flykt@linux.intel.com>
Fri, 19 May 2017 13:22:46 +0000 (16:22 +0300)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Tue, 30 May 2017 07:34:15 +0000 (10:34 +0300)
Move ICMPv6 Router Solicitation sending after timer computation so
that timers are already set up when the packet is being sent. This
makes it possible to create a test that inspects Router
Solicitation timer values when the Router Solicitation is sent out
on the network.

src/libsystemd-network/sd-ndisc.c

index 5dfe6ea36f8f4c3c57e2f3b0c82b32b6dcb216e3..4bf558b12bae56896d21ed0918d7fcf070ef857c 100644 (file)
@@ -281,12 +281,6 @@ static int ndisc_timeout(sd_event_source *s, uint64_t usec, void *userdata) {
         assert(nd);
         assert(nd->event);
 
-        r = icmp6_send_router_solicitation(nd->fd, &nd->mac_addr);
-        if (r < 0) {
-                log_ndisc_errno(r, "Error sending Router Solicitation: %m");
-                goto fail;
-        }
-
         assert_se(sd_event_now(nd->event, clock_boottime_or_monotonic(), &time_now) >= 0);
 
         nd->timeout_event_source = sd_event_source_unref(nd->timeout_event_source);
@@ -319,6 +313,12 @@ static int ndisc_timeout(sd_event_source *s, uint64_t usec, void *userdata) {
                 goto fail;
         }
 
+        r = icmp6_send_router_solicitation(nd->fd, &nd->mac_addr);
+        if (r < 0) {
+                log_ndisc_errno(r, "Error sending Router Solicitation: %m");
+                goto fail;
+        }
+
         log_ndisc("Sent Router Solicitation, next solicitation in %s",
                   format_timespan(time_string, FORMAT_TIMESPAN_MAX,
                                   nd->retransmit_time, USEC_PER_SEC));