Commit 5df1341e authored by Chuang Wang's avatar Chuang Wang Committed by David S. Miller

net: macvlan: Use built-in RCU list checking

hlist_for_each_entry_rcu() has built-in RCU and lock checking.

Pass cond argument to hlist_for_each_entry_rcu() to silence false
lockdep warning when CONFIG_PROVE_RCU_LIST is enabled.

Execute as follow:

 ip link add link eth0 type macvlan mode source macaddr add <MAC-ADDR>

The rtnl_lock is held when macvlan_hash_lookup_source() or
macvlan_fill_info_macaddr() are called in the non-RCU read side section.
So, pass lockdep_rtnl_is_held() to silence false lockdep warning.

Fixes: 79cf79ab ("macvlan: add source mode")
Signed-off-by: default avatarChuang Wang <nashuiliang@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2d25107e
...@@ -141,7 +141,7 @@ static struct macvlan_source_entry *macvlan_hash_lookup_source( ...@@ -141,7 +141,7 @@ static struct macvlan_source_entry *macvlan_hash_lookup_source(
u32 idx = macvlan_eth_hash(addr); u32 idx = macvlan_eth_hash(addr);
struct hlist_head *h = &vlan->port->vlan_source_hash[idx]; struct hlist_head *h = &vlan->port->vlan_source_hash[idx];
hlist_for_each_entry_rcu(entry, h, hlist) { hlist_for_each_entry_rcu(entry, h, hlist, lockdep_rtnl_is_held()) {
if (ether_addr_equal_64bits(entry->addr, addr) && if (ether_addr_equal_64bits(entry->addr, addr) &&
entry->vlan == vlan) entry->vlan == vlan)
return entry; return entry;
...@@ -1647,7 +1647,7 @@ static int macvlan_fill_info_macaddr(struct sk_buff *skb, ...@@ -1647,7 +1647,7 @@ static int macvlan_fill_info_macaddr(struct sk_buff *skb,
struct hlist_head *h = &vlan->port->vlan_source_hash[i]; struct hlist_head *h = &vlan->port->vlan_source_hash[i];
struct macvlan_source_entry *entry; struct macvlan_source_entry *entry;
hlist_for_each_entry_rcu(entry, h, hlist) { hlist_for_each_entry_rcu(entry, h, hlist, lockdep_rtnl_is_held()) {
if (entry->vlan != vlan) if (entry->vlan != vlan)
continue; continue;
if (nla_put(skb, IFLA_MACVLAN_MACADDR, ETH_ALEN, entry->addr)) if (nla_put(skb, IFLA_MACVLAN_MACADDR, ETH_ALEN, entry->addr))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment