From: Jiri Pirko <jiri@resnulli.us>
To: Ben Hutchings <bhutchings@solarflare.com>
Cc: bridge@lists.linux-foundation.org, ursula.braun@de.ibm.com,
john.r.fastabend@intel.com, edumazet@google.com,
shemminger@vyatta.com, sean.hefty@intel.com, therbert@google.com,
roland@kernel.org, linux-s390@vger.kernel.org,
linux-rdma@vger.kernel.org, fubar@us.ibm.com, fbl@redhat.com,
hal.rosenstock@gmail.com, faisal.latif@intel.com,
linux-driver@qlogic.com, blaschka@linux.vnet.ibm.com,
sony.chacko@qlogic.com, gregory.v.rose@intel.com,
xiyou.wangcong@gmail.com, jitendra.kalsaria@qlogic.com,
divy@chelsio.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, kaber@trash.net, joe@perches.com,
linux390@de.ibm.com, davem@davemloft.net
Subject: Re: [Bridge] [patch net-next 01/16] net: introduce upper device lists
Date: Mon, 13 Aug 2012 17:31:17 -0000 [thread overview]
Message-ID: <20120813173110.GA1808@minipsycho.orion> (raw)
In-Reply-To: <1344877451.2733.26.camel@bwh-desktop.uk.solarflarecom.com>
Mon, Aug 13, 2012 at 07:04:11PM CEST, bhutchings@solarflare.com wrote:
>On Mon, 2012-08-13 at 17:27 +0200, Jiri Pirko wrote:
>> This lists are supposed to serve for storing pointers to all upper devices.
>> Eventually it will replace dev->master pointer which is used for
>> bonding, bridge, team but it cannot be used for vlan, macvlan where
>> there might be multiple "masters" present.
>>
>> New upper device list resolves this limitation. Also, the information
>> stored in lists is used for preventing looping setups like
>> "bond->somethingelse->samebond"
>>
>> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
>[...]
>> --- a/net/core/dev.c
>> +++ b/net/core/dev.c
>> @@ -4425,6 +4425,229 @@ static int __init dev_proc_init(void)
>> #endif /* CONFIG_PROC_FS */
>>
>>
>> +struct netdev_upper {
>> + struct net_device *dev;
>> + bool unique;
>
>This needs a better name. It doesn't really have anything to do with
>uniqueness and doesn't ensure exclusivity. I think that it would be
>fine to keep the 'master' term.
Hmm. I admit that "unique" I do not like too much as well. But "master"
I like even less.
This flag should ensure exclusivity. Only one upper device with this
flag can be present at a time.
>
>> + struct list_head list;
>> + struct rcu_head rcu;
>> +};
>[...]
>> +static int __netdev_upper_dev_link(struct net_device *dev,
>> + struct net_device *upper_dev, bool unique)
>> +{
>> + struct netdev_upper *upper;
>> +
>> + ASSERT_RTNL();
>> +
>> + if (dev == upper_dev)
>> + return -EBUSY;
>> + /*
>> + * To prevent loops, check if dev is not upper device to upper_dev.
>> + */
>> + if (__netdev_has_upper_dev(upper_dev, dev, true))
>> + return -EBUSY;
>> +
>> + if (__netdev_find_upper(dev, upper_dev))
>> + return -EEXIST;
>> +
>> + if (unique && netdev_unique_upper_dev_get(dev))
>> + return -EBUSY;
>> +
>> + upper = kmalloc(sizeof(*upper), GFP_KERNEL);
>> + if (!upper)
>> + return -ENOMEM;
>> +
>> + upper->dev = upper_dev;
>> + upper->unique = unique;
>> +
>> + /*
>> + * Ensure that unique upper link is always the first item in the list.
>> + */
>> + if (unique)
>> + list_add_rcu(&upper->list, &dev->upper_dev_list);
>> + else
>> + list_add_tail_rcu(&upper->list, &dev->upper_dev_list);
>> + dev_hold(upper_dev);
>
>This behaviour (calling dev_hold()) matches netdev_set_master(). But
>it's oddly asymmetric: generally the administrator can remove either the
>upper device or the lower device (rtnl_link_ops or unbinding a physical
>device) and the upper device driver must then unlink itself from the
>lower device (using a notifier to catch lower device removal).
>
>If the upper device driver fails to unlink when the upper device is
>unregistered, then this extra reference causes netdev_wait_allrefs() to
>hang... is that the intent? Or should there be a more explicit counter
>and check on unregistration, e.g. WARN_ON(dev->num_lower_devs != 0)?
>
I'm not sure I understand you. I believe that upper device notifier
should take care of the unlink. This behaviour is unchanged by the
patch.
>If it fails to unlink when the lower device is removed, this warning in
>rollback_registered_many() may be triggered:
>
> /* Notifier chain MUST detach us from master device. */
> WARN_ON(dev->master);
>
>I think that needs to become WARN_ON(netdev_has_upper_dev(dev)).
Patch 15
>
>> + return 0;
>> +}
>[...]
>
>--
>Ben Hutchings, Staff Engineer, Solarflare
>Not speaking for my employer; that's the marketing department's job.
>They asked us to note that Solarflare product names are trademarked.
>
next prev parent reply other threads:[~2012-08-13 17:31 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-13 15:27 [Bridge] [patch net-next 00/16] net: introduce upper device lists and remove dev->master Jiri Pirko
2012-08-13 15:27 ` [Bridge] [patch net-next 01/16] net: introduce upper device lists Jiri Pirko
2012-08-13 17:04 ` Ben Hutchings
2012-08-13 17:31 ` Jiri Pirko [this message]
2012-08-15 20:33 ` Nicolas de Pesloüan
2012-08-13 17:52 ` Flavio Leitner
2012-08-14 12:24 ` Jiri Pirko
2012-08-14 13:14 ` Flavio Leitner
2012-08-14 13:35 ` Jiri Pirko
2012-08-14 9:02 ` Cong Wang
2012-08-14 10:18 ` Jiri Pirko
2012-08-13 15:27 ` [Bridge] [patch net-next 02/16] macvlan: add link to upper device Jiri Pirko
2012-08-13 15:27 ` [Bridge] [patch net-next 03/16] vlan: " Jiri Pirko
2012-08-13 19:04 ` Flavio Leitner
2012-08-14 7:24 ` Jiri Pirko
2012-08-13 15:27 ` [Bridge] [patch net-next 04/16] rtnetlink: remove usage of dev->master Jiri Pirko
2012-08-13 15:27 ` [Bridge] [patch net-next 05/16] team: remove usage of netdev_set_master() Jiri Pirko
2012-08-13 15:27 ` [Bridge] [patch net-next 06/16] bridge: " Jiri Pirko
2012-08-13 15:27 ` [Bridge] [patch net-next 07/16] netpoll: remove usage of dev->master Jiri Pirko
2012-08-13 15:27 ` [Bridge] [patch net-next 08/16] cxgb3: " Jiri Pirko
2012-08-13 15:27 ` [Bridge] [patch net-next 09/16] qlcnic: guard __vlan_find_dev_deep() by rcu_read_lock Jiri Pirko
2012-08-13 15:27 ` [Bridge] [patch net-next 10/16] qeth: ensure that __vlan_find_dev_deep() is called with rcu_read_lock Jiri Pirko
2012-08-13 15:27 ` [Bridge] [patch net-next 11/16] vlan: remove usage of dev->master in __vlan_find_dev_deep() Jiri Pirko
2012-08-13 15:27 ` [Bridge] [patch net-next 12/16] nes: remove usage of dev->master Jiri Pirko
2012-08-13 15:27 ` [Bridge] [patch net-next 13/16] bonding: " Jiri Pirko
2012-08-13 15:27 ` [Bridge] [patch net-next 14/16] net: remove no longer used netdev_set_bond_master() and netdev_set_master() Jiri Pirko
2012-08-13 15:28 ` [Bridge] [patch net-next 15/16] net: remove usage of dev->master Jiri Pirko
2012-08-13 17:15 ` Ben Hutchings
2012-08-13 17:31 ` Jiri Pirko
2012-08-13 15:28 ` [Bridge] [patch net-next 16/16] net: kill dev->master Jiri Pirko
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=20120813173110.GA1808@minipsycho.orion \
--to=jiri@resnulli.us \
--cc=bhutchings@solarflare.com \
--cc=blaschka@linux.vnet.ibm.com \
--cc=bridge@lists.linux-foundation.org \
--cc=davem@davemloft.net \
--cc=divy@chelsio.com \
--cc=edumazet@google.com \
--cc=faisal.latif@intel.com \
--cc=fbl@redhat.com \
--cc=fubar@us.ibm.com \
--cc=gregory.v.rose@intel.com \
--cc=hal.rosenstock@gmail.com \
--cc=jitendra.kalsaria@qlogic.com \
--cc=joe@perches.com \
--cc=john.r.fastabend@intel.com \
--cc=kaber@trash.net \
--cc=linux-driver@qlogic.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=linux390@de.ibm.com \
--cc=netdev@vger.kernel.org \
--cc=roland@kernel.org \
--cc=sean.hefty@intel.com \
--cc=shemminger@vyatta.com \
--cc=sony.chacko@qlogic.com \
--cc=therbert@google.com \
--cc=ursula.braun@de.ibm.com \
--cc=xiyou.wangcong@gmail.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).