From: Kurt Kanzenbach <kurt@linutronix.de>
To: Andrew Lunn <andrew@lunn.ch>,
Vivien Didelot <vivien.didelot@gmail.com>,
Florian Fainelli <f.fainelli@gmail.com>,
Vladimir Oltean <olteanv@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
netdev@vger.kernel.org, Rob Herring <robh+dt@kernel.org>,
devicetree@vger.kernel.org,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Richard Cochran <richardcochran@gmail.com>,
Kamil Alkhouri <kamil.alkhouri@hs-offenburg.de>,
ilias.apalodimas@linaro.org,
Vladimir Oltean <vladimir.oltean@nxp.com>,
Kurt Kanzenbach <kurt@linutronix.de>
Subject: [PATCH net-next v8 2/8] net: dsa: Give drivers the chance to veto certain upper devices
Date: Tue, 3 Nov 2020 08:10:55 +0100 [thread overview]
Message-ID: <20201103071101.3222-3-kurt@linutronix.de> (raw)
In-Reply-To: <20201103071101.3222-1-kurt@linutronix.de>
From: Vladimir Oltean <vladimir.oltean@nxp.com>
Some switches rely on unique pvids to ensure port separation in
standalone mode, because they don't have a port forwarding matrix
configurable in hardware. So, setups like a group of 2 uppers with the
same VLAN, swp0.100 and swp1.100, will cause traffic tagged with VLAN
100 to be autonomously forwarded between these switch ports, in spite
of there being no bridge between swp0 and swp1.
These drivers need to prevent this from happening. They need to have
VLAN filtering enabled in standalone mode (so they'll drop frames tagged
with unknown VLANs) and they can only accept an 8021q upper on a port as
long as it isn't installed on any other port too. So give them the
chance to veto bad user requests.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
[Kurt: Pass info instead of ptr]
Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
---
include/net/dsa.h | 6 ++++++
net/dsa/slave.c | 12 ++++++++++++
2 files changed, 18 insertions(+)
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 04e93bafb7bd..4e60d2610f20 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -536,6 +536,12 @@ struct dsa_switch_ops {
void (*get_regs)(struct dsa_switch *ds, int port,
struct ethtool_regs *regs, void *p);
+ /*
+ * Upper device tracking.
+ */
+ int (*port_prechangeupper)(struct dsa_switch *ds, int port,
+ struct netdev_notifier_changeupper_info *info);
+
/*
* Bridge integration
*/
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index c6806eef906f..59c80052e950 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -2032,10 +2032,22 @@ static int dsa_slave_netdevice_event(struct notifier_block *nb,
switch (event) {
case NETDEV_PRECHANGEUPPER: {
struct netdev_notifier_changeupper_info *info = ptr;
+ struct dsa_switch *ds;
+ struct dsa_port *dp;
+ int err;
if (!dsa_slave_dev_check(dev))
return dsa_prevent_bridging_8021q_upper(dev, ptr);
+ dp = dsa_slave_to_port(dev);
+ ds = dp->ds;
+
+ if (ds->ops->port_prechangeupper) {
+ err = ds->ops->port_prechangeupper(ds, dp->index, info);
+ if (err)
+ return notifier_from_errno(err);
+ }
+
if (is_vlan_dev(info->upper_dev))
return dsa_slave_check_8021q_upper(dev, ptr);
break;
--
2.20.1
next prev parent reply other threads:[~2020-11-03 7:11 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-03 7:10 [PATCH net-next v8 0/8] Hirschmann Hellcreek DSA driver Kurt Kanzenbach
2020-11-03 7:10 ` [PATCH net-next v8 1/8] net: dsa: Add tag handling for Hirschmann Hellcreek switches Kurt Kanzenbach
2020-11-03 7:17 ` Vladimir Oltean
2020-11-03 7:10 ` Kurt Kanzenbach [this message]
2020-11-03 7:10 ` [PATCH net-next v8 3/8] net: dsa: Add DSA driver " Kurt Kanzenbach
2020-11-03 7:10 ` [PATCH net-next v8 4/8] net: dsa: hellcreek: Add PTP clock support Kurt Kanzenbach
2020-11-03 7:10 ` [PATCH net-next v8 5/8] net: dsa: hellcreek: Add support for hardware timestamping Kurt Kanzenbach
2020-11-03 7:10 ` [PATCH net-next v8 6/8] net: dsa: hellcreek: Add PTP status LEDs Kurt Kanzenbach
2020-11-03 7:11 ` [PATCH net-next v8 7/8] dt-bindings: Add vendor prefix for Hirschmann Kurt Kanzenbach
2020-11-03 7:11 ` [PATCH net-next v8 8/8] dt-bindings: net: dsa: Add documentation for Hellcreek switches Kurt Kanzenbach
2020-11-05 22:17 ` [PATCH net-next v8 0/8] Hirschmann Hellcreek DSA driver Jakub Kicinski
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=20201103071101.3222-3-kurt@linutronix.de \
--to=kurt@linutronix.de \
--cc=andrew@lunn.ch \
--cc=bigeasy@linutronix.de \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=f.fainelli@gmail.com \
--cc=ilias.apalodimas@linaro.org \
--cc=kamil.alkhouri@hs-offenburg.de \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=richardcochran@gmail.com \
--cc=robh+dt@kernel.org \
--cc=vivien.didelot@gmail.com \
--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).