mbox series

[v3,net-next,00/10] rtnetlink: Convert rtnl_newlink() to per-netns RTNL.

Message ID 20241107022900.70287-1-kuniyu@amazon.com (mailing list archive)
Headers show
Series rtnetlink: Convert rtnl_newlink() to per-netns RTNL. | expand

Message

Kuniyuki Iwashima Nov. 7, 2024, 2:28 a.m. UTC
Patch 1 - 3 removes __rtnl_link_unregister() and protects link_ops by
its dedicated mutex to move synchronize_srcu() out of the RTNL scope.

Patch 4 introduces struct rtnl_nets and helper functions to acquire
multiple per-netns RTNL in rtnl_newlink().

Patch 5 - 8 are to prefetch the peer device's netns in rtnl_newlink().

Patch 9 converts rtnl_newlink() to per-netns RTNL.

Patch 10 pushes RTNL down to rtnl_dellink() and rtnl_setlink(), but
the conversion will not be completed unless we support cases with
peer/upper/lower devices.

I confirmed v3 survived ./rtnetlink.sh; rmmod netdevsim.ko; without
lockdep splat.


Changes:
  v3:
    * Add patch 1~3 to avoid SRCU & RTNL deadlock

  v2: https://lore.kernel.org/netdev/20241106022432.13065-1-kuniyu@amazon.com/
    * Patch 1
      * Move struct rtnl_nets to rtnetlink.c
      * Unexport rtnl_nets_add()
    * Patch 2
      * Rename the helper to rtnl_link_get_net_ifla()
      * Unexport rtnl_link_get_net_ifla()
      * Change peer_type to u16
    * Patch 6
      * Remove __rtnl_unlock() dance

  v1: https://lore.kernel.org/netdev/20241105020514.41963-1-kuniyu@amazon.com/


Kuniyuki Iwashima (10):
  rtnetlink: Remove __rtnl_link_unregister().
  rtnetlink: Protect link_ops by mutex.
  rtnetlink: Remove __rtnl_link_register()
  rtnetlink: Introduce struct rtnl_nets and helpers.
  rtnetlink: Add peer_type in struct rtnl_link_ops.
  veth: Set VETH_INFO_PEER to veth_link_ops.peer_type.
  vxcan: Set VXCAN_INFO_PEER to vxcan_link_ops.peer_type.
  netkit: Set IFLA_NETKIT_PEER_INFO to netkit_link_ops.peer_type.
  rtnetlink: Convert RTM_NEWLINK to per-netns RTNL.
  rtnetlink: Register rtnl_dellink() and rtnl_setlink() with
    RTNL_FLAG_DOIT_PERNET_WIP.

 drivers/net/can/vxcan.c  |  12 +-
 drivers/net/dummy.c      |  17 ++-
 drivers/net/ifb.c        |  17 ++-
 drivers/net/netkit.c     |  11 +-
 drivers/net/veth.c       |  18 +--
 include/net/rtnetlink.h  |   8 +-
 net/core/net_namespace.c |   1 -
 net/core/rtnetlink.c     | 257 ++++++++++++++++++++++++++++-----------
 8 files changed, 217 insertions(+), 124 deletions(-)

Comments

Jakub Kicinski Nov. 7, 2024, 11:53 p.m. UTC | #1
On Wed, 6 Nov 2024 18:28:50 -0800 Kuniyuki Iwashima wrote:
> Patch 5 - 8 are to prefetch the peer device's netns in rtnl_newlink().

Patch 5 did not make it to the list :(
Kuniyuki Iwashima Nov. 8, 2024, 12:02 a.m. UTC | #2
From: Jakub Kicinski <kuba@kernel.org>
Date: Thu, 7 Nov 2024 15:53:19 -0800
> On Wed, 6 Nov 2024 18:28:50 -0800 Kuniyuki Iwashima wrote:
> > Patch 5 - 8 are to prefetch the peer device's netns in rtnl_newlink().
> 
> Patch 5 did not make it to the list :(

Oh, I didn't notice that... thanks for the reminder !

It's in my gmail inbox at least, so probably something went
wrong on lore :S

Will resend v3.