-
Notifications
You must be signed in to change notification settings - Fork 487
UCS/SYS/NETLINK: Iteratively receive netlink messages until 'done' is set #10848
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
Conversation
1a829d3
to
19620b5
Compare
src/ucs/sys/netlink.c
Outdated
|
||
while ((status == UCS_INPROGRESS) && NLMSG_OK(nlh, msg_len) && | ||
(nlh->nlmsg_type != NLMSG_DONE)) { | ||
(!is_dump || !(*is_done_p = UCS_NETLINK_IS_MESSAGE_DONE(nlh)))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we avoid passing int *is_done_p and is_dump to this function, and keep the logic of calling ucs_netlink_parse_msg several times in the upper function, ucs_netlink_send_request?
rtm.rtm_table = RT_TABLE_MAIN; | ||
ucs_netlink_send_request(NETLINK_ROUTE, RTM_GETROUTE, NLM_F_DUMP, &rtm, | ||
sizeof(rtm), ucs_netlink_parse_rt_entry_cb, | ||
NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why removed RT_TABLE_MAIN?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because now we define it as RT_TABLE_UNSPEC
(value 0) in order to fetch all the tables
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe set it explicitly to RT_TABLE_UNSPEC and comment the reason?
src/ucs/sys/netlink.c
Outdated
int netlink_fd = -1; | ||
int is_message_done = 0; | ||
int is_dump = nlmsg_flags & NLM_F_DUMP; | ||
size_t recv_msg_len = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to ini
src/ucs/sys/netlink.c
Outdated
struct rtmsg rtm = {0}; | ||
ucs_netlink_route_info_t info; | ||
|
||
rtm.rtm_table = RT_TABLE_UNSPEC; /* fetch all the tables */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe move it inside UCS_INIT_ONCE block? as it used to be
5add2ce
to
6d96bec
Compare
What?
Iteratively receive netlink messages until 'NLMSG_DONE' flag is set.
Why?
https://redmine.mellanox.com/issues/4607309
In some cases, when many routing rules exist (many interfaces with multiple tables), the kernel may return those rules in chunks rather than in a single response.
When
NLM_F_DUMP
flag is set in the netlink request, it is actually necessary to perform multiplerecv
calls until anNLMSG_DONE
message is received.