* [PATCH net] netdev-genl: Set extack and fix error on napi-get
@ 2024-08-31 12:17 Joe Damato
2024-09-02 18:52 ` Joe Damato
2024-09-03 1:40 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 4+ messages in thread
From: Joe Damato @ 2024-08-31 12:17 UTC (permalink / raw)
To: netdev
Cc: mkarsten, Joe Damato, Amritha Nambiar, stable, Jakub Kicinski,
David S. Miller, Eric Dumazet, Paolo Abeni, Sridhar Samudrala,
Stanislav Fomichev, Daniel Jurgens, open list
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 <amritha.nambiar@intel.com>
Cc: stable@kernel.org
Suggested-by: Jakub Kicinski <kuba@kernel.org>
Fixes: 27f91aaf49b3 ("netdev-genl: Add netlink framework functions for napi")
Signed-off-by: Joe Damato <jdamato@fastly.com>
---
net/core/netdev-genl.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c
index 05f9515d2c05..a17d7eaeb001 100644
--- a/net/core/netdev-genl.c
+++ b/net/core/netdev-genl.c
@@ -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();
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net] netdev-genl: Set extack and fix error on napi-get
2024-08-31 12:17 [PATCH net] netdev-genl: Set extack and fix error on napi-get Joe Damato
@ 2024-09-02 18:52 ` Joe Damato
2024-09-03 1:28 ` Jakub Kicinski
2024-09-03 1:40 ` patchwork-bot+netdevbpf
1 sibling, 1 reply; 4+ messages in thread
From: Joe Damato @ 2024-09-02 18:52 UTC (permalink / raw)
To: netdev
Cc: mkarsten, Amritha Nambiar, stable, Jakub Kicinski,
David S. Miller, Eric Dumazet, Paolo Abeni, Sridhar Samudrala,
Stanislav Fomichev, Daniel Jurgens, open list
On Sat, Aug 31, 2024 at 12:17:04PM +0000, Joe Damato 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:
>
> $ ./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 <amritha.nambiar@intel.com>
> Cc: stable@kernel.org
> Suggested-by: Jakub Kicinski <kuba@kernel.org>
> Fixes: 27f91aaf49b3 ("netdev-genl: Add netlink framework functions for napi")
> Signed-off-by: Joe Damato <jdamato@fastly.com>
> ---
> net/core/netdev-genl.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c
> index 05f9515d2c05..a17d7eaeb001 100644
> --- a/net/core/netdev-genl.c
> +++ b/net/core/netdev-genl.c
> @@ -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();
>
> --
> 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/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] netdev-genl: Set extack and fix error on napi-get
2024-09-02 18:52 ` Joe Damato
@ 2024-09-03 1:28 ` Jakub Kicinski
0 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2024-09-03 1:28 UTC (permalink / raw)
To: Joe Damato
Cc: netdev, mkarsten, Amritha Nambiar, stable, David S. Miller,
Eric Dumazet, Paolo Abeni, Sridhar Samudrala, Stanislav Fomichev,
Daniel Jurgens, open list
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!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] netdev-genl: Set extack and fix error on napi-get
2024-08-31 12:17 [PATCH net] netdev-genl: Set extack and fix error on napi-get Joe Damato
2024-09-02 18:52 ` Joe Damato
@ 2024-09-03 1:40 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-09-03 1:40 UTC (permalink / raw)
To: Joe Damato
Cc: netdev, mkarsten, amritha.nambiar, stable, kuba, davem, edumazet,
pabeni, sridhar.samudrala, sdf, danielj, linux-kernel
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
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!
--
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-09-03 1:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-31 12:17 [PATCH net] netdev-genl: Set extack and fix error on napi-get Joe Damato
2024-09-02 18:52 ` Joe Damato
2024-09-03 1:28 ` Jakub Kicinski
2024-09-03 1:40 ` 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).