diff options
author | Kuniyuki Iwashima <kuniyu@amazon.com> | 2024-11-07 16:48:17 -0800 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2024-11-11 17:26:51 -0800 |
commit | cbaaa6326bc58e75239df437a8fdcdb2335d3b24 (patch) | |
tree | 663d8dc9488a0c489a9aae4b4ae72560f1dc095f /net/psample | |
parent | 68297dbb967f87c3c92af9d2f652270f57c547c7 (diff) | |
download | lwn-cbaaa6326bc58e75239df437a8fdcdb2335d3b24.tar.gz lwn-cbaaa6326bc58e75239df437a8fdcdb2335d3b24.zip |
rtnetlink: Introduce struct rtnl_nets and helpers.
rtnl_newlink() needs to hold 3 per-netns RTNL: 2 for a new device
and 1 for its peer.
We will add rtnl_nets_lock() later, which performs the nested locking
based on struct rtnl_nets, which has an array of struct net pointers.
rtnl_nets_add() adds a net pointer to the array and sorts it so that
rtnl_nets_lock() can simply acquire per-netns RTNL from array[0] to [2].
Before calling rtnl_nets_add(), get_net() must be called for the net,
and rtnl_nets_destroy() will call put_net() for each.
Let's apply the helpers to rtnl_newlink().
When CONFIG_DEBUG_NET_SMALL_RTNL is disabled, we do not call
rtnl_net_lock() thus do not care about the array order, so
rtnl_net_cmp_locks() returns -1 so that the loop in rtnl_nets_add()
can be optimised to NOP.
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org>
Link: https://patch.msgid.link/20241108004823.29419-5-kuniyu@amazon.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net/psample')
0 files changed, 0 insertions, 0 deletions