From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: netdev@vger.kernel.org
Cc: Jakub Kicinski <kuba@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Florian Fainelli <f.fainelli@gmail.com>,
Andrew Lunn <andrew@lunn.ch>,
Vivien Didelot <vivien.didelot@gmail.com>,
Vladimir Oltean <olteanv@gmail.com>,
Roopa Prabhu <roopa@nvidia.com>,
Nikolay Aleksandrov <nikolay@nvidia.com>,
Jiri Pirko <jiri@nvidia.com>, Ido Schimmel <idosch@nvidia.com>,
Rafael Richter <rafael.richter@gin.de>,
Daniel Klauer <daniel.klauer@gin.de>,
Tobias Waldekranz <tobias@waldekranz.com>
Subject: [PATCH v2 net-next 2/8] net: bridge: switchdev: differentiate new VLANs from changed ones
Date: Tue, 15 Feb 2022 01:31:05 +0200 [thread overview]
Message-ID: <20220214233111.1586715-3-vladimir.oltean@nxp.com> (raw)
In-Reply-To: <20220214233111.1586715-1-vladimir.oltean@nxp.com>
br_switchdev_port_vlan_add() currently emits a SWITCHDEV_PORT_OBJ_ADD
event with a SWITCHDEV_OBJ_ID_PORT_VLAN for 2 distinct cases:
- a struct net_bridge_vlan got created
- an existing struct net_bridge_vlan was modified
This makes it impossible for switchdev drivers to properly balance
PORT_OBJ_ADD with PORT_OBJ_DEL events, so if we want to allow that to
happen, we must provide a way for drivers to distinguish between a
VLAN with changed flags and a new one.
Annotate struct switchdev_obj_port_vlan with a "bool changed" that
distinguishes the 2 cases above. If the VLAN is changed, also provide
the old flags such that the driver can determine which flags were
actually changed.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
v1->v2: patch is new, logically replaces the need for "net: bridge:
vlan: notify a switchdev deletion when modifying flags of
existing VLAN"
include/net/switchdev.h | 6 ++++++
net/bridge/br_private.h | 6 ++++--
net/bridge/br_switchdev.c | 3 +++
net/bridge/br_vlan.c | 12 +++++++-----
4 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/include/net/switchdev.h b/include/net/switchdev.h
index d353793dfeb5..24ec1f82a521 100644
--- a/include/net/switchdev.h
+++ b/include/net/switchdev.h
@@ -79,8 +79,14 @@ struct switchdev_obj {
/* SWITCHDEV_OBJ_ID_PORT_VLAN */
struct switchdev_obj_port_vlan {
struct switchdev_obj obj;
+ /* Valid only if @changed is set */
+ u16 old_flags;
u16 flags;
u16 vid;
+ /* If set, the notifier signifies a change of flags for
+ * a VLAN that already exists.
+ */
+ bool changed;
};
#define SWITCHDEV_OBJ_PORT_VLAN(OBJ) \
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index 2661dda1a92b..633cc048c590 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -1985,6 +1985,7 @@ void br_switchdev_mdb_notify(struct net_device *dev,
struct net_bridge_port_group *pg,
int type);
int br_switchdev_port_vlan_add(struct net_device *dev, u16 vid, u16 flags,
+ bool changed, u16 old_flags,
struct netlink_ext_ack *extack);
int br_switchdev_port_vlan_del(struct net_device *dev, u16 vid);
void br_switchdev_init(struct net_bridge *br);
@@ -2052,8 +2053,9 @@ static inline int br_switchdev_set_port_flag(struct net_bridge_port *p,
return 0;
}
-static inline int br_switchdev_port_vlan_add(struct net_device *dev,
- u16 vid, u16 flags,
+static inline int br_switchdev_port_vlan_add(struct net_device *dev, u16 vid,
+ u16 flags, bool changed,
+ u16 old_flags,
struct netlink_ext_ack *extack)
{
return -EOPNOTSUPP;
diff --git a/net/bridge/br_switchdev.c b/net/bridge/br_switchdev.c
index f8fbaaa7c501..f36f60766478 100644
--- a/net/bridge/br_switchdev.c
+++ b/net/bridge/br_switchdev.c
@@ -160,6 +160,7 @@ br_switchdev_fdb_notify(struct net_bridge *br,
}
int br_switchdev_port_vlan_add(struct net_device *dev, u16 vid, u16 flags,
+ bool changed, u16 old_flags,
struct netlink_ext_ack *extack)
{
struct switchdev_obj_port_vlan v = {
@@ -167,6 +168,8 @@ int br_switchdev_port_vlan_add(struct net_device *dev, u16 vid, u16 flags,
.obj.id = SWITCHDEV_OBJ_ID_PORT_VLAN,
.flags = flags,
.vid = vid,
+ .changed = changed,
+ .old_flags = old_flags,
};
return switchdev_port_obj_add(dev, &v.obj, extack);
diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c
index c5355695c976..6f3ee4d8fea8 100644
--- a/net/bridge/br_vlan.c
+++ b/net/bridge/br_vlan.c
@@ -105,7 +105,7 @@ static int __vlan_vid_add(struct net_device *dev, struct net_bridge *br,
/* Try switchdev op first. In case it is not supported, fallback to
* 8021q add.
*/
- err = br_switchdev_port_vlan_add(dev, v->vid, flags, extack);
+ err = br_switchdev_port_vlan_add(dev, v->vid, flags, false, 0, extack);
if (err == -EOPNOTSUPP)
return vlan_vid_add(dev, br->vlan_proto, v->vid);
v->priv_flags |= BR_VLFLAG_ADDED_BY_SWITCHDEV;
@@ -297,7 +297,8 @@ static int __vlan_add(struct net_bridge_vlan *v, u16 flags,
}
br_multicast_port_ctx_init(p, v, &v->port_mcast_ctx);
} else {
- err = br_switchdev_port_vlan_add(dev, v->vid, flags, extack);
+ err = br_switchdev_port_vlan_add(dev, v->vid, flags, false, 0,
+ extack);
if (err && err != -EOPNOTSUPP)
goto out;
br_multicast_ctx_init(br, v, &v->br_mcast_ctx);
@@ -688,7 +689,7 @@ static int br_vlan_add_existing(struct net_bridge *br,
*changed = __vlan_flags_would_change(vlan, flags);
if (*changed) {
err = br_switchdev_port_vlan_add(br->dev, vlan->vid, flags,
- extack);
+ true, vlan->flags, extack);
if (err && err != -EOPNOTSUPP)
return err;
}
@@ -1266,8 +1267,9 @@ int nbp_vlan_add(struct net_bridge_port *port, u16 vid, u16 flags,
*changed = __vlan_flags_would_change(vlan, flags);
if (*changed) {
/* Pass the flags to the hardware bridge */
- ret = br_switchdev_port_vlan_add(port->dev, vid,
- flags, extack);
+ ret = br_switchdev_port_vlan_add(port->dev, vid, flags,
+ true, vlan->flags,
+ extack);
if (ret && ret != -EOPNOTSUPP)
return ret;
}
--
2.25.1
next prev parent reply other threads:[~2022-02-14 23:32 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-14 23:31 [PATCH v2 net-next 0/8] Replay and offload host VLAN entries in DSA Vladimir Oltean
2022-02-14 23:31 ` [PATCH v2 net-next 1/8] net: bridge: vlan: notify switchdev only when something changed Vladimir Oltean
2022-02-15 0:05 ` Vladimir Oltean
2022-02-15 8:54 ` Nikolay Aleksandrov
2022-02-15 9:54 ` Vladimir Oltean
2022-02-15 10:10 ` Vladimir Oltean
2022-02-15 10:15 ` Nikolay Aleksandrov
2022-02-15 10:12 ` Nikolay Aleksandrov
2022-02-15 10:30 ` Vladimir Oltean
2022-02-15 11:08 ` Nikolay Aleksandrov
2022-02-15 11:10 ` Nikolay Aleksandrov
2022-02-15 14:36 ` Vladimir Oltean
2022-02-15 15:38 ` Vladimir Oltean
2022-02-15 15:44 ` Nikolay Aleksandrov
2022-02-15 15:52 ` Vladimir Oltean
2022-02-14 23:31 ` Vladimir Oltean [this message]
2022-02-14 23:31 ` [PATCH v2 net-next 3/8] net: bridge: make nbp_switchdev_unsync_objs() follow reverse order of sync() Vladimir Oltean
2022-02-14 23:31 ` [PATCH v2 net-next 4/8] net: bridge: switchdev: replay all VLAN groups Vladimir Oltean
2022-02-14 23:31 ` [PATCH v2 net-next 5/8] net: switchdev: rename switchdev_lower_dev_find to switchdev_lower_dev_find_rcu Vladimir Oltean
2022-02-14 23:31 ` [PATCH v2 net-next 6/8] net: switchdev: introduce switchdev_handle_port_obj_{add,del} for foreign interfaces Vladimir Oltean
2022-02-14 23:31 ` [PATCH v2 net-next 7/8] net: dsa: add explicit support for host bridge VLANs Vladimir Oltean
2022-02-14 23:31 ` [PATCH v2 net-next 8/8] net: dsa: offload bridge port VLANs on foreign interfaces 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=20220214233111.1586715-3-vladimir.oltean@nxp.com \
--to=vladimir.oltean@nxp.com \
--cc=andrew@lunn.ch \
--cc=daniel.klauer@gin.de \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=idosch@nvidia.com \
--cc=jiri@nvidia.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nikolay@nvidia.com \
--cc=olteanv@gmail.com \
--cc=rafael.richter@gin.de \
--cc=roopa@nvidia.com \
--cc=tobias@waldekranz.com \
--cc=vivien.didelot@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