summaryrefslogtreecommitdiff
path: root/net/core
diff options
context:
space:
mode:
authorEdward Cree <ecree.xilinx@gmail.com>2024-06-27 18:33:51 +0300
committerJakub Kicinski <kuba@kernel.org>2024-06-29 04:53:21 +0300
commit87925151191b64d9623e63ccf11e517eacc99d7d (patch)
tree4e4c6614bd25cbc859f6f870a517085a3c63318e /net/core
parent30a32cdf6b130356805b3193a6208de25cbb2015 (diff)
downloadlinux-87925151191b64d9623e63ccf11e517eacc99d7d.tar.xz
net: ethtool: add a mutex protecting RSS contexts
While this is not needed to serialise the ethtool entry points (which are all under RTNL), drivers may have cause to asynchronously access dev->ethtool->rss_ctx; taking dev->ethtool->rss_lock allows them to do this safely without needing to take the RTNL. Signed-off-by: Edward Cree <ecree.xilinx@gmail.com> Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com> Link: https://patch.msgid.link/7f9c15eb7525bf87af62c275dde3a8570ee8bf0a.1719502240.git.ecree.xilinx@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/dev.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index 2daed4464c08..385c4091aa77 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -10338,6 +10338,7 @@ int register_netdevice(struct net_device *dev)
/* rss ctx ID 0 is reserved for the default context, start from 1 */
xa_init_flags(&dev->ethtool->rss_ctx, XA_FLAGS_ALLOC1);
+ mutex_init(&dev->ethtool->rss_lock);
spin_lock_init(&dev->addr_list_lock);
netdev_set_addr_lockdep_class(dev);
@@ -11243,6 +11244,7 @@ static void netdev_rss_contexts_free(struct net_device *dev)
struct ethtool_rxfh_context *ctx;
unsigned long context;
+ mutex_lock(&dev->ethtool->rss_lock);
xa_for_each(&dev->ethtool->rss_ctx, context, ctx) {
struct ethtool_rxfh_param rxfh;
@@ -11262,6 +11264,7 @@ static void netdev_rss_contexts_free(struct net_device *dev)
kfree(ctx);
}
xa_destroy(&dev->ethtool->rss_ctx);
+ mutex_unlock(&dev->ethtool->rss_lock);
}
/**
@@ -11374,6 +11377,8 @@ void unregister_netdevice_many_notify(struct list_head *head,
if (dev->netdev_ops->ndo_uninit)
dev->netdev_ops->ndo_uninit(dev);
+ mutex_destroy(&dev->ethtool->rss_lock);
+
if (skb)
rtmsg_ifinfo_send(skb, dev, GFP_KERNEL, portid, nlh);