From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by passt.top (Postfix, from userid 1000) id 7F7665A0269; Sun, 15 Nov 2026 23:37:28 +0100 (CET) From: Stefano Brivio To: passt-dev@passt.top Subject: [PATCH] flow: Handle NULL (unknown) flows in flow logging functions Date: Sun, 15 Nov 2026 23:37:28 +0100 Message-ID: <20261115223728.1400901-1-sbrivio@redhat.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: LYAHE67VCPVLLB2W6KF7FBNHP4CKHE5P X-Message-ID-Hash: LYAHE67VCPVLLB2W6KF7FBNHP4CKHE5P X-MailFrom: sbrivio@passt.top X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Doug Baggett , David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Starting from commit edeb2a26c663 ("udp: Improve messages for errors getting errors"), we might call flow logging functions with a NULL flow, for example via udp_sock_fwd() -> udp_sock_errs(). As reported by Doug, that will make us dereference a NULL flow in flow_dbg(). This happens occasionally with a specific pattern in outbound UDP traffic, where we contact a large number of endpoints that might be occasionally unreachable. We want to print socket errors even if we couldn't find an associated flow. For simplicity, instead of adding conditionals in all the possible callers, just handle NULL flows in flow logging functions, and tell the user that we couldn't find a flow for the error. Reported-by: Doug Baggett Link: https://bugzilla.redhat.com/show_bug.cgi?id=2529245 Fixes: edeb2a26c663 ("udp: Improve messages for errors getting errors") Signed-off-by: Stefano Brivio --- flow.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/flow.c b/flow.c index 71918b7..27a24a4 100644 --- a/flow.c +++ b/flow.c @@ -295,14 +295,19 @@ void flow_log__(const struct flow_common *f, int pri, bool perror, bool details, (void)vsnprintf(msg, sizeof(msg), fmt, args); va_end(args); - /* Show type if it's set, otherwise the state */ - if (f->state < FLOW_STATE_TYPED) - type_or_state = FLOW_STATE(f); - else - type_or_state = FLOW_TYPE(f); + if (!f) { + logmsg(!perror, false, pri, "Flow: not found, error: %s", msg); + details = false; + } else { + /* Show type if it's set, otherwise the state */ + if (f->state < FLOW_STATE_TYPED) + type_or_state = FLOW_STATE(f); + else + type_or_state = FLOW_TYPE(f); - logmsg(!perror, false, pri, - "Flow %u (%s): %s", flow_idx(f), type_or_state, msg); + logmsg(!perror, false, pri, + "Flow %u (%s): %s", flow_idx(f), type_or_state, msg); + } if (perror) logmsg(true, true, pri, ": %s", strerror_(errno_)); -- 2.43.0