From: Ying Xue <ying.xue@windriver.com>
To: <davem@davemloft.net>
Cc: <vfalico@redhat.com>, <john.r.fastabend@intel.com>,
<stephen@networkplumber.org>, <antonio@meshcoding.com>,
<dmitry.tarnyagin@lockless.no>, <socketcan@hartkopp.net>,
<johannes@sipsolutions.net>, <netdev@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: [PATCH net-next 04/10] dcb: use __dev_get_by_name instead of dev_get_by_name to find interface
Date: Tue, 14 Jan 2014 15:41:03 +0800 [thread overview]
Message-ID: <1389685269-18600-5-git-send-email-ying.xue@windriver.com> (raw)
In-Reply-To: <1389685269-18600-1-git-send-email-ying.xue@windriver.com>
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: Ying Xue <ying.xue@windriver.com>
---
net/dcb/dcbnl.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index 66fbe19..5536444 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -1688,21 +1688,17 @@ static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh)
if (!tb[DCB_ATTR_IFNAME])
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)
return -ENODEV;
- if (!netdev->dcbnl_ops) {
- ret = -EOPNOTSUPP;
- goto out;
- }
+ if (!netdev->dcbnl_ops)
+ return -EOPNOTSUPP;
reply_skb = dcbnl_newmsg(fn->type, dcb->cmd, portid, nlh->nlmsg_seq,
nlh->nlmsg_flags, &reply_nlh);
- if (!reply_skb) {
- ret = -ENOBUFS;
- goto out;
- }
+ if (!reply_skb)
+ return -ENOBUFS;
ret = fn->cb(netdev, nlh, nlh->nlmsg_seq, tb, reply_skb);
if (ret < 0) {
@@ -1714,7 +1710,6 @@ static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh)
ret = rtnl_unicast(reply_skb, net, portid);
out:
- dev_put(netdev);
return ret;
}
--
1.7.9.5
next prev parent reply other threads:[~2014-01-14 7:41 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-14 7:40 [PATCH net-next 00/10] use appropriate APIs to get interfaces Ying Xue
2014-01-14 7:41 ` [PATCH net-next 01/10] Drivers: Staging: cxt1e1: use __dev_get_name instead of dev_get_name to find interfaces Ying Xue
2014-01-14 7:41 ` [PATCH net-next 02/10] bonding: use __dev_get_by_name instead of dev_get_by_name to find interface Ying Xue
2014-01-14 11:55 ` Veaceslav Falico
2014-01-14 7:41 ` [PATCH net-next 03/10] eql: " Ying Xue
2014-01-14 7:41 ` Ying Xue [this message]
2014-01-14 7:41 ` [PATCH net-next 05/10] decnet: use __dev_get_by_index instead of dev_get_by_index " Ying Xue
2014-01-14 7:41 ` [PATCH net-next 06/10] vxlan: " Ying Xue
2014-01-14 16:51 ` Stephen Hemminger
2014-01-14 7:41 ` [PATCH net-next 07/10] batman-adv: " Ying Xue
2014-01-14 12:43 ` Antonio Quartulli
2014-01-14 7:41 ` [PATCH net-next 08/10] caif: " Ying Xue
2014-01-14 7:41 ` [PATCH net-next 09/10] can: use " Ying Xue
2014-01-14 16:11 ` Oliver Hartkopp
2014-01-14 7:41 ` [PATCH net-next 10/10] net: nl80211: " Ying Xue
2014-01-14 12:11 ` Johannes Berg
2014-01-15 1:18 ` Ying Xue
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1389685269-18600-5-git-send-email-ying.xue@windriver.com \
--to=ying.xue@windriver.com \
--cc=antonio@meshcoding.com \
--cc=davem@davemloft.net \
--cc=dmitry.tarnyagin@lockless.no \
--cc=johannes@sipsolutions.net \
--cc=john.r.fastabend@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=socketcan@hartkopp.net \
--cc=stephen@networkplumber.org \
--cc=vfalico@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).