lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240209142441.6c56435b@kernel.org>
Date: Fri, 9 Feb 2024 14:24:41 -0800
From: Jakub Kicinski <kuba@...nel.org>
To: Eric Dumazet <edumazet@...gle.com>
Cc: "David S . Miller" <davem@...emloft.net>, Paolo Abeni
 <pabeni@...hat.com>, netdev@...r.kernel.org, eric.dumazet@...il.com
Subject: Re: [PATCH net-next 2/2] rtnetlink: use xarray iterator to
 implement rtnl_dump_ifinfo()

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.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ