netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Eric Dumazet <edumazet@google.com>
Cc: "David S . Miller" <davem@davemloft.net>,
	Paolo Abeni <pabeni@redhat.com>,
	netdev@vger.kernel.org, eric.dumazet@gmail.com
Subject: Re: [PATCH net-next 2/2] rtnetlink: use xarray iterator to implement rtnl_dump_ifinfo()
Date: Fri, 9 Feb 2024 14:24:41 -0800	[thread overview]
Message-ID: <20240209142441.6c56435b@kernel.org> (raw)
In-Reply-To: <20240209145615.3708207-3-edumazet@google.com>

On Fri,  9 Feb 2024 14:56:15 +0000 Eric Dumazet wrote:
> +	unsigned long ifindex = cb->args[0];

[snip]

> +	for_each_netdev_dump(tgt_net, dev, ifindex) {
> +		if (link_dump_filtered(dev, master_idx, kind_ops))
> +			continue;
> +		err = rtnl_fill_ifinfo(skb, dev, net, RTM_NEWLINK,
> +				       NETLINK_CB(cb->skb).portid,
> +				       nlh->nlmsg_seq, 0, flags,
> +				       ext_filter_mask, 0, NULL, 0,
> +				       netnsid, GFP_KERNEL);
> +
> +		if (err < 0)
> +			break;
> +		cb->args[0] = ifindex + 1;

Perhaps we can cast the context buffer onto something typed and use 
it directly? I think it's a tiny bit less error prone:

	struct {
		unsigned long ifindex;
	} *ctx = (void *)cb->ctx;

Then we can:

	for_each_netdev_dump(tgt_net, dev, ctx->ifindex)
					   ^^^^^^^^^^^^

and not need to worry about saving the ifindex back to cb before
exiting.

Up to you.

  reply	other threads:[~2024-02-09 22:24 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-09 14:56 [PATCH net-next 0/2] net: use net->dev_by_index in two places Eric Dumazet
2024-02-09 14:56 ` [PATCH net-next 1/2] vlan: use xarray iterator to implement /proc/net/vlan/config Eric Dumazet
2024-02-09 22:25   ` Jakub Kicinski
2024-02-09 14:56 ` [PATCH net-next 2/2] rtnetlink: use xarray iterator to implement rtnl_dump_ifinfo() Eric Dumazet
2024-02-09 22:24   ` Jakub Kicinski [this message]
2024-02-10 11:23     ` Eric Dumazet
2024-02-11 18:29       ` Ido Schimmel
2024-02-11 21:35         ` Eric Dumazet

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=20240209142441.6c56435b@kernel.org \
    --to=kuba@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=eric.dumazet@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@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.
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).