Handle the case where the rfkill is set when ndhc is initializing.
This commit is contained in:
parent
5b050ba498
commit
79a97131bc
22
src/ifset.c
22
src/ifset.c
@ -128,12 +128,17 @@ static ssize_t rtnl_do_send(int fd, const uint8_t *sbuf, size_t slen,
|
|||||||
}
|
}
|
||||||
const struct nlmsghdr *nlh = (const struct nlmsghdr *)response;
|
const struct nlmsghdr *nlh = (const struct nlmsghdr *)response;
|
||||||
if (nlh->nlmsg_type == NLMSG_ERROR) {
|
if (nlh->nlmsg_type == NLMSG_ERROR) {
|
||||||
if (nlmsg_get_error(nlh) == 0)
|
int nlerr = nlmsg_get_error(nlh);
|
||||||
|
if (nlerr == 0)
|
||||||
return 0;
|
return 0;
|
||||||
else {
|
else {
|
||||||
|
if (nlerr == 132) {
|
||||||
|
log_line("%s: (%s) RF-kill is set (%d). Cannot change interface.",
|
||||||
|
client_config.interface, fnname, nlerr);
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
log_error("%s: (%s) netlink sendto returned NLMSG_ERROR: %s",
|
log_error("%s: (%s) netlink sendto returned NLMSG_ERROR: %s",
|
||||||
client_config.interface, fnname,
|
client_config.interface, fnname, strerror(nlerr));
|
||||||
strerror(nlmsg_get_error(nlh)));
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -475,9 +480,14 @@ int perform_ifup(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int r = link_set_flags(fd, IFF_UP);
|
int r = link_set_flags(fd, IFF_UP);
|
||||||
if (r < 0)
|
if (r < 0) {
|
||||||
log_error("%s: (%s) Failed to set link to be up.",
|
if (r != -3)
|
||||||
client_config.interface, __func__);
|
log_error("%s: (%s) Failed to set link to be up.",
|
||||||
|
client_config.interface, __func__);
|
||||||
|
else
|
||||||
|
log_line("%s: (%s) rfkill is set; waiting until it is unset",
|
||||||
|
client_config.interface, __func__);
|
||||||
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -493,6 +493,7 @@ int main(int argc, char *argv[])
|
|||||||
switch (perform_ifup()) {
|
switch (perform_ifup()) {
|
||||||
case 1: cs.ifsPrevState = IFS_UP;
|
case 1: cs.ifsPrevState = IFS_UP;
|
||||||
case 0: break;
|
case 0: break;
|
||||||
|
case -3: cs.rfkill_set = 1; cs.ifsPrevState = IFS_DOWN; break;
|
||||||
default: suicide("failed to set the interface to up state");
|
default: suicide("failed to set the interface to up state");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user