Skip to content

rtnl: reset and close request socket on error and export rtnl.close() - #474

Open
ptpt52 wants to merge 1 commit into
ucode-lang:masterfrom
x-wrt:fix-issue-422
Open

ptpt52 wants to merge 1 commit into
ucode-lang:masterfrom
x-wrt:fix-issue-422

Conversation

@ptpt52

@ptpt52 ptpt52 commented Oct 8, 2026

Copy link
Copy Markdown

The rtnl module caches an internal netlink socket across uc_nl_request() calls. However, if a request fails or is interrupted (for example, during a multi-part link/address dump query that triggers -EBUSY or sequence number mismatch), unread packets can remain in the socket's receive buffer and kernel dump state remains attached to the socket.

Because the socket was never closed or reset upon error, subsequent requests on the same socket read leftover responses from the previous transaction, leading to persistent NLE_SEQ_MISMATCH failures.

Fix this by:

  1. Closing and resetting the cached socket whenever connect, setsockopt, send, or receive fails (including STATE_ERROR and interrupted reply states), avoiding caching a broken or half-open socket.
  2. Exporting an explicit rtnl.close() function to allow callers to close and reset the cached request socket at will.

Fixes: #422

The rtnl module caches an internal netlink socket across uc_nl_request()
calls. However, if a request fails or is interrupted (for example, during
a multi-part link/address dump query that triggers -EBUSY or sequence
number mismatch), unread packets can remain in the socket's receive
buffer and kernel dump state remains attached to the socket.

Because the socket was never closed or reset upon error, subsequent
requests on the same socket read leftover responses from the previous
transaction, leading to persistent NLE_SEQ_MISMATCH failures.

Fix this by:
1. Closing and resetting the cached socket whenever connect, setsockopt,
   send, or receive fails (including STATE_ERROR and interrupted reply
   states), avoiding caching a broken or half-open socket.
2. Exporting an explicit rtnl.close() function to allow callers to close
   and reset the cached request socket at will.

Fixes: ucode-lang#422
Signed-off-by: Chen Minqiang <ptpt52@gmail.com>

This branch has not been deployed

No deployments
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.

lib_rtnl.c: uc_nl_request - if the socket assigned to 'sock' fails in some way there is no way to close and reopen it

1 participant