Q Qiliang Yuan #
Message details and related content
Moving a device to another netns waits in rcu_barrier() with RTNL held. Container and sandbox managers move one end of a veth pair for every new network namespace, so this barrier limits how fast such namespaces can be created on the whole system, to under 80 per second in a 4 vCPU guest however many threads create them. The barrier was added for NETDEV_UNREGISTER_FINAL, which is long gone, but it still keeps cached IPv4 routes through the moved device from being accepted in the old netns, and it lets the RCU callbacks of the nexthops removed with the device flush their IPv6 route exceptions before the move. Routes through nexthop objects are not fully covered by it: their cached dst entries are released by an RCU callback queued from another RCU callback, so a socket in the old netns can still send through a device that now belongs to another netns whenever the route generation numbers of the two netns happen to match. Patches 1 and 2 draw the IPv4 rt_genid and the IPv6 fib6_sernum bumps from sequences shared by all netns, so a cached route no longer matches another netns. Patch 3 flushes the cached routes of a nexthop group when one of its members is removed, instead of leaving the IPv6 exceptions through that member valid until it is freed. With these, nothing relies on the barrier, and patch 4 removes it. Patches 1 to 3 fix bugs that exist today and can go to net on their own if preferred. Without patch 3, removing the barrier lets a socket keep sending through a moved device that carries no IPv6 address and is a member of a nexthop group, until its exceptions are flushed. Datagrams a socket in netns A sent through such a device after it moved to netns B, 10 trials: patches 1, 2, 4 patches 1-4 datagrams 561-6525 0 Creating 400 netns, each with a veth pair whose host end is moved back to the initial netns, a tap device, addresses and routes, in a 4 vCPU guest, median of 5 runs: before after 1 thread 46 /s 56 /s 4 threads 58 /s 84 /s 16 threads 75 /s 146 /s