get_netlink_msg: unable to receive kernel netlink message:
PATCH 1/1 get_netlink_msg: unable to receive kernel netlink message:
Hi there!
Had this Bug-report floating around since some time:
http://bugs.gentoo.org/show_bug.cgi?id=151414
It occurs, when root-partition has no /dev/console, meaning that kernel could not open it, and such udevd is started without open filedescriptors 0 1 2.
In that case udevd openes its sockets (netlink and control). They get fds between 0 and 2.
Later duping /dev/null to 0 1 2 closes the sockets and replaces them with /dev/null.
Communicating over socket in main-look then gets that error-messages.
One possible solution is:
Checking at startup of udevd that fd 0 1 2 are open, and if not, connect them to /dev/null.
A. For example by explictely checking each fd and dup /dev/null (attached patch).
B. By opening /dev/null until open returns 2 meaning fds 0 1 2 are open. C. Remembering which fd is open, and later only dup/close the ones that were open.
But in case C one perhaps has to conditionalize each printf(...) and fprintf(2,...) as the sockets are sure not happy about text-messages.
For gentoo-startup, that does work without /dev/console, only udevd has problems there, we solved it for now this way in udev-startup script (until udevd copes with this itself):
# check if /dev/console exists outside tmpfs
[[ -c /dev/console ]] ; local need_redirect=$?
....
mount /dev
....
mknod /dev/null
mknod /dev/console
...
if [[ ${need_redirect} == 1 ]]; then
/sbin/udevd --daemon </dev/console >/dev/console 2>/dev/console
else
/sbin/udevd --daemon
fiMatthias
Signature · 1 line
Matthias Schwarzott (zzam)
udevd.c +15 -0
@@ -948,6 +948,21 @@int rc =1 ;int maxfd; + fd =open ("/dev/null" ,O_RDWR ); + +if (fd <0 ) { +fprintf (stderr,"cannot open /dev/null\n" ); +err ("cannot open /dev/null" ); + } +if (read (STDIN_FILENO ,0 ,0 ) <0 ) +dup2 (fd,STDIN_FILENO ); +if (write (STDOUT_FILENO ,0 ,0 ) <0 ) +dup2 (fd,STDOUT_FILENO ); +if (write (STDERR_FILENO ,0 ,0 ) <0 ) +dup2 (fd,STDERR_FILENO ); +if (fd >2 ) +close (fd); +logging_init ("udevd" );udev_config_init ();selinux_init ();
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Re: [PATCH] get_netlink_msg: unable to receive kernel netlink
Quoted 9 lines · Matthias Schwarzott
Hi there!
Had this Bug-report floating around since some time:
http://bugs.gentoo.org/show_bug.cgi?id1414It occurs, when root-partition has no
/dev/console, meaning that kernel could not open it, and such udevd is started without open filedescriptors 0 1 2.
The error condition can also be reproduced by starting udevd with this command-line:
killall udevd
udevd --daemon <&- >&- 2>&-
This will fill syslog with the message from subject.
Matthias
Signature · 11 lines
Matthias Schwarzott (zzam) ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CIDÞVDEV _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net [email protected] https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Re: [PATCH] get_netlink_msg: unable to receive kernel netlink
In reply to Matthias SchwarzottQuoted 8 lines · Matthias Schwarzott
Quoted 7 lines
Had this Bug-report floating around since some time:
http://bugs.gentoo.org/show_bug.cgi?id1414It occurs, when root-partition has no
/dev/console, meaning that kernel could not open it, and such udevd is started without open filedescriptors 0 1 2.
Quoted 8 lines
The error condition can also be reproduced by starting udevd with this command-line:
killall udevd
udevd --daemon <&- >&- 2>&-This will fill syslog with the message from subject.
This is just to bring this issue back to mind.
Does nobody cosider this bug worth fixing it, as I consider it ugly to have to explicitly redirect stdin, stdout and stderr just for executing a daemon that already has the goal to close these fds.
Greetings
Matthias
Signature · 11 lines
Matthias Schwarzott (zzam) ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CIDÞVDEV _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net [email protected] https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Re: [PATCH] get_netlink_msg: unable to receive kernel netlink
In reply to Matthias SchwarzottQuoted 16 lines · Matthias Schwarzott
Quoted 15 lines · Matthias Schwarzott
Quoted 7 lines
Had this Bug-report floating around since some time:
http://bugs.gentoo.org/show_bug.cgi?id1414It occurs, when root-partition has no
/dev/console, meaning that kernel could not open it, and such udevd is started without open filedescriptors 0 1 2.The error condition can also be reproduced by starting udevd with this command-line:
killall udevd
udevd --daemon <&- >&- 2>&-
Quoted 7 lines
Quoted 1 line
This will fill syslog with the message from subject.
This is just to bring this issue back to mind.
Does nobody cosider this bug worth fixing it, as I consider it ugly to have to explicitly redirect stdin, stdout and stderr just for executing a daemon that already has the goal to close these fds.
Aren't you expected to connect the init script to the (dead) console anyway?
exec 0<> $CONSOLE 1>&0 2>&0
Kay
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CIDÞVDEV
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Re: [PATCH] get_netlink_msg: unable to receive kernel netlink
In reply to Matthias SchwarzottQuoted 8 lines · Kay Sievers
Quoted 4 lines · Matthias Schwarzott
Does nobody cosider this bug worth fixing it, as I consider it ugly to have to explicitly redirect stdin, stdout and stderr just for executing a daemon that already has the goal to close these fds.
Aren't you expected to connect the init script to the (dead) console anyway? exec 0<> $CONSOLE 1>&0 2>&0
Normally the kernel connects /dev/console and the init-process. But only if /dev/console (or $CONSOLE) exists on the root-partition. If it does not fds 0, 1 and 2 are closed.
In that case I have to add
# exec 0<> $CONSOLE 1>&0 2>& to every init-script? And for that even create $CONSOLE before executing udev, as that does not exist in empty tmpfs.
For all other init-scripts/daemons it works without, but not for udev. If this bug is solved we still can boot from a partition with completely destroyed/cleaned /dev, without crashing bootup at udevd startup.
Matthias
Signature · 11 lines
Matthias Schwarzott (zzam) ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CIDÞVDEV _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net [email protected] https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Re: [PATCH] get_netlink_msg: unable to receive kernel netlink
In reply to Matthias SchwarzottQuoted 10 lines · Matthias Schwarzott
Quoted 8 lines · Kay Sievers
Quoted 4 lines · Matthias Schwarzott
Does nobody cosider this bug worth fixing it, as I consider it ugly to have to explicitly redirect stdin, stdout and stderr just for executing a daemon that already has the goal to close these fds.
Aren't you expected to connect the init script to the (dead) console anyway? exec 0<> $CONSOLE 1>&0 2>&0
Quoted 6 lines
Normally the kernel connects
/dev/consoleand the init-process. But only if/dev/console(or $CONSOLE) exists on the root-partition. If it does not fds 0, 1 and 2 are closed.
In that case I have to add# exec 0<> $CONSOLE 1>&0 2>& to every init-script?
Usually only in the single-user script forked by init. But sure, you would need the device-node, to do that.
Quoted 2 lines
And for that even create $CONSOLE before executing udev, as that does not exist in empty tmpfs.
Yes, but you are expected to have created /dev/null and some other stuff too, in the empty tmpfs, before you start udevd.
If you don't do the 'exec', in case of a missing /dev/console, your terminal is not connected to the init script, which maybe nice to do for various other reasons.
Quoted 3 lines
For all other init-scripts/daemons it works without, but not for udev. If this bug is solved we still can boot from a partition with completely destroyed/cleaned /dev, without crashing bootup at udevd startup.
Fine. Does the attached work for you?
Thanks,
Kay
udevd.c +19 -11
@@ -989,6 +989,19 @@ int main(int argc, char *argv[], char *e goto exit; } +/* make sure std{in,out,err} fd's are in a sane state */ + fd =open ("/dev/null" ,O_RDWR ); +if (fd <0 ) { +fprintf (stderr,"cannot open /dev/null\n" ); +err ("cannot open /dev/null" ); + } +if (fd >STDIN_FILENO ) +dup2 (fd,STDIN_FILENO ); +if (write (STDOUT_FILENO ,0 ,0 ) <0 ) +dup2 (fd,STDOUT_FILENO ); +if (write (STDERR_FILENO ,0 ,0 ) <0 ) +dup2 (fd,STDERR_FILENO ); +/* init sockets to receive events */ if (init_udevd_socket () <0 ) {if (errno ==EADDRINUSE ) {
@@ -1064,17 +1077,12 @@ int main(int argc, char *argv[], char *e } } -/* redirect std fd's */ - fd =open ("/dev/null" ,O_RDWR ); -if (fd >=0 ) { -dup2 (fd,STDIN_FILENO ); -if (!verbose) -dup2 (fd,STDOUT_FILENO ); -dup2 (fd,STDERR_FILENO ); -if (fd >STDERR_FILENO ) -close (fd); - }else -err ("error opening /dev/null: %s" ,strerror (errno)); +/* redirect std{out,err} fd's */ +if (!verbose) +dup2 (fd,STDOUT_FILENO ); +dup2 (fd,STDERR_FILENO ); +if (fd >STDERR_FILENO ) +close (fd);/* set scheduling priority for the daemon */ setpriority (PRIO_PROCESS ,0 ,UDEVD_PRIORITY );
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel