linux-cp: Fix looping netlink messages

Signal when consuming a batch of netlink messages, in order to inhibit
lcp_sync from generating new netlink messages. This avoids link up/down
state changess from triggering an infinite loop.
Do this in the regular case of nl_route_process_msgs()
and in the special case of re-synchronizing in lcp_nl_recv_dump_replies().
Type: fix
Change-Id: I419d3f9aa350c119b3778b644c65165cb4cc1bef
Signed-off-by: Pim van Pelt <pim@ipng.nl>
This commit is contained in:
Pim van Pelt
2023-10-06 11:26:33 +02:00
committed by Matthew Smith
parent 2fa69effc8
commit 2c9b128e1b
5 changed files with 45 additions and 6 deletions

View File

@@ -348,6 +348,8 @@ nl_route_process_msgs (void)
nl_msg_info_t *msg_info;
int err, n_msgs = 0;
lcp_set_netlink_processing_active (1);
/* process a batch of messages. break if we hit our limit */
vec_foreach (msg_info, nm->nl_msg_queue)
{
@@ -365,6 +367,8 @@ nl_route_process_msgs (void)
NL_DBG ("Processed %u messages", n_msgs);
lcp_set_netlink_processing_active (0);
return n_msgs;
}
@@ -441,10 +445,15 @@ lcp_nl_recv_dump_replies (nl_sock_type_t sock_type, int msg_limit,
int done = 0;
int n_msgs = 0;
lcp_set_netlink_processing_active (1);
continue_reading:
n_bytes = nl_recv (sk_route, &nla, &buf, /* creds */ NULL);
if (n_bytes <= 0)
return n_bytes;
{
lcp_set_netlink_processing_active (0);
return n_bytes;
}
hdr = (struct nlmsghdr *) buf;
while (nlmsg_ok (hdr, n_bytes))
@@ -521,6 +530,8 @@ continue_reading:
goto continue_reading;
out:
lcp_set_netlink_processing_active (0);
nlmsg_free (msg);
free (buf);