]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
netdev: add "ops compat locking" helpers
authorJakub Kicinski <kuba@kernel.org>
Tue, 8 Apr 2025 19:59:50 +0000 (12:59 -0700)
committerJakub Kicinski <kuba@kernel.org>
Thu, 10 Apr 2025 00:01:51 +0000 (17:01 -0700)
commit4ec9031cbeb73a66979560bbb6d355329be762de
treed9b8ca8af45142eaa8db653f8ddac6ab8f96952e
parent606048cbd8346e616cfaee01b0143d072534136d
netdev: add "ops compat locking" helpers

Add helpers to "lock a netdev in a backward-compatible way",
which for ops-locked netdevs will mean take the instance lock.
For drivers which haven't opted into the ops locking we'll take
rtnl_lock.

The scoped foreach is dropping and re-taking the lock for each
device, even if prev and next are both under rtnl_lock.
I hope that's fine since we expect that netdev nl to be mostly
supported by modern drivers, and modern drivers should also
opt into the instance locking.

Note that these helpers are mostly needed for queue related state,
because drivers modify queue config in their ops in a non-atomic
way. Or differently put, queue changes don't have a clear-cut API
like NAPI configuration. Any state that can should just use the
instance lock directly, not the "compat" hacks.

Reviewed-by: Joe Damato <jdamato@fastly.com>
Acked-by: Stanislav Fomichev <sdf@fomichev.me>
Link: https://patch.msgid.link/20250408195956.412733-4-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/net/netdev_lock.h
net/core/dev.c
net/core/dev.h