netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Cc: <davem@davemloft.net>, <netdev@vger.kernel.org>,
	<edumazet@google.com>, <pabeni@redhat.com>
Subject: Re: [PATCH net-next] net: make for_each_netdev_dump() a little more bug-proof
Date: Thu, 13 Jun 2024 18:57:28 -0700	[thread overview]
Message-ID: <20240613185728.6e7bf9ad@kernel.org> (raw)
In-Reply-To: <d6e29acc-c759-48ce-bea2-3088b4d3ea86@intel.com>

On Fri, 14 Jun 2024 03:45:47 +0200 Przemek Kitszel wrote:
> you are right, it would be easier to go one step [of macros] up, we have
>   453│ #define xa_for_each_range(xa, index, entry, start, last)         \
>   454│         for (index = start,                                      \
>   455│              entry = xa_find(xa, &index, last, XA_PRESENT);      \
>   456│              entry;                                              \
>   457│              entry = xa_find_after(xa, &index, last, XA_PRESENT))
> 
> You could simply change L456 to:
> entry || (index = 0);
> to achieve what you want; but that would slow down a little lot's of
> places, only to change value of the index that should not be used :P
> 
> For me a proper solution would be to fast forward into C11 era, and move
> @index allocation into the loop, so value could not be abused.

I think we're already in C11 era for that exact reason 🤐️
But please don't take this as an invitation to do crazy things!

In netlink dumps, tho, we keep the index in persistent socket context,
because the iteration is split into multiple recvmsg() calls,
each one continuing where the previous one left off.

  reply	other threads:[~2024-06-14  1:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-13 21:33 [PATCH net-next] net: make for_each_netdev_dump() a little more bug-proof Jakub Kicinski
2024-06-14  1:45 ` Przemek Kitszel
2024-06-14  1:57   ` Jakub Kicinski [this message]
2024-06-14 10:36 ` Przemek Kitszel
2024-06-17 12:20 ` patchwork-bot+netdevbpf

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=20240613185728.6e7bf9ad@kernel.org \
    --to=kuba@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=przemyslaw.kitszel@intel.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.
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 NNTP newsgroup(s).