Subject: Re: [PATCH net-next v2 09/12] ethtool: rss: support dumping RSS contexts

From: Jakub Kicinski <[email-masked]>
Date: Mon, 5 Aug 2024 14:59:33 -0700

On Sat, 3 Aug 2024 19:11:28 +0100 Joe Damato wrote:
> > +struct rss_nl_dump_ctx {
> > +	unsigned long		ifindex;
> > +	unsigned long		ctx_idx;
> > +
> > +	unsigned int		one_ifindex;  
> 
> My apologies: I'm probably just not familiar enough with the code,
> but I'm having a hard time understanding what the purpose of
> one_ifindex is.
> 
> I read both ethnl_rss_dump_start and ethnl_rss_dumpit, but I'm still
> not following what this is used for; it'll probably be obvious in
> retrospect once you explain it, but I suppose my feedback is that a
> comment or something would be really helpful :)

Better name would probably help, but can't think of any.

User can (optionally) pass an ifindex/ifname to the dump, to dump
contexts only for the specified ifindex. If they do we "preset"
the ifindex and one_ifindex:

+	if (req_info.dev) {
+		ctx->one_ifindex = req_info.dev->ifindex;
+		ctx->ifindex = ctx->one_ifindex;
+		ethnl_parse_header_dev_put(&req_info);
+		req_info.dev = NULL;
+	}

and then the iteration is stopped after first full pass:

+	rtnl_lock();
+	for_each_netdev_dump(net, dev, ctx->ifindex) {
+		if (ctx->one_ifindex && ctx->one_ifindex != ctx->ifindex)
+			break;

Unfortunately we don't have any best practice for handling filtering 
in dumps. I find this cleaner than approaches I previously tried, but
we'll see if it stands the test of time.

I'll add the following comment:

	/* User wants to dump contexts for one ifindex only */