Skip to content

Commit 2429f7a

Browse files
Jiri Pirkodavem330
authored andcommitted
net: introduce netif_addr_lock_nested() and call if when appropriate
dev_uc_sync() and dev_mc_sync() are acquiring netif_addr_lock for destination device of synchronization. Since netif_addr_lock is already held at the time for source device, this triggers lockdep deadlock warning. There's no way this deadlock can happen so use spin_lock_nested() to silence the warning. Signed-off-by: Jiri Pirko <jpirko@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent ab16ebf commit 2429f7a

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

‎include/linux/netdevice.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2450,6 +2450,11 @@ static inline void netif_addr_lock(struct net_device *dev)
24502450
spin_lock(&dev->addr_list_lock);
24512451
}
24522452

2453+
static inline void netif_addr_lock_nested(struct net_device *dev)
2454+
{
2455+
spin_lock_nested(&dev->addr_list_lock, SINGLE_DEPTH_NESTING);
2456+
}
2457+
24532458
static inline void netif_addr_lock_bh(struct net_device *dev)
24542459
{
24552460
spin_lock_bh(&dev->addr_list_lock);

‎net/core/dev_addr_lists.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -439,11 +439,11 @@ int dev_uc_sync(struct net_device *to, struct net_device *from)
439439
if (to->addr_len != from->addr_len)
440440
return -EINVAL;
441441

442-
netif_addr_lock_bh(to);
442+
netif_addr_lock_nested(to);
443443
err = __hw_addr_sync(&to->uc, &from->uc, to->addr_len);
444444
if (!err)
445445
__dev_set_rx_mode(to);
446-
netif_addr_unlock_bh(to);
446+
netif_addr_unlock(to);
447447
return err;
448448
}
449449
EXPORT_SYMBOL(dev_uc_sync);
@@ -463,7 +463,7 @@ void dev_uc_unsync(struct net_device *to, struct net_device *from)
463463
return;
464464

465465
netif_addr_lock_bh(from);
466-
netif_addr_lock(to);
466+
netif_addr_lock_nested(to);
467467
__hw_addr_unsync(&to->uc, &from->uc, to->addr_len);
468468
__dev_set_rx_mode(to);
469469
netif_addr_unlock(to);
@@ -602,11 +602,11 @@ int dev_mc_sync(struct net_device *to, struct net_device *from)
602602
if (to->addr_len != from->addr_len)
603603
return -EINVAL;
604604

605-
netif_addr_lock_bh(to);
605+
netif_addr_lock_nested(to);
606606
err = __hw_addr_sync(&to->mc, &from->mc, to->addr_len);
607607
if (!err)
608608
__dev_set_rx_mode(to);
609-
netif_addr_unlock_bh(to);
609+
netif_addr_unlock(to);
610610
return err;
611611
}
612612
EXPORT_SYMBOL(dev_mc_sync);
@@ -626,7 +626,7 @@ void dev_mc_unsync(struct net_device *to, struct net_device *from)
626626
return;
627627

628628
netif_addr_lock_bh(from);
629-
netif_addr_lock(to);
629+
netif_addr_lock_nested(to);
630630
__hw_addr_unsync(&to->mc, &from->mc, to->addr_len);
631631
__dev_set_rx_mode(to);
632632
netif_addr_unlock(to);

0 commit comments

Comments
 (0)