diff mbox series

[net] netdev-genl: fix error codes when outputting XDP features

Message ID 20240613213044.3675745-1-kuba@kernel.org (mailing list archive)
State Accepted
Commit 7ed352d34f1a09a7659c53de07785115587499fe
Delegated to: Netdev Maintainers
Headers show
Series [net] netdev-genl: fix error codes when outputting XDP features | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 861 this patch: 861
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 4 maintainers not CCed: bpf@vger.kernel.org john.fastabend@gmail.com ast@kernel.org daniel@iogearbox.net
netdev/build_clang success Errors and warnings before: 863 this patch: 863
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 865 this patch: 865
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 30 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-06-14--21-00 (tests: 650)

Commit Message

Jakub Kicinski June 13, 2024, 9:30 p.m. UTC
-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(-)

Comments

Nambiar, Amritha June 13, 2024, 10:13 p.m. UTC | #1
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
Eric Dumazet June 14, 2024, 6:38 a.m. UTC | #2
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>
patchwork-bot+netdevbpf@kernel.org June 15, 2024, 1:50 a.m. UTC | #3
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!
diff mbox series

Patch

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