summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Kicinski <kuba@kernel.org>2026-06-04 17:29:07 -0700
committerJakub Kicinski <kuba@kernel.org>2026-06-09 10:13:05 -0700
commit0c334c21f5a599b593a3495031cfcefb9fc47b96 (patch)
treee6e6d7b234249a0bb432c99232557eb034e571a2
parentf16013fde46d38e1a79216976445e1cd79922a72 (diff)
downloadlinux-next-0c334c21f5a599b593a3495031cfcefb9fc47b96.tar.gz
linux-next-0c334c21f5a599b593a3495031cfcefb9fc47b96.zip
net: ethtool: optionally skip rtnl_lock in ethnl_tsinfo_dumpit()
ethnl_tsinfo_dumpit() iterates netdevs and per-netdev PHY topology calling ops->get_ts_info(). Switch to the "ops compat locking" helpers which take either rtnl_lock or instance lock, depending on what the device needs. Reviewed-by: Eric Dumazet <edumazet@google.com> Acked-by: Stanislav Fomichev <sdf@fomichev.me> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> Link: https://patch.msgid.link/20260605002912.3456868-8-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
-rw-r--r--net/ethtool/tsinfo.c32
1 files changed, 15 insertions, 17 deletions
diff --git a/net/ethtool/tsinfo.c b/net/ethtool/tsinfo.c
index 14bf01e3b55c..c9b680a9cc3f 100644
--- a/net/ethtool/tsinfo.c
+++ b/net/ethtool/tsinfo.c
@@ -6,6 +6,7 @@
#include <linux/ptp_clock_kernel.h>
#include <net/netdev_lock.h>
+#include "../core/dev.h"
#include "bitset.h"
#include "common.h"
#include "netlink.h"
@@ -473,28 +474,25 @@ int ethnl_tsinfo_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
{
struct ethnl_tsinfo_dump_ctx *ctx = (void *)cb->ctx;
struct net *net = sock_net(skb->sk);
- struct net_device *dev;
int ret = 0;
- rtnl_lock();
if (ctx->req_info->base.dev) {
- dev = ctx->req_info->base.dev;
- netdev_lock_ops(dev);
+ struct net_device *dev = ctx->req_info->base.dev;
+
+ netdev_lock_ops_compat(dev);
ret = ethnl_tsinfo_dump_one_net_topo(skb, dev, cb);
- netdev_unlock_ops(dev);
- } else {
- for_each_netdev_dump(net, dev, ctx->pos_ifindex) {
- netdev_lock_ops(dev);
- ret = ethnl_tsinfo_dump_one_net_topo(skb, dev, cb);
- netdev_unlock_ops(dev);
- if (ret < 0 && ret != -EOPNOTSUPP)
- break;
- ctx->pos_phyindex = 0;
- ctx->netdev_dump_done = false;
- ctx->pos_phcqualifier = HWTSTAMP_PROVIDER_QUALIFIER_PRECISE;
- }
+ netdev_unlock_ops_compat(dev);
+ return ret;
+ }
+
+ for_each_netdev_lock_ops_compat_scoped(net, dev, ctx->pos_ifindex) {
+ ret = ethnl_tsinfo_dump_one_net_topo(skb, dev, cb);
+ if (ret < 0 && ret != -EOPNOTSUPP)
+ break;
+ ctx->pos_phyindex = 0;
+ ctx->netdev_dump_done = false;
+ ctx->pos_phcqualifier = HWTSTAMP_PROVIDER_QUALIFIER_PRECISE;
}
- rtnl_unlock();
return ret;
}