提交 d9ac62be 编写于 作者: Y Ying Xue 提交者: David S. Miller

dcb: use __dev_get_by_name instead of dev_get_by_name to find interface

The following call chain indicates that dcb_doit() is protected
under rtnl_lock. So if we use __dev_get_by_name() instead of
dev_get_by_name() to find interface handlers in it, this would
help us avoid to change interface reference counter.

rtnetlink_rcv()
  rtnl_lock()
  netlink_rcv_skb()
    dcb_doit()
  rtnl_unlock()

Cc: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: NYing Xue <ying.xue@windriver.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 ebd93a7d
...@@ -1688,21 +1688,17 @@ static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh) ...@@ -1688,21 +1688,17 @@ static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh)
if (!tb[DCB_ATTR_IFNAME]) if (!tb[DCB_ATTR_IFNAME])
return -EINVAL; return -EINVAL;
netdev = dev_get_by_name(net, nla_data(tb[DCB_ATTR_IFNAME])); netdev = __dev_get_by_name(net, nla_data(tb[DCB_ATTR_IFNAME]));
if (!netdev) if (!netdev)
return -ENODEV; return -ENODEV;
if (!netdev->dcbnl_ops) { if (!netdev->dcbnl_ops)
ret = -EOPNOTSUPP; return -EOPNOTSUPP;
goto out;
}
reply_skb = dcbnl_newmsg(fn->type, dcb->cmd, portid, nlh->nlmsg_seq, reply_skb = dcbnl_newmsg(fn->type, dcb->cmd, portid, nlh->nlmsg_seq,
nlh->nlmsg_flags, &reply_nlh); nlh->nlmsg_flags, &reply_nlh);
if (!reply_skb) { if (!reply_skb)
ret = -ENOBUFS; return -ENOBUFS;
goto out;
}
ret = fn->cb(netdev, nlh, nlh->nlmsg_seq, tb, reply_skb); ret = fn->cb(netdev, nlh, nlh->nlmsg_seq, tb, reply_skb);
if (ret < 0) { if (ret < 0) {
...@@ -1714,7 +1710,6 @@ static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh) ...@@ -1714,7 +1710,6 @@ static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh)
ret = rtnl_unicast(reply_skb, net, portid); ret = rtnl_unicast(reply_skb, net, portid);
out: out:
dev_put(netdev);
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册