mirror of
https://github.com/raspberrypi/linux.git
synced 2026-01-04 18:27:36 +00:00
net: protect netdev->napi_list with netdev_lock()
Hold netdev->lock when NAPIs are getting added or removed. This will allow safe access to NAPI instances of a net_device without rtnl_lock. Create a family of helpers which assume the lock is already taken. Switch iavf to them, as it makes extensive use of netdev->lock, already. Reviewed-by: Joe Damato <jdamato@fastly.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com> Link: https://patch.msgid.link/20250115035319.559603-6-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
@@ -6910,9 +6910,12 @@ netif_napi_dev_list_add(struct net_device *dev, struct napi_struct *napi)
|
||||
list_add_rcu(&napi->dev_list, higher); /* adds after higher */
|
||||
}
|
||||
|
||||
void netif_napi_add_weight(struct net_device *dev, struct napi_struct *napi,
|
||||
int (*poll)(struct napi_struct *, int), int weight)
|
||||
void netif_napi_add_weight_locked(struct net_device *dev,
|
||||
struct napi_struct *napi,
|
||||
int (*poll)(struct napi_struct *, int),
|
||||
int weight)
|
||||
{
|
||||
netdev_assert_locked(dev);
|
||||
if (WARN_ON(test_and_set_bit(NAPI_STATE_LISTED, &napi->state)))
|
||||
return;
|
||||
|
||||
@@ -6953,7 +6956,7 @@ void netif_napi_add_weight(struct net_device *dev, struct napi_struct *napi,
|
||||
dev->threaded = false;
|
||||
netif_napi_set_irq(napi, -1);
|
||||
}
|
||||
EXPORT_SYMBOL(netif_napi_add_weight);
|
||||
EXPORT_SYMBOL(netif_napi_add_weight_locked);
|
||||
|
||||
void napi_disable(struct napi_struct *n)
|
||||
{
|
||||
@@ -7024,8 +7027,10 @@ static void flush_gro_hash(struct napi_struct *napi)
|
||||
}
|
||||
|
||||
/* Must be called in process context */
|
||||
void __netif_napi_del(struct napi_struct *napi)
|
||||
void __netif_napi_del_locked(struct napi_struct *napi)
|
||||
{
|
||||
netdev_assert_locked(napi->dev);
|
||||
|
||||
if (!test_and_clear_bit(NAPI_STATE_LISTED, &napi->state))
|
||||
return;
|
||||
|
||||
@@ -7045,7 +7050,7 @@ void __netif_napi_del(struct napi_struct *napi)
|
||||
napi->thread = NULL;
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL(__netif_napi_del);
|
||||
EXPORT_SYMBOL(__netif_napi_del_locked);
|
||||
|
||||
static int __napi_poll(struct napi_struct *n, bool *repoll)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user