Skip to contentSkip to conversation

netdev-genl: Set extack and fix error on napi-get

PATCH Applied Joe Damato 3 participants 4 messages Aug 31, 2024 – Sep 3, 2024

Subsystems (2)
lore
Share & tools
lore

Joe Damato

author
#0 lore raw

PATCH 1/1 netdev-genl: Set extack and fix error on napi-get

In commit 27f91aaf49b3 ("netdev-genl: Add netlink framework functions for napi"), when an invalid NAPI ID is specified the return value -EINVAL is used and no extack is set.

Change the return value to -ENOENT and set the extack.

Before this commit:

$ ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/netdev.yaml \
                          --do napi-get --json='{"id": 451}'
Netlink error: Invalid argument
nl_len = 36 (20) nl_flags = 0x100 nl_type = 2
	error: -22

After this commit:

$ ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/netdev.yaml \
                         --do napi-get --json='{"id": 451}'
Netlink error: No such file or directory
nl_len = 44 (28) nl_flags = 0x300 nl_type = 2
	error: -2
	extack: {'bad-attr': '.id'}
Cc Amritha Nambiar <[email protected]>
Fixes 27f91aaf49b3 ("netdev-genl: Add netlink framework functions for napi")
---
 net/core/netdev-genl.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
net/core/netdev-genl.c +5 -3
index 05f9515d2c05..a17d7eaeb001 100644
@@ -216,10 +216,12 @@ int netdev_nl_napi_get_doit(struct sk_buff *skb, struct genl_info *info)
 	rtnl_lock();
 
 	napi = napi_by_id(napi_id);
-	if (napi)
+	if (napi) {
 		err = netdev_nl_napi_fill_one(rsp, napi, info);
-	else
-		err = -EINVAL;
+	} else {
+		NL_SET_BAD_ATTR(info->extack, info->attrs[NETDEV_A_NAPI_ID]);
+		err = -ENOENT;
+	}
 
 	rtnl_unlock();
 
Signature · 1 line
2.25.1
author
#1 lore raw
Quoted 54 lines · Joe Damato

In commit 27f91aaf49b3 ("netdev-genl: Add netlink framework functions for napi"), when an invalid NAPI ID is specified the return value -EINVAL is used and no extack is set.

Change the return value to -ENOENT and set the extack.

Before this commit:

$ ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/netdev.yaml \
                          --do napi-get --json='{"id": 451}'
Netlink error: Invalid argument
nl_len = 36 (20) nl_flags = 0x100 nl_type = 2
	error: -22

After this commit:

$ ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/netdev.yaml \
                         --do napi-get --json='{"id": 451}'
Netlink error: No such file or directory
nl_len = 44 (28) nl_flags = 0x300 nl_type = 2
	error: -2
	extack: {'bad-attr': '.id'}
Cc Amritha Nambiar <[email protected]>
Fixes 27f91aaf49b3 ("netdev-genl: Add netlink framework functions for napi")
---
 net/core/netdev-genl.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
net/core/netdev-genl.c +5 -3
index 05f9515d2c05..a17d7eaeb001 100644
@@ -216,10 +216,12 @@ int netdev_nl_napi_get_doit(struct sk_buff *skb, struct genl_info *info)
 	rtnl_lock();
 
 	napi = napi_by_id(napi_id);
-	if (napi)
+	if (napi) {
 		err = netdev_nl_napi_fill_one(rsp, napi, info);
-	else
-		err = -EINVAL;
+	} else {
+		NL_SET_BAD_ATTR(info->extack, info->attrs[NETDEV_A_NAPI_ID]);
+		err = -ENOENT;
+	}
 
 	rtnl_unlock();
 
Signature · 1 line
2.25.1

Based on Eric's comment regarding my other patch [1], I should probably re-submit this against net-next instead of net.

It's been over 48 hours, but I'll wait a bit longer before resubmitting.

[1]: https://lore.kernel.org/all/CANn89iLhrKyFKf9DpJSSM9CZ9sgoRo7jovg2GhjsJABoqzzVsQ@mail.gmail.com/

maintainer
#2 lore raw
Quoted 5 lines · On Mon, 2 Sep 2024 20:52:15 +0200 Joe Damato wrote:

Based on Eric's comment regarding my other patch [1], I should probably re-submit this against net-next instead of net.

It's been over 48 hours, but I'll wait a bit longer before resubmitting.

Change is simple enough, I'll strip the tags and apply to net-next. Thanks!

#3 lore raw
In reply to Joe Damato
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Sat, 31 Aug 2024 12:17:04 +0000 you wrote:

In commit 27f91aaf49b3 ("netdev-genl: Add netlink framework functions for napi"), when an invalid NAPI ID is specified the return value -EINVAL is used and no extack is set.

Change the return value to -ENOENT and set the extack.

Before this commit:

[...]

Here is the summary with links:
- [net] netdev-genl: Set extack and fix error on napi-get

    https://git.kernel.org/netdev/net-next/c/4e3a024b437e

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html