summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-05-24 21:32:33 +0200
committerLennart Poettering <lennart@poettering.net>2016-05-26 15:34:43 +0200
commitb9e7b1cf06cdfb95397b11c60211f5bbe9df28d1 (patch)
treeb7437223e0929272f278c1c24d4a94267fa175f9
parent901c983b6dca860e675fd77f703a44f15d900101 (diff)
sd-ndisc: stop discovery properly when something fails
-rw-r--r--src/libsystemd-network/sd-ndisc.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/libsystemd-network/sd-ndisc.c b/src/libsystemd-network/sd-ndisc.c
index 36c6d444cc..28133e7a69 100644
--- a/src/libsystemd-network/sd-ndisc.c
+++ b/src/libsystemd-network/sd-ndisc.c
@@ -608,9 +608,10 @@ static int ndisc_router_solicitation_timeout(sd_event_source *s, uint64_t usec,
nd->state = NDISC_STATE_ADVERTISEMENT_LISTEN;
} else {
r = icmp6_send_router_solicitation(nd->fd, &nd->mac_addr);
- if (r < 0)
+ if (r < 0) {
log_ndisc_errno(nd, r, "Error sending Router Solicitation: %m");
- else {
+ goto fail;
+ } else {
nd->state = NDISC_STATE_SOLICITATION_SENT;
log_ndisc(nd, "Sent Router Solicitation");
}
@@ -625,19 +626,24 @@ static int ndisc_router_solicitation_timeout(sd_event_source *s, uint64_t usec,
next_timeout, 0,
ndisc_router_solicitation_timeout, nd);
if (r < 0) {
- /* we cannot continue if we are unable to rearm the timer */
- sd_ndisc_stop(nd);
- return 0;
+ log_ndisc_errno(nd, r, "Failed to allocate timer event: %m");
+ goto fail;
}
r = sd_event_source_set_priority(nd->timeout_event_source, nd->event_priority);
- if (r < 0)
- return 0;
+ if (r < 0) {
+ log_ndisc_errno(nd, r, "Cannot set timer priority: %m");
+ goto fail;
+ }
(void) sd_event_source_set_description(nd->timeout_event_source, "ndisc-timeout");
}
return 0;
+
+fail:
+ sd_ndisc_stop(nd);
+ return 0;
}
int sd_ndisc_stop(sd_ndisc *nd) {