From: John Fastabend <john.fastabend@gmail.com>
To: Scott Feldman <sfeldma@gmail.com>
Cc: Jiri Pirko <jiri@resnulli.us>, Netdev <netdev@vger.kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Ido Schimmel <idosch@mellanox.com>, Elad Raz <eladr@mellanox.com>,
Florian Fainelli <f.fainelli@gmail.com>,
Guenter Roeck <linux@roeck-us.net>,
Vivien Didelot <vivien.didelot@savoirfairelinux.com>,
"andrew@lunn.ch" <andrew@lunn.ch>,
David Laight <David.Laight@aculab.com>,
"stephen@networkplumber.org" <stephen@networkplumber.org>
Subject: Re: [patch net-next v4 5/7] bridge: defer switchdev fdb del call in fdb_del_external_learn
Date: Mon, 12 Oct 2015 22:16:54 -0700 [thread overview]
Message-ID: <561C93C6.2070402@gmail.com> (raw)
In-Reply-To: <CAE4R7bB1ARJEOuLzedaQrvbiK=YrbqDy3Vytas4JMotAeVS5mA@mail.gmail.com>
On 15-10-12 09:19 PM, Scott Feldman wrote:
> On Mon, Oct 12, 2015 at 8:31 PM, John Fastabend
> <john.fastabend@gmail.com> wrote:
>> On 15-10-12 08:28 PM, Scott Feldman wrote:
>>> On Mon, Oct 12, 2015 at 11:03 AM, Jiri Pirko <jiri@resnulli.us> wrote:
>>>> From: Jiri Pirko <jiri@mellanox.com>
>>>>
>>>> Since spinlock is held here, defer the switchdev operation.
>>>>
>>>> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
>>>> ---
>>>> net/bridge/br_fdb.c | 5 ++++-
>>>> net/bridge/br_if.c | 3 +++
>>>> 2 files changed, 7 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
>>>> index f5e7da0..c88bd8e 100644
>>>> --- a/net/bridge/br_fdb.c
>>>> +++ b/net/bridge/br_fdb.c
>>>> @@ -134,7 +134,10 @@ static void fdb_del_hw_addr(struct net_bridge *br, const unsigned char *addr)
>>>> static void fdb_del_external_learn(struct net_bridge_fdb_entry *f)
>>>> {
>>>> struct switchdev_obj_port_fdb fdb = {
>>>> - .obj.id = SWITCHDEV_OBJ_ID_PORT_FDB,
>>>> + .obj = {
>>>> + .id = SWITCHDEV_OBJ_ID_PORT_FDB,
>>>> + .flags = SWITCHDEV_F_DEFER,
>>>> + },
>>>> .vid = f->vlan_id,
>>>> };
>>>>
>>>> diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
>>>> index 934cae9..09147cb 100644
>>>> --- a/net/bridge/br_if.c
>>>> +++ b/net/bridge/br_if.c
>>>> @@ -24,6 +24,7 @@
>>>> #include <linux/slab.h>
>>>> #include <net/sock.h>
>>>> #include <linux/if_vlan.h>
>>>> +#include <net/switchdev.h>
>>>>
>>>> #include "br_private.h"
>>>>
>>>> @@ -249,6 +250,8 @@ static void del_nbp(struct net_bridge_port *p)
>>>> list_del_rcu(&p->list);
>>>>
>>>> br_fdb_delete_by_port(br, p, 0, 1);
>>>> + switchdev_flush_deferred();
>>>> +
>>>
>>> This potentially flushes other (valid) work on the deferred queue not
>>> related to FDB del.
>>>
>>> I wonder if this flush step is necessary at all? The work we deferred
>>> to delete the FDB entry can still happen after the port has been
>>> removed (del_nbp). If the port driver/device find the FDB entry, then
>>> delete it, otherwise ignore it.
>>>
>>
>> Just the first thing that springs to mind reading this comment is,
>>
>> - del gets deffered
>> - add fdb
>> - del runs
>>
>> Is there an issue here? Sorry I'll do a more thorough review now just
>> thought I would toss it out there before I forget.
>
> It's a valid thought to consider, for sure. The context is these are
> only FDB entries added by an external learn event. So I believe in
> your sequence, the second step to add fdb entry wouldn't happen as the
> fdb entry already exists at that point (in other words, the entry has
> already been learned on external device and pushed up via notifier to
> bridge). So I think we're OK in regards to your question.
>
ah I see so the take away is we need to be very careful about who/what
sets the deferred bit or you might get yourself in a world of hurt.
Here you are just ensuring you get all the fdb addr's out of the device.
Seems OK to me just be sure you don't try to set the deferred bit on
the attributes setting the state to DISABLED so we don't get a race
there.
Thanks,
John
next prev parent reply other threads:[~2015-10-13 5:17 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-12 17:54 [patch net-next v4 0/7] switchdev: change locking Jiri Pirko
2015-10-12 17:54 ` [patch net-next v4 1/7] switchdev: introduce switchdev workqueue Jiri Pirko
2015-10-13 3:01 ` Scott Feldman
2015-10-12 18:03 ` [patch net-next v4 2/7] switchdev: allow caller to explicitly request attr_set as deferred Jiri Pirko
2015-10-12 18:03 ` [patch net-next v4 3/7] switchdev: remove pointers from switchdev objects Jiri Pirko
2015-10-13 3:01 ` Scott Feldman
2015-10-13 4:44 ` John Fastabend
2015-10-12 18:03 ` [patch net-next v4 4/7] switchdev: introduce possibility to defer obj_add/del Jiri Pirko
2015-10-13 3:08 ` Scott Feldman
2015-10-12 18:03 ` [patch net-next v4 5/7] bridge: defer switchdev fdb del call in fdb_del_external_learn Jiri Pirko
2015-10-13 3:28 ` Scott Feldman
2015-10-13 3:31 ` John Fastabend
2015-10-13 4:19 ` Scott Feldman
2015-10-13 5:16 ` John Fastabend [this message]
2015-10-13 6:05 ` Jiri Pirko
2015-10-13 6:46 ` Scott Feldman
2015-10-12 18:03 ` [patch net-next v4 6/7] rocker: remove nowait from switchdev callbacks Jiri Pirko
2015-10-13 4:02 ` Scott Feldman
2015-10-13 6:25 ` Jiri Pirko
2015-10-13 6:55 ` Scott Feldman
2015-10-12 18:03 ` [patch net-next v4 7/7] switchdev: assert rtnl mutex when going over lower netdevs Jiri Pirko
2015-10-13 2:52 ` [patch net-next v4 2/7] switchdev: allow caller to explicitly request attr_set as deferred Scott Feldman
2015-10-13 4:40 ` John Fastabend
2015-10-13 5:45 ` Jiri Pirko
2015-10-13 5:48 ` John Fastabend
2015-10-13 5:44 ` Jiri Pirko
2015-10-13 6:03 ` John Fastabend
2015-10-13 6:21 ` Jiri Pirko
2015-10-13 6:53 ` Scott Feldman
2015-10-13 7:30 ` Jiri Pirko
2015-10-13 14:07 ` Scott Feldman
2015-10-13 14:39 ` 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=561C93C6.2070402@gmail.com \
--to=john.fastabend@gmail.com \
--cc=David.Laight@aculab.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=eladr@mellanox.com \
--cc=f.fainelli@gmail.com \
--cc=idosch@mellanox.com \
--cc=jiri@resnulli.us \
--cc=linux@roeck-us.net \
--cc=netdev@vger.kernel.org \
--cc=sfeldma@gmail.com \
--cc=stephen@networkplumber.org \
--cc=vivien.didelot@savoirfairelinux.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).