All of lore.kernel.org
 help / color / mirror / Atom feed
From: Veaceslav Falico <vfalico@redhat.com>
To: Ying Xue <ying.xue@windriver.com>
Cc: davem@davemloft.net, 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: Re: [PATCH net-next 02/10] bonding: use __dev_get_by_name instead of dev_get_by_name to find interface
Date: Tue, 14 Jan 2014 12:55:20 +0100	[thread overview]
Message-ID: <20140114115520.GH4132@redhat.com> (raw)
In-Reply-To: <1389685269-18600-3-git-send-email-ying.xue@windriver.com>

On Tue, Jan 14, 2014 at 03:41:01PM +0800, Ying Xue wrote:
>The following call chain indicates that bond_do_ioctl() is protected
>under rtnl_lock. If we use __dev_get_by_name() instead of
>dev_get_by_name() to find interface handler in it, this would
>help us avoid to change reference counter of interface once.
>
>dev_ioctl()
>  rtnl_lock()
>  dev_ifsioc()
>    bond_do_ioctl()
>  rtnl_unlock()
>
>Additionally we also change the coding style in bond_do_ioctl(),
>letting it more readable for us.
>
>Cc: Jay Vosburgh <fubar@us.ibm.com>
>Cc: Veaceslav Falico <vfalico@redhat.com>

Acked-by: Veaceslav Falico <vfalico@redhat.com>

>Signed-off-by: Ying Xue <ying.xue@windriver.com>
>---
> drivers/net/bonding/bond_main.c |   49 ++++++++++++++++++---------------------
> 1 file changed, 23 insertions(+), 26 deletions(-)
>
>diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
>index e06c445..a69afbf 100644
>--- a/drivers/net/bonding/bond_main.c
>+++ b/drivers/net/bonding/bond_main.c
>@@ -3213,37 +3213,34 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
> 	if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
> 		return -EPERM;
>
>-	slave_dev = dev_get_by_name(net, ifr->ifr_slave);
>+	slave_dev = __dev_get_by_name(net, ifr->ifr_slave);
>
> 	pr_debug("slave_dev=%p:\n", slave_dev);
>
> 	if (!slave_dev)
>-		res = -ENODEV;
>-	else {
>-		pr_debug("slave_dev->name=%s:\n", slave_dev->name);
>-		switch (cmd) {
>-		case BOND_ENSLAVE_OLD:
>-		case SIOCBONDENSLAVE:
>-			res = bond_enslave(bond_dev, slave_dev);
>-			break;
>-		case BOND_RELEASE_OLD:
>-		case SIOCBONDRELEASE:
>-			res = bond_release(bond_dev, slave_dev);
>-			break;
>-		case BOND_SETHWADDR_OLD:
>-		case SIOCBONDSETHWADDR:
>-			bond_set_dev_addr(bond_dev, slave_dev);
>-			res = 0;
>-			break;
>-		case BOND_CHANGE_ACTIVE_OLD:
>-		case SIOCBONDCHANGEACTIVE:
>-			res = bond_option_active_slave_set(bond, slave_dev);
>-			break;
>-		default:
>-			res = -EOPNOTSUPP;
>-		}
>+		return -ENODEV;
>
>-		dev_put(slave_dev);
>+	pr_debug("slave_dev->name=%s:\n", slave_dev->name);
>+	switch (cmd) {
>+	case BOND_ENSLAVE_OLD:
>+	case SIOCBONDENSLAVE:
>+		res = bond_enslave(bond_dev, slave_dev);
>+		break;
>+	case BOND_RELEASE_OLD:
>+	case SIOCBONDRELEASE:
>+		res = bond_release(bond_dev, slave_dev);
>+		break;
>+	case BOND_SETHWADDR_OLD:
>+	case SIOCBONDSETHWADDR:
>+		bond_set_dev_addr(bond_dev, slave_dev);
>+		res = 0;
>+		break;
>+	case BOND_CHANGE_ACTIVE_OLD:
>+	case SIOCBONDCHANGEACTIVE:
>+		res = bond_option_active_slave_set(bond, slave_dev);
>+		break;
>+	default:
>+		res = -EOPNOTSUPP;
> 	}
>
> 	return res;
>-- 
>1.7.9.5
>

  reply	other threads:[~2014-01-14 11:58 UTC|newest]

Thread overview: 18+ 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 [this message]
2014-01-14  7:41 ` [PATCH net-next 03/10] eql: " Ying Xue
2014-01-14  7:41 ` [PATCH net-next 04/10] dcb: " Ying Xue
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   ` [B.A.T.M.A.N.] " Antonio Quartulli
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=20140114115520.GH4132@redhat.com \
    --to=vfalico@redhat.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=ying.xue@windriver.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.