Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rtnl: improve event reception in order to avoid ENOBUFS #185

Merged
merged 3 commits into from
Jan 11, 2024

Conversation

jow-
Copy link
Owner

@jow- jow- commented Jan 10, 2024

  • rtnl: increase event socket rx buffer size limit to 1 MiB
  • rtnl: optimize reception of rtnl events
  • rtnl: store callback in listener registry only on success

Fixes: #184

Only store the callback reference in the registry once the listener
context was successfully initialized, to avoid keeping a lingering
entry when invalid parameters are passed.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Once we're notified about pending data on the netlink event socket,
try to receive as much messages as possible in order to empty the socket
buffer. In contrast to the previous implementation which received one
message per epoll read notification, this avoids some premature ENOBUFS
situations when a huge burst of messages arrives, e.g. due to kernel
side GC runs on the neighbor table.

Since libnl's nl_recvmsgs*() functions do not expose the underlying
-1 error returned by the recvmsg() calls, we need to indirectly check
for errors through errno variable, so clear it out both before the
recvmsgs() call and after successfully completing a message reception
callback invocation.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Use the same RX buffer size which iproute2 uses as default, in order to
avoid (or rather, delay as much as possible) ENOBUFS conditions when
receiving a large burst of netlink notifications.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
@f00b4r0
Copy link
Contributor

f00b4r0 commented Jan 11, 2024

AFAICT it does fix the breakage seen in #184
Thanks!

@jow- jow- merged commit dce19b7 into master Jan 11, 2024
7 checks passed
@jow- jow- deleted the rtnl-enobufs-handling branch January 11, 2024 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rtnl.listener dies on message burst
2 participants