mdev: re-initialize if uevent messages were lost

If the netlink read() failed with ENOBUFS we know that we have missed at
least one message due to a socket receive buffer overrun. The only way
how to recover is to drop the old socket, open a fresh one and make a
cold-plug scan of the current system state.

Signed-off-by: Jan Klötzke <jan@kloetzke.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Jan Klötzke 2019-12-16 22:56:52 +01:00 committed by Denys Vlasenko
parent e3f4759019
commit d560030548

View File

@ -1199,6 +1199,16 @@ static void daemon_loop(char *temp, int fd)
len = safe_read(fd, netbuf, sizeof(netbuf) - 1);
if (len < 0) {
if (errno == ENOBUFS) {
/*
* We ran out of socket receive buffer space.
* Start from scratch.
*/
dbg1s("uevent overrun, rescanning");
close(fd);
fd = daemon_init(temp);
continue;
}
bb_simple_perror_msg_and_die("read");
}
end = netbuf + len;