mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-02-01 05:47:04 +03:00
sd-ndisc: notify user on STOP
Also, stop the state machine when we get into a broken state, rather than just notify the user.
This commit is contained in:
parent
b69015efd2
commit
cb53894d3b
@ -549,7 +549,8 @@ static int ndisc_router_solicitation_timeout(sd_event_source *s, uint64_t usec,
|
|||||||
next_timeout, 0,
|
next_timeout, 0,
|
||||||
ndisc_router_solicitation_timeout, nd);
|
ndisc_router_solicitation_timeout, nd);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
ndisc_notify(nd, r);
|
/* we cannot continue if we are unable to rearm the timer */
|
||||||
|
sd_ndisc_stop(nd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -575,6 +576,8 @@ int sd_ndisc_stop(sd_ndisc *nd) {
|
|||||||
|
|
||||||
nd->state = NDISC_STATE_IDLE;
|
nd->state = NDISC_STATE_IDLE;
|
||||||
|
|
||||||
|
ndisc_notify(nd, SD_NDISC_EVENT_STOP);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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) {
|
static void test_rs_done(sd_ndisc *nd, int event, void *userdata) {
|
||||||
sd_event *e = userdata;
|
sd_event *e = userdata;
|
||||||
static int idx = 0;
|
static unsigned idx = 0;
|
||||||
struct {
|
struct {
|
||||||
uint8_t flag;
|
uint8_t flag;
|
||||||
int event;
|
int event;
|
||||||
} flag_event[] = {
|
} flag_event[] = {
|
||||||
|
{ 0, SD_NDISC_EVENT_STOP },
|
||||||
|
{ 0, SD_NDISC_EVENT_STOP },
|
||||||
{ 0, SD_NDISC_EVENT_ROUTER_ADVERTISMENT_NONE },
|
{ 0, SD_NDISC_EVENT_ROUTER_ADVERTISMENT_NONE },
|
||||||
{ ND_RA_FLAG_OTHER, SD_NDISC_EVENT_ROUTER_ADVERTISMENT_OTHER },
|
{ ND_RA_FLAG_OTHER, SD_NDISC_EVENT_ROUTER_ADVERTISMENT_OTHER },
|
||||||
{ ND_RA_FLAG_MANAGED, SD_NDISC_EVENT_ROUTER_ADVERTISMENT_MANAGED }
|
{ 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)
|
if (verbose)
|
||||||
printf(" got event %d\n", event);
|
printf(" got event %d\n", event);
|
||||||
|
|
||||||
if (idx < 3) {
|
if (idx < ELEMENTSOF(flag_event)) {
|
||||||
send_ra(flag_event[idx].flag);
|
send_ra(flag_event[idx].flag);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@ static void ndisc_router_handler(sd_ndisc *nd, int event, void *userdata) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
switch(event) {
|
switch(event) {
|
||||||
|
case SD_NDISC_EVENT_STOP:
|
||||||
case SD_NDISC_EVENT_ROUTER_ADVERTISMENT_NONE:
|
case SD_NDISC_EVENT_ROUTER_ADVERTISMENT_NONE:
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -51,9 +52,6 @@ static void ndisc_router_handler(sd_ndisc *nd, int event, void *userdata) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (event < 0)
|
|
||||||
log_link_warning_errno(link, event, "IPv6 Neighbor Discover error: %m");
|
|
||||||
else
|
|
||||||
log_link_warning(link, "IPv6 Neighbor Discovery unknown event: %d", event);
|
log_link_warning(link, "IPv6 Neighbor Discovery unknown event: %d", event);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -35,6 +35,7 @@ enum {
|
|||||||
SD_NDISC_EVENT_ROUTER_ADVERTISMENT_TIMEOUT = 1,
|
SD_NDISC_EVENT_ROUTER_ADVERTISMENT_TIMEOUT = 1,
|
||||||
SD_NDISC_EVENT_ROUTER_ADVERTISMENT_OTHER = 2,
|
SD_NDISC_EVENT_ROUTER_ADVERTISMENT_OTHER = 2,
|
||||||
SD_NDISC_EVENT_ROUTER_ADVERTISMENT_MANAGED = 3,
|
SD_NDISC_EVENT_ROUTER_ADVERTISMENT_MANAGED = 3,
|
||||||
|
SD_NDISC_EVENT_STOP = 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct sd_ndisc sd_ndisc;
|
typedef struct sd_ndisc sd_ndisc;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user