diff mbox series

[net-next] netns: no longer hold RTNL in rtnl_net_dumpid()

Message ID 20240416140739.967941-1-edumazet@google.com (mailing list archive)
State Accepted
Commit 1514b06aff1681a418089060f0ebe936c27481bc
Delegated to: Netdev Maintainers
Headers show
Series [net-next] netns: no longer hold RTNL in rtnl_net_dumpid() | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 928 this patch: 928
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 2 maintainers not CCed: lixiaoyan@google.com viro@zeniv.linux.org.uk
netdev/build_clang success Errors and warnings before: 938 this patch: 938
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 No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 939 this patch: 939
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 17 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 3 this patch: 3
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-04-18--00-00 (tests: 961)

Commit Message

Eric Dumazet April 16, 2024, 2:07 p.m. UTC
- rtnl_net_dumpid() is already fully RCU protected,
  RTNL is not needed there.

- Fix return value at the end of a dump,
  so that NLMSG_DONE can be appended to current skb,
  saving one recvmsg() system call.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Guillaume Nault <gnault@redhat.com>
---
 net/core/net_namespace.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Guillaume Nault April 17, 2024, 10:37 a.m. UTC | #1
On Tue, Apr 16, 2024 at 02:07:39PM +0000, Eric Dumazet wrote:
> - rtnl_net_dumpid() is already fully RCU protected,
>   RTNL is not needed there.
> 
> - Fix return value at the end of a dump,
>   so that NLMSG_DONE can be appended to current skb,
>   saving one recvmsg() system call.

Reviewed-by: Guillaume Nault <gnault@redhat.com>
patchwork-bot+netdevbpf@kernel.org April 18, 2024, 1:40 a.m. UTC | #2
Hello:

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

On Tue, 16 Apr 2024 14:07:39 +0000 you wrote:
> - rtnl_net_dumpid() is already fully RCU protected,
>   RTNL is not needed there.
> 
> - Fix return value at the end of a dump,
>   so that NLMSG_DONE can be appended to current skb,
>   saving one recvmsg() system call.
> 
> [...]

Here is the summary with links:
  - [net-next] netns: no longer hold RTNL in rtnl_net_dumpid()
    https://git.kernel.org/netdev/net-next/c/1514b06aff16

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index f0540c5575157135b1dc5dece2220f81a408fb7e..2f5190aa2f15cec2e934ebee9c502fb426cf0d7d 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -1090,7 +1090,7 @@  static int rtnl_net_dumpid(struct sk_buff *skb, struct netlink_callback *cb)
 end:
 	if (net_cb.fillargs.add_ref)
 		put_net(net_cb.tgt_net);
-	return err < 0 ? err : skb->len;
+	return err;
 }
 
 static void rtnl_net_notifyid(struct net *net, int cmd, int id, u32 portid,
@@ -1205,7 +1205,8 @@  void __init net_ns_init(void)
 	rtnl_register(PF_UNSPEC, RTM_NEWNSID, rtnl_net_newid, NULL,
 		      RTNL_FLAG_DOIT_UNLOCKED);
 	rtnl_register(PF_UNSPEC, RTM_GETNSID, rtnl_net_getid, rtnl_net_dumpid,
-		      RTNL_FLAG_DOIT_UNLOCKED);
+		      RTNL_FLAG_DOIT_UNLOCKED |
+		      RTNL_FLAG_DUMP_UNLOCKED);
 }
 
 static void free_exit_list(struct pernet_operations *ops, struct list_head *net_exit_list)