public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Stefano Brivio <sbrivio@redhat.com>
Cc: passt-dev@passt.top
Subject: Re: [PATCH v2 0/6] Improvements to flow specific logging
Date: Sat, 20 Jun 2026 01:27:23 +1000	[thread overview]
Message-ID: <ajVf26AIP4uNZ-bb@zatzit> (raw)
In-Reply-To: <20260619131044.30bdf848@elisabeth>

[-- Attachment #1: Type: text/plain, Size: 4940 bytes --]

On Fri, Jun 19, 2026 at 01:10:44PM +0200, Stefano Brivio wrote:
> On Wed, 17 Jun 2026 13:11:16 +1000
> David Gibson <david@gibson.dropbear.id.au> wrote:
> 
> > While working on podman bug 23739, I found some deficiences in how and
> > when we report various socket errors related to specific flows.  Here
> > are some preliminary patches to improve that.
> > 
> > I think patches 1..3 are pretty straightforward and safe.  4/4 I think
> > is a good idea in principle - promoting the priority of a number of
> > messages now that we have ratelimiting.  However, plumbing 'now' all
> > the places we need it resuls in a *lot* of churn, so we might want to
> > postpone or split it up.
> > 
> > Still, current drafted posted for consideration.
> > 
> > v2:
> >  * Added patch 2/6 At Stefano's suggestion
> >  * Simplified the errno Handling fix at Stefano's suggestion
> >  * Added patch 6/6 which I noticed while revising 5/6.
> >  * Made a handful of minor corrections based on feedback.
> > 
> > David Gibson (6):
> >   flow: Regularise flow specific logging helpers
> >   flow: Indent flow details messages
> >   flow: Include flow details with higher priority log messages
> >   flow, udp: Fix errno handling in udp_flow_sock()
> >   flow, treewide: Promote priority of selected flow-linked messages
> >   udp: Improve messages for errors getting errors
> 
> I was about to apply this without 6/6 because it leads cppcheck (at
> least my version, but the warning appears obviously correct) to
> complain that:

Argh.  How did I manage to forget to do a checker run *again*.

> ---
> udp.c:583:20: style: Local variable 'uflow' shadows outer variable [shadowVariable]
>   struct udp_flow *uflow = udp_at_sidx(sidx);
>                    ^
> udp.c:576:19: note: Shadowed declaration
>  struct udp_flow *uflow;
>                   ^
> udp.c:583:20: note: Shadow variable
>   struct udp_flow *uflow = udp_at_sidx(sidx);
>                    ^
> ---

Not only is the warning correct, but it pointed out a deeper error: I
can't actually use a flow_log() function here, because we only
sometimes know what flow we're dealing with at this point.  Fixed.

> and Coverity Scan to report this:
> 
> ---
> /home/sbrivio/passt/udp.c:727:3:
>   Type: Extra argument to printf format specifier (PRINTF_ARGS)
> 
> /home/sbrivio/passt/udp.c:727:3:
>   extra_argument: This argument was not used by the format string: "s".
> /home/sbrivio/passt/flow.c:290:2:
>   printf_function: Calling "vsnprintf" which uses a "printf"-style format string. [Note: The source code implementation of the function has been overridden by a builtin model.]
> ---

This one too, points out a different problem - I failed to attach a
printf __attribute__ to the flow log function, which is why the
compiler didn't catch this.  That in turn caught another minor bug
where I missed one call when removing the flow_log_() parameter in 3/6.

> 
> but this warning, coming from 1/6 (oops, I didn't spot that myself),
> reported by clang-tidy, is a bit more fundamental for the whole series:
> 
> /home/sbrivio/passt/flow.c:281:6: error: function 'flow_log__' is within a recursive call chain [misc-no-recursion,-warnings-as-errors]
>   281 | void flow_log__(const struct flow_common *f, int pri, bool perror, bool details,
>       |      ^
> /home/sbrivio/passt/flow.c:281:6: note: example recursive call chain, starting from function 'flow_log__'
> /home/sbrivio/passt/flow.c:312:4: note: Frame #1: function 'flow_log__' calls function 'flow_log__' here:
>   312 |                         flow_log__(f, pri, false, false, state,
>       |                         ^
> /home/sbrivio/passt/flow.c:312:4: note: ... which was the starting point of the recursive call chain; there may be other cycles
> 
> ...so I didn't proceed for the moment. I guess you meant to call
> flow_log() there instead, but I'm not sure I should fix it up like
> that, as I guess you checked some specific stuff with this version
> which might be broken if I just fix it.

Whereas this one *looks* scary, but is basically fine.  The warning is
technically correct - there really is a recursive call here - but it's
at most one level of recursion (the recursive call only happens if
details==true, but always passes details=false to the next layer).
Plus it's a tail call, so it shouldn't even take an extra stack frame,
except maybe with -O0.

I was aware of this when I wrote it, but figured it was cleaner than
adding yet another layer of wrapper function to avoid it.  I didn't
realise that clang-tidy would whinge about the possibility of
recursion.  Anyway, I added a comment and a lint suppression for v3.

-- 
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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      reply	other threads:[~2026-06-19 15:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-17  3:11 David Gibson
2026-06-17  3:11 ` [PATCH v2 1/6] flow: Regularise flow specific logging helpers David Gibson
2026-06-17  3:11 ` [PATCH v2 2/6] flow: Indent flow details messages David Gibson
2026-06-17  3:11 ` [PATCH v2 3/6] flow: Include flow details with higher priority log messages David Gibson
2026-06-17  3:11 ` [PATCH v2 4/6] flow, udp: Fix errno handling in udp_flow_sock() David Gibson
2026-06-17  3:11 ` [PATCH v2 5/6] flow, treewide: Promote priority of selected flow-linked messages David Gibson
2026-06-17  5:23   ` Stefano Brivio
2026-06-17  3:11 ` [PATCH v2 6/6] udp: Improve messages for errors getting errors David Gibson
2026-06-19 11:10 ` [PATCH v2 0/6] Improvements to flow specific logging Stefano Brivio
2026-06-19 15:27   ` David Gibson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ajVf26AIP4uNZ-bb@zatzit \
    --to=david@gibson.dropbear.id.au \
    --cc=passt-dev@passt.top \
    --cc=sbrivio@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).