From 2c530fd99bba0721d86a644214e255e98d6a3d9d Mon Sep 17 00:00:00 2001 From: Alan Maguire Date: Mon, 25 Nov 2024 20:35:21 +0000 Subject: [PATCH] libbpftune: only send events to active tuners Roger reported a segmentation fault in tcp_buffer_tuner. Examining the state of the tuner we were handling an event when in manual (i.e. off) state. The event handler for a tuner should only be called if the tuner is active. Reported by: Roger Knobbe (https://github.com/rknobbe) Signed-off-by: Alan Maguire --- src/libbpftune.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libbpftune.c b/src/libbpftune.c index 4a801de..f75981b 100644 --- a/src/libbpftune.c +++ b/src/libbpftune.c @@ -783,7 +783,9 @@ static int bpftune_ringbuf_event_read(void *ctx, void *data, size_t size) event->netns_cookie, event->netns_cookie && event->netns_cookie != global_netns_cookie ? "non-global netns" : "global netns"); - tuner->event_handler(tuner, event, ctx); + /* only send events to active tuners */ + if (tuner->state == BPFTUNE_ACTIVE) + tuner->event_handler(tuner, event, ctx); return 0; }