mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] netlink.c: missing handling of EAGAIN and EWOULDBLOCK
@ 2022-06-13 15:41 Waldek Kozaczuk
  2022-06-13 17:08 ` Rich Felker
  0 siblings, 1 reply; 4+ messages in thread
From: Waldek Kozaczuk @ 2022-06-13 15:41 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 920 bytes --]

Hi,

Very recently we implemented minimal rnetlink support on OSv side which
allowed us to finally switch to the netlink-based implementation of
getifaddrs() and if_nameindex().

However, I noticed that the function __netlink_enumerate() in
https://github.com/ifduyue/musl/blob/master/src/network/netlink.c uses
MSG_DONTWAIT flag when calling recv() which may fail with EAGAIN or
EWOULDBLOCK and there is no error/retry handling for that. I actually saw
both functions fail occasionally on OSv.

One way to fix is to add missing error handling. But another simpler
solution is to stop using MSG_DONTWAIT altogether and force recv() to
block. In other words, the line:

r = recv(fd, u.buf, sizeof(u.buf), MSG_DONTWAIT);

should change to:

r = recv(fd, u.buf, sizeof(u.buf), 0);

For time being we are applying a header trick on OSv side to re-define
MSG_DONTWAIT as 0 when compiling those specific musl sources.

Waldek

[-- Attachment #2: Type: text/html, Size: 5034 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-06-14  5:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-13 15:41 [musl] netlink.c: missing handling of EAGAIN and EWOULDBLOCK Waldek Kozaczuk
2022-06-13 17:08 ` Rich Felker
2022-06-13 18:38   ` Waldek Kozaczuk
2022-06-14  5:19   ` Timo Teras

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).