aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/linux-cp
diff options
context:
space:
mode:
authorArtem Glazychev <glazychev@mts.ru>2024-12-18 15:50:13 +0700
committerMatthew Smith <mgsmith@netgate.com>2025-01-16 15:32:54 +0000
commit8d6b2f6d7a8cd78ae42262c4de112f8301e80e18 (patch)
tree4e00a4262bf047db40b93ffc5aeb51e637e099b2 /src/plugins/linux-cp
parent4e003776cb9a7f7989ae4c49baec12d74ad16fa7 (diff)
linux-cp: fix segfault while receiving nl messages
- 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 <glazychev@mts.ru>
Diffstat (limited to 'src/plugins/linux-cp')
-rw-r--r--src/plugins/linux-cp/lcp_nl.c13
1 files changed, 2 insertions, 11 deletions
diff --git a/src/plugins/linux-cp/lcp_nl.c b/src/plugins/linux-cp/lcp_nl.c
index 85b6447007a..71104d39134 100644
--- a/src/plugins/linux-cp/lcp_nl.c
+++ b/src/plugins/linux-cp/lcp_nl.c
@@ -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 */
@@ -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)
{
@@ -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);
}