summaryrefslogtreecommitdiff
path: root/src/libsystemd-network
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-10-22 17:46:35 +0200
committerTom Gundersen <teg@jklm.no>2015-11-11 15:42:38 +0100
commitcb53894d3b6e90edaee4219fe716850d01242f46 (patch)
treeb3b8f88db29f2836235b465349098673e342bed4 /src/libsystemd-network
parentb69015efd2752fd2719beec85496221304130b0b (diff)
sd-ndisc: notify user on STOP
Also, stop the state machine when we get into a broken state, rather than just notify the user.
Diffstat (limited to 'src/libsystemd-network')
-rw-r--r--src/libsystemd-network/sd-ndisc.c9
-rw-r--r--src/libsystemd-network/test-ndisc-rs.c6
2 files changed, 10 insertions, 5 deletions
diff --git a/src/libsystemd-network/sd-ndisc.c b/src/libsystemd-network/sd-ndisc.c
index c494b9d6d8..b8bfc6c549 100644
--- a/src/libsystemd-network/sd-ndisc.c
+++ b/src/libsystemd-network/sd-ndisc.c
@@ -494,8 +494,8 @@ static int ndisc_router_advertisment_recv(sd_event_source *s, int fd, uint32_t r
event = SD_NDISC_EVENT_ROUTER_ADVERTISMENT_MANAGED;
log_ndisc(nd, "Received Router Advertisement flags %s/%s",
- ra->nd_ra_flags_reserved & ND_RA_FLAG_MANAGED? "MANAGED": "none",
- ra->nd_ra_flags_reserved & ND_RA_FLAG_OTHER? "OTHER": "none");
+ ra->nd_ra_flags_reserved & ND_RA_FLAG_MANAGED ? "MANAGED" : "none",
+ ra->nd_ra_flags_reserved & ND_RA_FLAG_OTHER ? "OTHER" : "none");
if (event != SD_NDISC_EVENT_ROUTER_ADVERTISMENT_NONE) {
r = ndisc_ra_parse(nd, ra, len);
@@ -549,7 +549,8 @@ static int ndisc_router_solicitation_timeout(sd_event_source *s, uint64_t usec,
next_timeout, 0,
ndisc_router_solicitation_timeout, nd);
if (r < 0) {
- ndisc_notify(nd, r);
+ /* we cannot continue if we are unable to rearm the timer */
+ sd_ndisc_stop(nd);
return 0;
}
@@ -575,6 +576,8 @@ int sd_ndisc_stop(sd_ndisc *nd) {
nd->state = NDISC_STATE_IDLE;
+ ndisc_notify(nd, SD_NDISC_EVENT_STOP);
+
return 0;
}
diff --git a/src/libsystemd-network/test-ndisc-rs.c b/src/libsystemd-network/test-ndisc-rs.c
index 44eab94e8b..59c720d48d 100644
--- a/src/libsystemd-network/test-ndisc-rs.c
+++ b/src/libsystemd-network/test-ndisc-rs.c
@@ -87,11 +87,13 @@ int icmp6_send_router_solicitation(int s, const struct ether_addr *ether_addr) {
static void test_rs_done(sd_ndisc *nd, int event, void *userdata) {
sd_event *e = userdata;
- static int idx = 0;
+ static unsigned idx = 0;
struct {
uint8_t flag;
int event;
} flag_event[] = {
+ { 0, SD_NDISC_EVENT_STOP },
+ { 0, SD_NDISC_EVENT_STOP },
{ 0, SD_NDISC_EVENT_ROUTER_ADVERTISMENT_NONE },
{ ND_RA_FLAG_OTHER, SD_NDISC_EVENT_ROUTER_ADVERTISMENT_OTHER },
{ ND_RA_FLAG_MANAGED, SD_NDISC_EVENT_ROUTER_ADVERTISMENT_MANAGED }
@@ -106,7 +108,7 @@ static void test_rs_done(sd_ndisc *nd, int event, void *userdata) {
if (verbose)
printf(" got event %d\n", event);
- if (idx < 3) {
+ if (idx < ELEMENTSOF(flag_event)) {
send_ra(flag_event[idx].flag);
return;
}