netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: warn during dump if NAPI list is not sorted
@ 2025-01-10  0:45 Jakub Kicinski
  2025-01-10  6:16 ` Michal Swiatkowski
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jakub Kicinski @ 2025-01-10  0:45 UTC (permalink / raw)
  To: davem
  Cc: netdev, edumazet, pabeni, andrew+netdev, horms, Jakub Kicinski,
	jdamato, almasrymina

Dump continuation depends on the NAPI list being sorted.
Broken netlink dump continuation may be rare and hard to debug
so add a warning if we notice the potential problem while walking
the list.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
This is really a follow up to commit d6c7b03497ee ("net: make sure
we retain NAPI ordering on netdev->napi_list") but I had to wait
for some fixes to make it to net-next.

CC: jdamato@fastly.com
CC: almasrymina@google.com
---
 net/core/netdev-genl.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c
index a3bdaf075b6b..c59619a2ec23 100644
--- a/net/core/netdev-genl.c
+++ b/net/core/netdev-genl.c
@@ -263,14 +263,21 @@ netdev_nl_napi_dump_one(struct net_device *netdev, struct sk_buff *rsp,
 			struct netdev_nl_dump_ctx *ctx)
 {
 	struct napi_struct *napi;
+	unsigned int prev_id;
 	int err = 0;
 
 	if (!(netdev->flags & IFF_UP))
 		return err;
 
+	prev_id = UINT_MAX;
 	list_for_each_entry(napi, &netdev->napi_list, dev_list) {
 		if (napi->napi_id < MIN_NAPI_ID)
 			continue;
+
+		/* Dump continuation below depends on the list being sorted */
+		WARN_ON_ONCE(napi->napi_id >= prev_id);
+		prev_id = napi->napi_id;
+
 		if (ctx->napi_id && napi->napi_id >= ctx->napi_id)
 			continue;
 
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] net: warn during dump if NAPI list is not sorted
  2025-01-10  0:45 [PATCH net-next] net: warn during dump if NAPI list is not sorted Jakub Kicinski
@ 2025-01-10  6:16 ` Michal Swiatkowski
  2025-01-10 18:06 ` Joe Damato
  2025-01-11  2:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Michal Swiatkowski @ 2025-01-10  6:16 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms, jdamato,
	almasrymina

On Thu, Jan 09, 2025 at 04:45:04PM -0800, Jakub Kicinski wrote:
> Dump continuation depends on the NAPI list being sorted.
> Broken netlink dump continuation may be rare and hard to debug
> so add a warning if we notice the potential problem while walking
> the list.
> 
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
> This is really a follow up to commit d6c7b03497ee ("net: make sure
> we retain NAPI ordering on netdev->napi_list") but I had to wait
> for some fixes to make it to net-next.
> 
> CC: jdamato@fastly.com
> CC: almasrymina@google.com
> ---
>  net/core/netdev-genl.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c
> index a3bdaf075b6b..c59619a2ec23 100644
> --- a/net/core/netdev-genl.c
> +++ b/net/core/netdev-genl.c
> @@ -263,14 +263,21 @@ netdev_nl_napi_dump_one(struct net_device *netdev, struct sk_buff *rsp,
>  			struct netdev_nl_dump_ctx *ctx)
>  {
>  	struct napi_struct *napi;
> +	unsigned int prev_id;
>  	int err = 0;
>  
>  	if (!(netdev->flags & IFF_UP))
>  		return err;
>  
> +	prev_id = UINT_MAX;
>  	list_for_each_entry(napi, &netdev->napi_list, dev_list) {
>  		if (napi->napi_id < MIN_NAPI_ID)
>  			continue;
> +
> +		/* Dump continuation below depends on the list being sorted */
> +		WARN_ON_ONCE(napi->napi_id >= prev_id);
> +		prev_id = napi->napi_id;
> +
>  		if (ctx->napi_id && napi->napi_id >= ctx->napi_id)
>  			continue;
>  

Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>

> -- 
> 2.47.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] net: warn during dump if NAPI list is not sorted
  2025-01-10  0:45 [PATCH net-next] net: warn during dump if NAPI list is not sorted Jakub Kicinski
  2025-01-10  6:16 ` Michal Swiatkowski
@ 2025-01-10 18:06 ` Joe Damato
  2025-01-11  2:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Joe Damato @ 2025-01-10 18:06 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms,
	almasrymina

On Thu, Jan 09, 2025 at 04:45:04PM -0800, Jakub Kicinski wrote:
> Dump continuation depends on the NAPI list being sorted.
> Broken netlink dump continuation may be rare and hard to debug
> so add a warning if we notice the potential problem while walking
> the list.
> 
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
> This is really a follow up to commit d6c7b03497ee ("net: make sure
> we retain NAPI ordering on netdev->napi_list") but I had to wait
> for some fixes to make it to net-next.
> 
> CC: jdamato@fastly.com
> CC: almasrymina@google.com
> ---
>  net/core/netdev-genl.c | 7 +++++++
>  1 file changed, 7 insertions(+)

Thanks.

Reviewed-by: Joe Damato <jdamato@fastly.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] net: warn during dump if NAPI list is not sorted
  2025-01-10  0:45 [PATCH net-next] net: warn during dump if NAPI list is not sorted Jakub Kicinski
  2025-01-10  6:16 ` Michal Swiatkowski
  2025-01-10 18:06 ` Joe Damato
@ 2025-01-11  2:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-01-11  2:50 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms, jdamato,
	almasrymina

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Thu,  9 Jan 2025 16:45:04 -0800 you wrote:
> Dump continuation depends on the NAPI list being sorted.
> Broken netlink dump continuation may be rare and hard to debug
> so add a warning if we notice the potential problem while walking
> the list.
> 
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> 
> [...]

Here is the summary with links:
  - [net-next] net: warn during dump if NAPI list is not sorted
    https://git.kernel.org/netdev/net-next/c/af3525d41001

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-01-11  2:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-10  0:45 [PATCH net-next] net: warn during dump if NAPI list is not sorted Jakub Kicinski
2025-01-10  6:16 ` Michal Swiatkowski
2025-01-10 18:06 ` Joe Damato
2025-01-11  2:50 ` patchwork-bot+netdevbpf

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).