summaryrefslogtreecommitdiff
path: root/net/core/dev.c
diff options
context:
space:
mode:
authorKuniyuki Iwashima <kuniyu@google.com>2025-07-11 05:10:59 +0000
committerJakub Kicinski <kuba@kernel.org>2025-07-14 17:11:14 -0700
commit2a683d005286018c6f47ef0e432829655a6a21a3 (patch)
tree03dda37cbd079dd814f9b269fec9d4e648b5f40f /net/core/dev.c
parentf25a7eaa897f21396e99f90809af82ca553c9d14 (diff)
dev: Pass netdevice_tracker to dev_get_by_flags_rcu().
This is a follow-up for commit eb1ac9ff6c4a5 ("ipv6: anycast: Don't hold RTNL for IPV6_JOIN_ANYCAST."). We should not add a new device lookup API without netdevice_tracker. Let's pass netdevice_tracker to dev_get_by_flags_rcu() and rename it with netdev_ prefix to match other newer APIs. Note that we always use GFP_ATOMIC for netdev_hold() as it's expected to be called under RCU. Suggested-by: Jakub Kicinski <kuba@kernel.org> Link: https://lore.kernel.org/netdev/20250708184053.102109f6@kernel.org/ Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/20250711051120.2866855-1-kuniyu@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net/core/dev.c')
-rw-r--r--net/core/dev.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index e365b099484e..19ddc3e6990a 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1267,8 +1267,9 @@ struct net_device *dev_getfirstbyhwtype(struct net *net, unsigned short type)
EXPORT_SYMBOL(dev_getfirstbyhwtype);
/**
- * dev_get_by_flags_rcu - find any device with given flags
+ * netdev_get_by_flags_rcu - find any device with given flags
* @net: the applicable net namespace
+ * @tracker: tracking object for the acquired reference
* @if_flags: IFF_* values
* @mask: bitmask of bits in if_flags to check
*
@@ -1277,21 +1278,21 @@ EXPORT_SYMBOL(dev_getfirstbyhwtype);
* Context: rcu_read_lock() must be held.
* Returns: NULL if a device is not found or a pointer to the device.
*/
-struct net_device *dev_get_by_flags_rcu(struct net *net, unsigned short if_flags,
- unsigned short mask)
+struct net_device *netdev_get_by_flags_rcu(struct net *net, netdevice_tracker *tracker,
+ unsigned short if_flags, unsigned short mask)
{
struct net_device *dev;
for_each_netdev_rcu(net, dev) {
if (((READ_ONCE(dev->flags) ^ if_flags) & mask) == 0) {
- dev_hold(dev);
+ netdev_hold(dev, tracker, GFP_ATOMIC);
return dev;
}
}
return NULL;
}
-EXPORT_IPV6_MOD(dev_get_by_flags_rcu);
+EXPORT_IPV6_MOD(netdev_get_by_flags_rcu);
/**
* dev_valid_name - check if name is okay for network device