netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonas Gorski <jonas.gorski@gmail.com>
To: Nikolay Aleksandrov <razor@blackwall.org>,
	Ido Schimmel <idosch@nvidia.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>, Andrew Lunn <andrew@lunn.ch>,
	Vladimir Oltean <olteanv@gmail.com>
Cc: Vladimir Oltean <vladimir.oltean@nxp.com>,
	bridge@lists.linux.dev, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH RFC net 2/2] net: dsa: propagate brentry flag changes
Date: Sat, 12 Apr 2025 14:24:28 +0200	[thread overview]
Message-ID: <20250412122428.108029-3-jonas.gorski@gmail.com> (raw)
In-Reply-To: <20250412122428.108029-1-jonas.gorski@gmail.com>

Currently any flag changes for brentry vlans are ignored, so the
configured cpu port vlan will get stuck at whatever the original flags
were.

E.g.

$ bridge vlan add dev swbridge vid 10 self pvid untagged
$ bridge vlan add dev swbridge vid 10 self

Would cause the vlan to get "stuck" at pvid untagged in the hardware,
despite now being configured as tagged on the bridge.

Fix this by passing on changed vlans to drivers, but do not increase the
refcount for updates.

Since we should never get an update for a non-existing VLAN, add a
WARN_ON() in case it happens.

Fixes: 134ef2388e7f ("net: dsa: add explicit support for host bridge VLANs")
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
---
 net/dsa/switch.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/net/dsa/switch.c b/net/dsa/switch.c
index 3d2feeea897b..dc3cf13ef29a 100644
--- a/net/dsa/switch.c
+++ b/net/dsa/switch.c
@@ -702,23 +702,25 @@ static int dsa_port_do_vlan_add(struct dsa_port *dp,
 		return err;
 	}
 
-	/* No need to propagate on shared ports the existing VLANs that were
-	 * re-notified after just the flags have changed. This would cause a
-	 * refcount bump which we need to avoid, since it unbalances the
-	 * additions with the deletions.
-	 */
-	if (vlan->changed)
-		return 0;
-
 	mutex_lock(&dp->vlans_lock);
 
 	v = dsa_vlan_find(&dp->vlans, vlan);
 	if (v) {
-		refcount_inc(&v->refcount);
-		trace_dsa_vlan_add_bump(dp, vlan, &v->refcount);
+		/* Do not update the refcount for updated VLANs. This would
+		 * cause an imbalance with deletions.
+		 */
+		if (vlan->changed) {
+			err = ds->ops->port_vlan_add(ds, port, vlan, extack);
+			trace_dsa_vlan_add_hw(dp, vlan, err);
+		} else {
+			refcount_inc(&v->refcount);
+			trace_dsa_vlan_add_bump(dp, vlan, &v->refcount);
+		}
 		goto out;
 	}
 
+	WARN_ON(vlan->changed);
+
 	v = kzalloc(sizeof(*v), GFP_KERNEL);
 	if (!v) {
 		err = -ENOMEM;
-- 
2.43.0


  parent reply	other threads:[~2025-04-12 12:24 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-12 12:24 [PATCH RFC net 0/2] net: dsa: fix handling brentry vlans with flags Jonas Gorski
2025-04-12 12:24 ` [PATCH RFC net 1/2] net: bridge: switchdev: do not notify new brentries as changed Jonas Gorski
2025-04-14 11:39   ` Vladimir Oltean
2025-04-14 12:11     ` Jonas Gorski
2025-04-14 12:58       ` Vladimir Oltean
2025-04-12 12:24 ` Jonas Gorski [this message]
2025-04-14 12:49   ` [PATCH RFC net 2/2] net: dsa: propagate brentry flag changes Vladimir Oltean
2025-04-14 12:52     ` Vladimir Oltean
2025-04-14 13:49       ` Jonas Gorski
2025-04-14 15:07         ` Vladimir Oltean
2025-04-19 10:52           ` Jonas Gorski
2025-04-28 10:07             ` Vladimir Oltean
2025-04-12 13:34 ` [PATCH RFC net 0/2] net: dsa: fix handling brentry vlans with flags Vladimir Oltean
2025-04-12 13:50   ` Jonas Gorski
2025-04-13  9:25     ` Jonas Gorski

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=20250412122428.108029-3-jonas.gorski@gmail.com \
    --to=jonas.gorski@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=bridge@lists.linux.dev \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=razor@blackwall.org \
    --cc=vladimir.oltean@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).