netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Amritha Nambiar <amritha.nambiar@intel.com>
Cc: netdev@vger.kernel.org, kuba@kernel.org, davem@davemloft.net,
	sridhar.samudrala@intel.com
Subject: Re: [net-next PATCH v1 5/9] netdev-genl: Add netlink framework functions for napi
Date: Sun, 30 Jul 2023 19:15:58 +0200	[thread overview]
Message-ID: <ZMaaztfofIy7g9Qx@kernel.org> (raw)
In-Reply-To: <169059163779.3736.7602272507688648566.stgit@anambiarhost.jf.intel.com>

On Fri, Jul 28, 2023 at 05:47:17PM -0700, Amritha Nambiar wrote:
> Implement the netdev netlink framework functions for
> napi support. The netdev structure tracks all the napi
> instances and napi fields. The napi instances and associated
> queue[s] can be retrieved this way.
> 
> Signed-off-by: Amritha Nambiar <amritha.nambiar@intel.com>
> ---
>  net/core/netdev-genl.c |  253 ++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 251 insertions(+), 2 deletions(-)
> 
> diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c

...

>  int netdev_nl_napi_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
>  {
> -	return -EOPNOTSUPP;
> +	struct netdev_nl_dump_ctx *ctx = netdev_dump_ctx(cb);
> +	struct net *net = sock_net(skb->sk);
> +	struct net_device *netdev;
> +	int idx = 0, s_idx, n_idx;
> +	int h, s_h;
> +	int err;
> +
> +	s_h = ctx->dev_entry_hash;
> +	s_idx = ctx->dev_entry_idx;
> +	n_idx = ctx->napi_idx;
> +
> +	rtnl_lock();
> +
> +	for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
> +		struct hlist_head *head;
> +
> +		idx = 0;
> +		head = &net->dev_index_head[h];
> +		hlist_for_each_entry(netdev, head, index_hlist) {
> +			if (idx < s_idx)
> +				goto cont;
> +			err = netdev_nl_napi_dump_entry(netdev, skb, cb, &n_idx);
> +			if (err == -EMSGSIZE)
> +				goto out;
> +			n_idx = 0;
> +			if (err < 0)
> +				break;
> +cont:
> +			idx++;
> +		}
> +	}
> +
> +	rtnl_unlock();
> +
> +	return err;

Hi Amritha,

I'm unsure if this can happen, but if loop iteration occurs zero times
above in such a way that netdev_nl_napi_dump_entry() isn't called, then err
will be uninitialised here.

This is also the case in netdev_nl_dev_get_dumpit
(both before and after this patch.

As flagged by Smatch.

> +
> +out:
> +	rtnl_unlock();
> +
> +	ctx->dev_entry_idx = idx;
> +	ctx->dev_entry_hash = h;
> +	ctx->napi_idx = n_idx;
> +	cb->seq = net->dev_base_seq;
> +
> +	return skb->len;
>  }

...

  reply	other threads:[~2023-07-30 17:16 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-29  0:46 [net-next PATCH v1 0/9] Introduce NAPI queues support Amritha Nambiar
2023-07-29  0:46 ` [net-next PATCH v1 1/9] net: Introduce new fields for napi and queue associations Amritha Nambiar
2023-07-29  9:55   ` kernel test robot
2023-07-30 17:10   ` Simon Horman
2023-07-31 22:57     ` Nambiar, Amritha
2023-07-29  0:47 ` [net-next PATCH v1 2/9] ice: Add support in the driver for associating napi with queue[s] Amritha Nambiar
2023-07-29  0:47 ` [net-next PATCH v1 3/9] netdev-genl: spec: Extend netdev netlink spec in YAML for NAPI Amritha Nambiar
2023-07-31 19:36   ` Jakub Kicinski
2023-07-31 23:12     ` Nambiar, Amritha
2023-08-01  0:13       ` Jakub Kicinski
2023-08-01  0:24         ` Nambiar, Amritha
2023-08-01  0:35           ` Jakub Kicinski
2023-08-09  0:17             ` Nambiar, Amritha
2023-08-09  2:45               ` Jakub Kicinski
2023-07-29  0:47 ` [net-next PATCH v1 4/9] net: Move kernel helpers for queue index outside sysfs Amritha Nambiar
2023-07-29  0:47 ` [net-next PATCH v1 5/9] netdev-genl: Add netlink framework functions for napi Amritha Nambiar
2023-07-30 17:15   ` Simon Horman [this message]
2023-07-31 23:00     ` Nambiar, Amritha
2023-07-31 19:37   ` Jakub Kicinski
2023-07-31 23:01     ` Nambiar, Amritha
2023-07-29  0:47 ` [net-next PATCH v1 6/9] netdev-genl: spec: Add irq in netdev netlink YAML spec Amritha Nambiar
2023-07-29  0:47 ` [net-next PATCH v1 7/9] net: Add NAPI IRQ support Amritha Nambiar
2023-07-29  4:05   ` Stephen Hemminger
2023-07-31 23:22     ` Nambiar, Amritha
2023-07-29  0:47 ` [net-next PATCH v1 8/9] netdev-genl: spec: Add PID in netdev netlink YAML spec Amritha Nambiar
2023-07-29  0:47 ` [net-next PATCH v1 9/9] netdev-genl: Add PID for the NAPI thread Amritha Nambiar

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=ZMaaztfofIy7g9Qx@kernel.org \
    --to=horms@kernel.org \
    --cc=amritha.nambiar@intel.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=sridhar.samudrala@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).