freenode
Kernel & Low-Level

Linux neighbour tables become per-network-namespace

ARP and ND tables move out of the global scope, so each netns can tune neighbour defaults and control paths need less global locking.

Kuniyuki Iwashima has submitted work for net-next that turns the kernel's global ARP and IPv6 neighbour discovery tables into per-network-namespace tables. The neighbour subsystem was already close to dropping the RTNL for control paths, but those paths still contended on a single per-table lock. Namespacing the tables is the step that breaks that global choke point.

The practical user-visible win is sysctl. Paths under /proc/sys/net/ipv4/neigh/default/ and the IPv6 counterpart were effectively global: only init_net could set them. After this change, each netns gets its own defaults and garbage-collection parameters, and RTM_SETNEIGHTBL can adjust the default table and GC knobs per namespace.

To limit surprise for existing setups, new namespaces inherit those defaults from init_net. A new core sysctl, net.core.neigh_inherit_init_net, controls that. It is on by default; turning it off gives a fresh netns the stock neighbour parameters instead of whatever init_net was using.

The conversion also cleans up leftover global assumptions: proxy neighbour entries no longer carry a net pointer, several obsolete exports and RCU protections around the old global table list go away, and table lifetime is tied to a refcount so a namespace can tear down without racing neighbour timers. A few drivers that still touch the IPv6 table without checking whether IPv6 is disabled keep a compatibility path for now.

For operators running many netns or containers, neighbour GC thresholds and related tunables stop being a machine-wide compromise. For the networking stack, the series is another concrete move toward lighter locking on neighbour add and delete.