Skip to content

Commit

Permalink
net: explain the lockdep annotations for dev_uc_unsync()
Browse files Browse the repository at this point in the history
The lockdep annotations for dev_uc_unsync() and dev_mc_unsync()
are not easy to understand, so add some comments to explain
why they are correct.

Similar for the rest netif_addr_lock_bh() cases, they don't
need nested version.

Cc: Taehee Yoo <ap420073@gmail.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
congwang authored and davem330 committed Jun 29, 2020
1 parent be74294 commit e828033
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions net/core/dev_addr_lists.c
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,15 @@ void dev_uc_unsync(struct net_device *to, struct net_device *from)
if (to->addr_len != from->addr_len)
return;

/* netif_addr_lock_bh() uses lockdep subclass 0, this is okay for two
* reasons:
* 1) This is always called without any addr_list_lock, so as the
* outermost one here, it must be 0.
* 2) This is called by some callers after unlinking the upper device,
* so the dev->lower_level becomes 1 again.
* Therefore, the subclass for 'from' is 0, for 'to' is either 1 or
* larger.
*/
netif_addr_lock_bh(from);
netif_addr_lock_nested(to);
__hw_addr_unsync(&to->uc, &from->uc, to->addr_len);
Expand Down Expand Up @@ -911,6 +920,7 @@ void dev_mc_unsync(struct net_device *to, struct net_device *from)
if (to->addr_len != from->addr_len)
return;

/* See the above comments inside dev_uc_unsync(). */
netif_addr_lock_bh(from);
netif_addr_lock_nested(to);
__hw_addr_unsync(&to->mc, &from->mc, to->addr_len);
Expand Down

0 comments on commit e828033

Please sign in to comment.