Skip to content

Commit

Permalink
linux-cp: fix segfault while receiving nl messages
Browse files Browse the repository at this point in the history
- check nl socket before receiving messages
- we don't need extra callback after adding an lcp pair because we start draining messages (due to epoll) right after opening socket

Type: fix

Change-Id: I0ecb03b758f066662015fd6c6b9d3c48cb520c0d
Signed-off-by: Artem Glazychev <[email protected]>
  • Loading branch information
Artem Glazychev authored and mgsmith1000 committed Jan 16, 2025
1 parent 4e00377 commit 8d6b2f6
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/plugins/linux-cp/lcp_nl.c
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,8 @@ lcp_nl_drain_messages (void)
nl_main_t *nm = &nl_main;

/* Read until there's an error */
while ((err = nl_recvmsgs_default (nm->sk_route)) > -1)
while ((err = nm->sk_route ? nl_recvmsgs_default (nm->sk_route) :
-NLE_BAD_SOCK) > -1)
;

/* If there was an error other then EAGAIN, signal process node */
Expand All @@ -752,12 +753,6 @@ lcp_nl_drain_messages (void)
return err;
}

void
lcp_nl_pair_add_cb (lcp_itf_pair_t *pair)
{
lcp_nl_drain_messages ();
}

static clib_error_t *
nl_route_read_cb (clib_file_t *f)
{
Expand Down Expand Up @@ -1008,16 +1003,12 @@ clib_error_t *
lcp_nl_init (vlib_main_t *vm)
{
nl_main_t *nm = &nl_main;
lcp_itf_pair_vft_t nl_itf_pair_vft = {
.pair_add_fn = lcp_nl_pair_add_cb,
};

nm->nl_status = NL_STATUS_NOTIF_PROC;
nm->clib_file_index = ~0;
nm->nl_logger = vlib_log_register_class ("nl", "nl");

lcp_nl_open_socket ();
lcp_itf_pair_register_vft (&nl_itf_pair_vft);

return (NULL);
}
Expand Down

0 comments on commit 8d6b2f6

Please sign in to comment.