Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: devlink: remove redundant rtnl lock assert

It is enough for caller of devlink_compat_switch_id_get() to hold the net
device to guarantee that devlink port is not destroyed concurrently. Remove
rtnl lock assertion and modify comment to warn user that they must hold
either rtnl lock or reference to net device. This is necessary to
accommodate future implementation of rtnl-unlocked TC offloads driver
callbacks.

Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>

authored by

Vlad Buslov and committed by
Jakub Kicinski
043b8413 708852dc

+2 -3
+2 -3
net/core/devlink.c
··· 6939 6939 { 6940 6940 struct devlink_port *devlink_port; 6941 6941 6942 - /* RTNL mutex is held here which ensures that devlink_port 6943 - * instance cannot disappear in the middle. No need to take 6942 + /* Caller must hold RTNL mutex or reference to dev, which ensures that 6943 + * devlink_port instance cannot disappear in the middle. No need to take 6944 6944 * any devlink lock as only permanent values are accessed. 6945 6945 */ 6946 - ASSERT_RTNL(); 6947 6946 devlink_port = netdev_to_devlink_port(dev); 6948 6947 if (!devlink_port || !devlink_port->attrs.switch_port) 6949 6948 return -EOPNOTSUPP;