vxlan: use __dev_get_by_index instead of dev_get_by_index to find interface

The following call chains indicate that vxlan_fdb_parse() is
under rtnl_lock protection. So if we use __dev_get_by_index()
instead of dev_get_by_index() to find interface handler in it,
this would help us avoid to change interface reference counter.

rtnetlink_rcv()
  rtnl_lock()
  netlink_rcv_skb()
    rtnl_fdb_add()
      vxlan_fdb_add()
        vxlan_fdb_parse()
  rtnl_unlock()

rtnetlink_rcv()
  rtnl_lock()
  netlink_rcv_skb()
    rtnl_fdb_del()
      vxlan_fdb_del()
        vxlan_fdb_parse()
  rtnl_unlock()

Cc: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Ying Xue <ying.xue@windriver.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Ying Xue 2014-01-15 10:23:41 +08:00 committed by David S. Miller
parent d4c5fba2f6
commit 7376394930
1 changed files with 1 additions and 2 deletions

View File

@ -741,10 +741,9 @@ static int vxlan_fdb_parse(struct nlattr *tb[], struct vxlan_dev *vxlan,
if (nla_len(tb[NDA_IFINDEX]) != sizeof(u32)) if (nla_len(tb[NDA_IFINDEX]) != sizeof(u32))
return -EINVAL; return -EINVAL;
*ifindex = nla_get_u32(tb[NDA_IFINDEX]); *ifindex = nla_get_u32(tb[NDA_IFINDEX]);
tdev = dev_get_by_index(net, *ifindex); tdev = __dev_get_by_index(net, *ifindex);
if (!tdev) if (!tdev)
return -EADDRNOTAVAIL; return -EADDRNOTAVAIL;
dev_put(tdev);
} else { } else {
*ifindex = 0; *ifindex = 0;
} }