From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 6ED995A0271 for ; Mon, 16 Nov 2026 05:34:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202610; t=1794803680; bh=2pqyFpJpoYjpAgM70JnRaKvqYIcttROWU6rOLiZ3ysI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=odn+UqfL4gPa+TsiOtom9j2tjSQAAKrxROgeb0uyqdehvMILfrPHlmT0F6zVsUIit RnZZdXJ9agGIWrHSDnR8Lk3qg/Vokmo99FBNj/8NOvKoSmtw5gmwyrQiJkVTlQ2OJs 7o34JgjfF1wuCDF762cIAYHtdJuSq1HlspWMveLdRBEF81Co7rMwxe2T4c+7p10z7f xboO0NqALnrte0tcZOB3ghjxe1G/LeGg5jnUKZIsoUYZQO3dFhMD5A1svbqvlHqVas RYzSKA2YkEYUS8ykNMIRgyAtNg3Wg4TVjXOTB3R0T40Jp+fzPq6S64kVrHuws4woG5 BojKsF0JNFtFw== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4jSZlN1Hqjz4wLm; Mon, 16 Nov 2026 15:34:40 +1100 (AEDT) Date: Mon, 16 Nov 2026 14:12:35 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH] flow: Handle NULL (unknown) flows in flow logging functions Message-ID: References: <20261115223728.1400901-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="hx6I+hynrc/UzlaG" Content-Disposition: inline In-Reply-To: <20261115223728.1400901-1-sbrivio@redhat.com> Message-ID-Hash: TF22LRSO6FSOJD2JXGPFI4XO7AD5DS63 X-Message-ID-Hash: TF22LRSO6FSOJD2JXGPFI4XO7AD5DS63 X-MailFrom: dgibson@gandalf.ozlabs.org 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: passt-dev@passt.top, Doug Baggett 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: --hx6I+hynrc/UzlaG Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Nov 15, 2026 at 11:37:28PM +0100, Stefano Brivio wrote: > 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(). >=20 > 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. >=20 > 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. >=20 > Reported-by: Doug Baggett > Link: https://bugzilla.redhat.com/show_bug.cgi?id=3D2529245 > Fixes: edeb2a26c663 ("udp: Improve messages for errors getting errors") > Signed-off-by: Stefano Brivio Reviewed-by: David Gibson > --- > flow.c | 19 ++++++++++++------- > 1 file changed, 12 insertions(+), 7 deletions(-) >=20 > 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 pr= i, bool perror, bool details, > (void)vsnprintf(msg, sizeof(msg), fmt, args); > va_end(args); > =20 > - /* Show type if it's set, otherwise the state */ > - if (f->state < FLOW_STATE_TYPED) > - type_or_state =3D FLOW_STATE(f); > - else > - type_or_state =3D FLOW_TYPE(f); > + if (!f) { > + logmsg(!perror, false, pri, "Flow: not found, error: %s", msg); > + details =3D false; > + } else { > + /* Show type if it's set, otherwise the state */ > + if (f->state < FLOW_STATE_TYPED) > + type_or_state =3D FLOW_STATE(f); > + else > + type_or_state =3D FLOW_TYPE(f); > =20 > - 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); > + } > =20 > if (perror) > logmsg(true, true, pri, ": %s", strerror_(errno_)); > --=20 > 2.43.0 >=20 --=20 David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson --hx6I+hynrc/UzlaG Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmr6dKMACgkQzQJF27ox 2GenmA/9HahHHVUqBhEV02DdVIfYy8KOWEY6/rtrX+/vwypgiva9gxd02EyompXY ub4n4CO8Hg3zkSpE1xW6ihXdvQalfQPeaW/BqfaYZrcL5QsV8jZ2vFeWltGgxEIj 1gu0HaX5b2aLXde624H84hMscZss185IpIYMQ7wmQ1+QyY0OK0Yp2h0X+K35hayM OybRz9qVOzMjk59IWRIS4KQfVgSWjvPm+GplhNRPGsfNlmCgrdrGvziVD7HKWNbw w2DQJYu3FKdp94n3VrRAlSO/AV/9Dlnzors+SuIlUeCptj6MZHxoNx/42/en+Hw4 65RtjnAlTOn51enHbDV/ZQI6o+ZUnZtefBE5ih2Is5j55tT3Ph2JbEA4lIDmyWYj D/NVmCNLsRAHec7sm/HLIrXYkjTCuwoxC15ET8ZDlHZ1tWoksh7T8OmHm0RF+FkP Pv0Upn2oWo1rBZRXH5g5jWuERNKvBI+fEo066iaRMP1BZ1nJAmU2gtzutPhjP/B9 FP08xKVa3Wafr4qwy0zwBV6HR3a7D4lHh/tPBBSlufwqO/cUgNwONJljBKY8HoNI J28b5RdkxTTi2C0UNjiUZ2ynKsEjx/5yFyU6Y1NN3Dj9apuUxsCyUTuPeVIhjn0j tA0/yLCju3gvnHiPzzhwnKMGnZaKUXpV15aM7mcQeJmSadLkf1c= =+4o8 -----END PGP SIGNATURE----- --hx6I+hynrc/UzlaG--