netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] netdev-genl: fix error codes when outputting XDP features
@ 2024-06-13 21:30 Jakub Kicinski
  2024-06-13 22:13 ` Nambiar, Amritha
  2024-06-15  1:50 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 4+ messages in thread
From: Jakub Kicinski @ 2024-06-13 21:30 UTC (permalink / raw)
  To: davem
  Cc: netdev, edumazet, pabeni, Jakub Kicinski, hawk, amritha.nambiar,
	sridhar.samudrala, alardam, lorenzo, memxor

-EINVAL will interrupt the dump. The correct error to return
if we have more data to dump is -EMSGSIZE.

Discovered by doing:

  for i in `seq 80`; do ip link add type veth; done
  ./cli.py --dbg-small-recv 5300 --spec netdev.yaml --dump dev-get >> /dev/null
  [...]
     nl_len = 64 (48) nl_flags = 0x0 nl_type = 19
     nl_len = 20 (4) nl_flags = 0x2 nl_type = 3
  	error: -22

Fixes: d3d854fd6a1d ("netdev-genl: create a simple family for netdev stuff")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: hawk@kernel.org
CC: amritha.nambiar@intel.com
CC: sridhar.samudrala@intel.com
CC: alardam@gmail.com
CC: lorenzo@kernel.org
CC: memxor@gmail.com
---
 net/core/netdev-genl.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c
index 1f6ae6379e0f..05f9515d2c05 100644
--- a/net/core/netdev-genl.c
+++ b/net/core/netdev-genl.c
@@ -59,22 +59,22 @@ XDP_METADATA_KFUNC_xxx
 	    nla_put_u64_64bit(rsp, NETDEV_A_DEV_XDP_RX_METADATA_FEATURES,
 			      xdp_rx_meta, NETDEV_A_DEV_PAD) ||
 	    nla_put_u64_64bit(rsp, NETDEV_A_DEV_XSK_FEATURES,
-			      xsk_features, NETDEV_A_DEV_PAD)) {
-		genlmsg_cancel(rsp, hdr);
-		return -EINVAL;
-	}
+			      xsk_features, NETDEV_A_DEV_PAD))
+		goto err_cancel_msg;
 
 	if (netdev->xdp_features & NETDEV_XDP_ACT_XSK_ZEROCOPY) {
 		if (nla_put_u32(rsp, NETDEV_A_DEV_XDP_ZC_MAX_SEGS,
-				netdev->xdp_zc_max_segs)) {
-			genlmsg_cancel(rsp, hdr);
-			return -EINVAL;
-		}
+				netdev->xdp_zc_max_segs))
+			goto err_cancel_msg;
 	}
 
 	genlmsg_end(rsp, hdr);
 
 	return 0;
+
+err_cancel_msg:
+	genlmsg_cancel(rsp, hdr);
+	return -EMSGSIZE;
 }
 
 static void
-- 
2.45.2


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

* Re: [PATCH net] netdev-genl: fix error codes when outputting XDP features
  2024-06-13 21:30 [PATCH net] netdev-genl: fix error codes when outputting XDP features Jakub Kicinski
@ 2024-06-13 22:13 ` Nambiar, Amritha
  2024-06-14  6:38   ` Eric Dumazet
  2024-06-15  1:50 ` patchwork-bot+netdevbpf
  1 sibling, 1 reply; 4+ messages in thread
From: Nambiar, Amritha @ 2024-06-13 22:13 UTC (permalink / raw)
  To: Jakub Kicinski, davem
  Cc: netdev, edumazet, pabeni, hawk, sridhar.samudrala, alardam,
	lorenzo, memxor

On 6/13/2024 2:30 PM, Jakub Kicinski wrote:
> -EINVAL will interrupt the dump. The correct error to return
> if we have more data to dump is -EMSGSIZE.
> 
> Discovered by doing:
> 
>    for i in `seq 80`; do ip link add type veth; done
>    ./cli.py --dbg-small-recv 5300 --spec netdev.yaml --dump dev-get >> /dev/null
>    [...]
>       nl_len = 64 (48) nl_flags = 0x0 nl_type = 19
>       nl_len = 20 (4) nl_flags = 0x2 nl_type = 3
>    	error: -22
> 
> Fixes: d3d854fd6a1d ("netdev-genl: create a simple family for netdev stuff")
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>

LGTM.
Reviewed-by: Amritha Nambiar <amritha.nambiar@intel.com>

> ---
> CC: hawk@kernel.org
> CC: amritha.nambiar@intel.com
> CC: sridhar.samudrala@intel.com
> CC: alardam@gmail.com
> CC: lorenzo@kernel.org
> CC: memxor@gmail.com
> ---
>   net/core/netdev-genl.c | 16 ++++++++--------
>   1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c
> index 1f6ae6379e0f..05f9515d2c05 100644
> --- a/net/core/netdev-genl.c
> +++ b/net/core/netdev-genl.c
> @@ -59,22 +59,22 @@ XDP_METADATA_KFUNC_xxx
>   	    nla_put_u64_64bit(rsp, NETDEV_A_DEV_XDP_RX_METADATA_FEATURES,
>   			      xdp_rx_meta, NETDEV_A_DEV_PAD) ||
>   	    nla_put_u64_64bit(rsp, NETDEV_A_DEV_XSK_FEATURES,
> -			      xsk_features, NETDEV_A_DEV_PAD)) {
> -		genlmsg_cancel(rsp, hdr);
> -		return -EINVAL;
> -	}
> +			      xsk_features, NETDEV_A_DEV_PAD))
> +		goto err_cancel_msg;
>   
>   	if (netdev->xdp_features & NETDEV_XDP_ACT_XSK_ZEROCOPY) {
>   		if (nla_put_u32(rsp, NETDEV_A_DEV_XDP_ZC_MAX_SEGS,
> -				netdev->xdp_zc_max_segs)) {
> -			genlmsg_cancel(rsp, hdr);
> -			return -EINVAL;
> -		}
> +				netdev->xdp_zc_max_segs))
> +			goto err_cancel_msg;
>   	}
>   
>   	genlmsg_end(rsp, hdr);
>   
>   	return 0;
> +
> +err_cancel_msg:
> +	genlmsg_cancel(rsp, hdr);
> +	return -EMSGSIZE;
>   }
>   
>   static void

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

* Re: [PATCH net] netdev-genl: fix error codes when outputting XDP features
  2024-06-13 22:13 ` Nambiar, Amritha
@ 2024-06-14  6:38   ` Eric Dumazet
  0 siblings, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2024-06-14  6:38 UTC (permalink / raw)
  To: Nambiar, Amritha
  Cc: Jakub Kicinski, davem, netdev, pabeni, hawk, sridhar.samudrala,
	alardam, lorenzo, memxor

On Fri, Jun 14, 2024 at 12:13 AM Nambiar, Amritha
<amritha.nambiar@intel.com> wrote:
>
> On 6/13/2024 2:30 PM, Jakub Kicinski wrote:
> > -EINVAL will interrupt the dump. The correct error to return
> > if we have more data to dump is -EMSGSIZE.
> >
> > Discovered by doing:
> >
> >    for i in `seq 80`; do ip link add type veth; done
> >    ./cli.py --dbg-small-recv 5300 --spec netdev.yaml --dump dev-get >> /dev/null
> >    [...]
> >       nl_len = 64 (48) nl_flags = 0x0 nl_type = 19
> >       nl_len = 20 (4) nl_flags = 0x2 nl_type = 3
> >       error: -22
> >
> > Fixes: d3d854fd6a1d ("netdev-genl: create a simple family for netdev stuff")
> > Signed-off-by: Jakub Kicinski <kuba@kernel.org>
>
> LGTM.
> Reviewed-by: Amritha Nambiar <amritha.nambiar@intel.com>

Reviewed-by: Eric Dumazet <edumazet@google.com>

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

* Re: [PATCH net] netdev-genl: fix error codes when outputting XDP features
  2024-06-13 21:30 [PATCH net] netdev-genl: fix error codes when outputting XDP features Jakub Kicinski
  2024-06-13 22:13 ` Nambiar, Amritha
@ 2024-06-15  1:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-06-15  1:50 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: davem, netdev, edumazet, pabeni, hawk, amritha.nambiar,
	sridhar.samudrala, alardam, lorenzo, memxor

Hello:

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

On Thu, 13 Jun 2024 14:30:44 -0700 you wrote:
> -EINVAL will interrupt the dump. The correct error to return
> if we have more data to dump is -EMSGSIZE.
> 
> Discovered by doing:
> 
>   for i in `seq 80`; do ip link add type veth; done
>   ./cli.py --dbg-small-recv 5300 --spec netdev.yaml --dump dev-get >> /dev/null
>   [...]
>      nl_len = 64 (48) nl_flags = 0x0 nl_type = 19
>      nl_len = 20 (4) nl_flags = 0x2 nl_type = 3
>   	error: -22
> 
> [...]

Here is the summary with links:
  - [net] netdev-genl: fix error codes when outputting XDP features
    https://git.kernel.org/netdev/net/c/7ed352d34f1a

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:[~2024-06-15  1:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-13 21:30 [PATCH net] netdev-genl: fix error codes when outputting XDP features Jakub Kicinski
2024-06-13 22:13 ` Nambiar, Amritha
2024-06-14  6:38   ` Eric Dumazet
2024-06-15  1: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).