netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: "David S . Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org, Andrew Lunn <andrew@lunn.ch>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Vivien Didelot <vivien.didelot@gmail.com>,
	Richard Cochran <richardcochran@gmail.com>,
	Claudiu Manoil <claudiu.manoil@nxp.com>,
	Alexandru Marginean <alexandru.marginean@nxp.com>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	Xiaoliang Yang <xiaoliang.yang_1@nxp.com>,
	Hongbo Wang <hongbo.wang@nxp.com>,
	Vladimir Oltean <vladimir.oltean@nxp.com>,
	Po Liu <po.liu@nxp.com>, Yangbo Lu <yangbo.lu@nxp.com>,
	Maxim Kochetkov <fido_max@inbox.ru>,
	Eldar Gasanov <eldargasanov2@gmail.com>,
	Andrey L <al@b4comtech.com>,
	Tobias Waldekranz <tobias@waldekranz.com>,
	UNGLinuxDriver@microchip.com
Subject: Re: [PATCH v6 net-next 07/10] net: dsa: allow changing the tag protocol via the "tagging" device attribute
Date: Sun, 24 Jan 2021 10:20:39 +0200	[thread overview]
Message-ID: <20210124082039.gkgxskot7oxseub7@skbuf> (raw)
In-Reply-To: <20210122205216.7f1e05f6@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>

On Fri, Jan 22, 2021 at 08:52:16PM -0800, Jakub Kicinski wrote:
> On Thu, 21 Jan 2021 18:01:28 +0200 Vladimir Oltean wrote:
> > +	/* At the moment we don't allow changing the tag protocol under
> > +	 * traffic. May revisit in the future.
> > +	 */
> > +	if (master->flags & IFF_UP)
> > +		return -EBUSY;
>
> But you're not holding rtnl_lock at this point, this check is advisory
> at best.

Yes, I should hold the rtnl_mutex.

> > +	list_for_each_entry(dp, &dst->ports, list) {
>
> What protects this iteration? All sysfs guarantees you is that
> struct net_device *master itself will not disappear.
>
> Could you explain the locking expectations a bit?

The dsa_group sysfs is removed in:

dsa_unregister_switch
-> mutex_lock(&dsa2_mutex)
-> dsa_switch_remove
   -> dsa_tree_teardown
      -> dsa_tree_teardown_master
         -> dsa_master_teardown
            -> sysfs_remove_group
There are 2 points here:
1. sysfs_remove_group actually waits for a concurrent tagging_store()
   call to finish (at least it does when I put an msleep(10000) inside
   tagging_store).
2. After the sysfs_remove_group, dsa_tree_change_tag_proto should never
   be called again.

Next comes:
   -> dsa_tree_teardown
      -> dsa_tree_teardown_switches
         -> dsa_port_teardown
            -> dsa_slave_destroy
After this, all DSA net devices are unregistered and freed.

Next comes:
-> dsa_switch_remove
   -> dsa_switch_release_ports
-> mutex_unlock(&dsa2_mutex)
where the dst->ports list is finally freed.

So there is no chance that the dst->ports list is modified concurrently
with tagging_store.

  reply	other threads:[~2021-01-24  8:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-21 16:01 [PATCH v6 net-next 00/10] tag_8021q for Ocelot switches Vladimir Oltean
2021-01-21 16:01 ` [PATCH v6 net-next 01/10] net: dsa: tag_8021q: add helpers to deduce whether a VLAN ID is RX or TX VLAN Vladimir Oltean
2021-01-21 16:01 ` [PATCH v6 net-next 02/10] net: mscc: ocelot: export VCAP structures to include/soc/mscc Vladimir Oltean
2021-01-21 16:01 ` [PATCH v6 net-next 03/10] net: mscc: ocelot: store a namespaced VCAP filter ID Vladimir Oltean
2021-01-21 16:01 ` [PATCH v6 net-next 04/10] net: mscc: ocelot: reapply bridge forwarding mask on bonding join/leave Vladimir Oltean
2021-01-21 16:01 ` [PATCH v6 net-next 05/10] net: mscc: ocelot: don't use NPI tag prefix for the CPU port module Vladimir Oltean
2021-01-21 16:01 ` [PATCH v6 net-next 06/10] net: dsa: document the existing switch tree notifiers and add a new one Vladimir Oltean
2021-01-21 16:01 ` [PATCH v6 net-next 07/10] net: dsa: allow changing the tag protocol via the "tagging" device attribute Vladimir Oltean
2021-01-21 20:38   ` Florian Fainelli
2021-01-23  4:52   ` Jakub Kicinski
2021-01-24  8:20     ` Vladimir Oltean [this message]
2021-01-25 18:46       ` Jakub Kicinski
2021-01-21 16:01 ` [PATCH v6 net-next 08/10] net: dsa: felix: convert to the new .{set,del}_tag_protocol DSA API Vladimir Oltean
2021-01-21 16:01 ` [PATCH v6 net-next 09/10] net: dsa: add a second tagger for Ocelot switches based on tag_8021q Vladimir Oltean
2021-01-21 16:01 ` [PATCH v6 net-next 10/10] net: dsa: felix: perform switch setup for tag_8021q Vladimir Oltean

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=20210124082039.gkgxskot7oxseub7@skbuf \
    --to=olteanv@gmail.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=al@b4comtech.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=alexandru.marginean@nxp.com \
    --cc=andrew@lunn.ch \
    --cc=claudiu.manoil@nxp.com \
    --cc=davem@davemloft.net \
    --cc=eldargasanov2@gmail.com \
    --cc=f.fainelli@gmail.com \
    --cc=fido_max@inbox.ru \
    --cc=hongbo.wang@nxp.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=po.liu@nxp.com \
    --cc=richardcochran@gmail.com \
    --cc=tobias@waldekranz.com \
    --cc=vivien.didelot@gmail.com \
    --cc=vladimir.oltean@nxp.com \
    --cc=xiaoliang.yang_1@nxp.com \
    --cc=yangbo.lu@nxp.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).