From: Nikolay Aleksandrov <razor@blackwall.org>
To: Luke Howard <lukeh@padl.com>, netdev@vger.kernel.org
Cc: Kieran Tyrrell <kieran@sienda.com>,
Max Hunter <max@huntershome.org>,
Cedric Jehasse <cedric.jehasse@luminex.be>,
Jiri Pirko <jiri@resnulli.us>, Ivan Vecera <ivecera@redhat.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+netdev@lunn.ch>,
Ido Schimmel <idosch@nvidia.com>,
linux-kernel@vger.kernel.org, bridge@lists.linux.dev
Subject: Re: [PATCH net-next 1/6] net: bridge: mdb: add MDB_FLAGS_STREAM_RESERVED flag
Date: Wed, 27 May 2026 10:05:32 +0300 [thread overview]
Message-ID: <946d52d4-1456-4cf8-9dfa-9bba96121dcb@blackwall.org> (raw)
In-Reply-To: <45e7cd01f9449c8ef15a5affd587fe7645ecddb7.1779841530.git.lukeh@padl.com>
On 27/05/2026 03:42, Luke Howard wrote:
> Add a new MDB entry flag, MDB_FLAGS_STREAM_RESERVED, that userspace
> can set on RTM_NEWMDB to mark a multicast destination as belonging
> to a reserved stream (e.g. IEEE 802.1Q Stream Reservation Protocol /
> IEEE 1722 / TSN). The bridge core does no admission control on the
> basis of the flag; it is metadata propagated through switchdev to
> hardware drivers that can themselves enforce admission of AVB / SR
> priority traffic only to flagged destinations.
>
> The flag is settable via the new nested attribute MDBE_ATTR_FLAGS
> (NLA_U32 bitmask, validated against MDB_FLAGS_SETTABLE_MASK), and is
> reflected in dump output via br_mdb_entry.flags as is done today for
> the OFFLOAD/BLOCKED/STAR_EXCL flags.
>
> Assisted-by: Claude:claude-4.7-opus
> Signed-off-by: Luke Howard <lukeh@padl.com>
> ---
> include/net/switchdev.h | 4 ++++
> include/uapi/linux/if_bridge.h | 2 ++
> net/bridge/br_mdb.c | 12 ++++++++++++
> net/bridge/br_private.h | 2 ++
> net/bridge/br_switchdev.c | 17 +++++++++++------
> 5 files changed, 31 insertions(+), 6 deletions(-)
>
We don't add hw-only functionality, if you'd like to have this flag
you'll have to do a software implementation of this feature first.
Also please check the slop(code) that Claude generates before sending
it, there are obvious issues in this patch.
Cheers,
Nik
> diff --git a/include/net/switchdev.h b/include/net/switchdev.h
> index ee500706496b0..03d176708b768 100644
> --- a/include/net/switchdev.h
> +++ b/include/net/switchdev.h
> @@ -111,10 +111,14 @@ struct switchdev_obj_port_vlan {
> container_of((OBJ), struct switchdev_obj_port_vlan, obj)
>
> /* SWITCHDEV_OBJ_ID_PORT_MDB */
> +
> +#define SWITCHDEV_MDB_F_STREAM_RESERVED BIT(0)
> +
> struct switchdev_obj_port_mdb {
> struct switchdev_obj obj;
> unsigned char addr[ETH_ALEN];
> u16 vid;
> + u32 flags;
> };
>
> #define SWITCHDEV_OBJ_PORT_MDB(OBJ) \
> diff --git a/include/uapi/linux/if_bridge.h b/include/uapi/linux/if_bridge.h
> index 21a700c02ef76..51ec314994bec 100644
> --- a/include/uapi/linux/if_bridge.h
> +++ b/include/uapi/linux/if_bridge.h
> @@ -705,6 +705,7 @@ struct br_mdb_entry {
> #define MDB_FLAGS_STAR_EXCL (1 << 2)
> #define MDB_FLAGS_BLOCKED (1 << 3)
> #define MDB_FLAGS_OFFLOAD_FAILED (1 << 4)
> +#define MDB_FLAGS_STREAM_RESERVED (1 << 5)
> __u8 flags;
> __u16 vid;
> struct {
> @@ -760,6 +761,7 @@ enum {
> MDBE_ATTR_IFINDEX,
> MDBE_ATTR_SRC_VNI,
> MDBE_ATTR_STATE_MASK,
> + MDBE_ATTR_FLAGS,
> __MDBE_ATTR_MAX,
> };
> #define MDBE_ATTR_MAX (__MDBE_ATTR_MAX - 1)
> diff --git a/net/bridge/br_mdb.c b/net/bridge/br_mdb.c
> index e0c7020b12f5f..1320ccd81b0a1 100644
> --- a/net/bridge/br_mdb.c
> +++ b/net/bridge/br_mdb.c
> @@ -146,6 +146,8 @@ static void __mdb_entry_fill_flags(struct br_mdb_entry *e, unsigned char flags)
> e->flags |= MDB_FLAGS_BLOCKED;
> if (flags & MDB_PG_FLAGS_OFFLOAD_FAILED)
> e->flags |= MDB_FLAGS_OFFLOAD_FAILED;
> + if (flags & MDB_PG_FLAGS_STREAM_RESERVED)
> + e->flags |= MDB_FLAGS_STREAM_RESERVED;
> }
>
> static void __mdb_entry_to_br_ip(struct br_mdb_entry *entry, struct br_ip *ip,
> @@ -664,6 +666,7 @@ static const struct nla_policy br_mdbe_attrs_pol[MDBE_ATTR_MAX + 1] = {
> MCAST_INCLUDE),
> [MDBE_ATTR_SRC_LIST] = NLA_POLICY_NESTED(br_mdbe_src_list_pol),
> [MDBE_ATTR_RTPROT] = NLA_POLICY_MIN(NLA_U8, RTPROT_STATIC),
> + [MDBE_ATTR_FLAGS] = NLA_POLICY_MASK(NLA_U32, MDB_FLAGS_STREAM_RESERVED),
> };
>
> static bool is_valid_mdb_source(struct nlattr *attr, __be16 proto,
> @@ -1072,6 +1075,8 @@ static int br_mdb_add_group(const struct br_mdb_config *cfg,
> if (entry->state == MDB_PERMANENT)
> flags |= MDB_PG_FLAGS_PERMANENT;
>
> + flags |= cfg->pg_flags;
> +
> if (br_multicast_is_star_g(&group))
> return br_mdb_add_group_star_g(cfg, mp, brmctx, flags, extack);
> else
> @@ -1225,6 +1230,13 @@ static int br_mdb_config_attrs_init(struct nlattr *set_attrs,
> cfg->rt_protocol = nla_get_u8(mdb_attrs[MDBE_ATTR_RTPROT]);
> }
>
> + if (mdb_attrs[MDBE_ATTR_FLAGS]) {
> + u32 user_flags = nla_get_u32(mdb_attrs[MDBE_ATTR_FLAGS]);
> +
> + if (user_flags & MDB_FLAGS_STREAM_RESERVED)
> + cfg->pg_flags |= MDB_PG_FLAGS_STREAM_RESERVED;
> + }
> +
> return 0;
> }
>
> diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
> index 02671e648dac7..b9ee19448e38b 100644
> --- a/net/bridge/br_private.h
> +++ b/net/bridge/br_private.h
> @@ -111,6 +111,7 @@ struct br_mdb_config {
> struct br_mdb_src_entry *src_entries;
> int num_src_entries;
> u8 rt_protocol;
> + unsigned char pg_flags;
> };
> #endif
>
> @@ -317,6 +318,7 @@ struct net_bridge_fdb_flush_desc {
> #define MDB_PG_FLAGS_STAR_EXCL BIT(3)
> #define MDB_PG_FLAGS_BLOCKED BIT(4)
> #define MDB_PG_FLAGS_OFFLOAD_FAILED BIT(5)
> +#define MDB_PG_FLAGS_STREAM_RESERVED BIT(6)
>
> #define PG_SRC_ENT_LIMIT 32
>
> diff --git a/net/bridge/br_switchdev.c b/net/bridge/br_switchdev.c
> index 18b558a931ad9..bc05cda2f5350 100644
> --- a/net/bridge/br_switchdev.c
> +++ b/net/bridge/br_switchdev.c
> @@ -548,7 +548,8 @@ static void br_switchdev_mdb_complete(struct net_device *dev, int err, void *pri
> }
>
> static void br_switchdev_mdb_populate(struct switchdev_obj_port_mdb *mdb,
> - const struct net_bridge_mdb_entry *mp)
> + const struct net_bridge_mdb_entry *mp,
> + const struct net_bridge_port_group *pg)
> {
> if (mp->addr.proto == htons(ETH_P_IP))
> ip_eth_mc_map(mp->addr.dst.ip4, mdb->addr);
> @@ -560,6 +561,9 @@ static void br_switchdev_mdb_populate(struct switchdev_obj_port_mdb *mdb,
> ether_addr_copy(mdb->addr, mp->addr.dst.mac_addr);
>
> mdb->vid = mp->addr.vid;
> + mdb->flags = 0;
> + if (pg && (pg->flags & MDB_PG_FLAGS_STREAM_RESERVED))
> + mdb->flags |= SWITCHDEV_MDB_F_STREAM_RESERVED;
> }
>
> static void br_switchdev_host_mdb_one(struct net_device *dev,
> @@ -575,7 +579,7 @@ static void br_switchdev_host_mdb_one(struct net_device *dev,
> },
> };
>
> - br_switchdev_mdb_populate(&mdb, mp);
> + br_switchdev_mdb_populate(&mdb, mp, NULL);
>
> switch (type) {
> case RTM_NEWMDB:
> @@ -622,6 +626,7 @@ static int br_switchdev_mdb_queue_one(struct list_head *mdb_list,
> unsigned long action,
> enum switchdev_obj_id id,
> const struct net_bridge_mdb_entry *mp,
> + const struct net_bridge_port_group *pg,
> struct net_device *orig_dev)
> {
> struct switchdev_obj_port_mdb mdb = {
> @@ -632,7 +637,7 @@ static int br_switchdev_mdb_queue_one(struct list_head *mdb_list,
> };
> struct switchdev_obj_port_mdb *pmdb;
>
> - br_switchdev_mdb_populate(&mdb, mp);
> + br_switchdev_mdb_populate(&mdb, mp, pg);
>
> if (action == SWITCHDEV_PORT_OBJ_ADD &&
> switchdev_port_obj_act_is_deferred(dev, action, &mdb.obj)) {
> @@ -671,7 +676,7 @@ void br_switchdev_mdb_notify(struct net_device *dev,
> if (!pg)
> return br_switchdev_host_mdb(dev, mp, type);
>
> - br_switchdev_mdb_populate(&mdb, mp);
> + br_switchdev_mdb_populate(&mdb, mp, pg);
>
> mdb.obj.orig_dev = pg->key.port->dev;
> switch (type) {
> @@ -740,7 +745,7 @@ br_switchdev_mdb_replay(struct net_device *br_dev, struct net_device *dev,
> if (mp->host_joined) {
> err = br_switchdev_mdb_queue_one(&mdb_list, dev, action,
> SWITCHDEV_OBJ_ID_HOST_MDB,
> - mp, br_dev);
> + mp, NULL, br_dev);
> if (err) {
> spin_unlock_bh(&br->multicast_lock);
> goto out_free_mdb;
> @@ -754,7 +759,7 @@ br_switchdev_mdb_replay(struct net_device *br_dev, struct net_device *dev,
>
> err = br_switchdev_mdb_queue_one(&mdb_list, dev, action,
> SWITCHDEV_OBJ_ID_PORT_MDB,
> - mp, dev);
> + mp, p, dev);
> if (err) {
> spin_unlock_bh(&br->multicast_lock);
> goto out_free_mdb;
next prev parent reply other threads:[~2026-05-27 7:05 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1779841530.git.lukeh@padl.com>
2026-05-27 0:42 ` Luke Howard
2026-05-27 7:05 ` Nikolay Aleksandrov [this message]
2026-05-27 7:15 ` Luke Howard
2026-05-27 0:42 ` [PATCH net-next 2/6] net: dsa: mv88e6xxx: add num_tx_queues to chip info structure Luke Howard
2026-05-27 0:42 ` [PATCH net-next 3/6] net: dsa: mv88e6xxx: add MV88E6XXX_G1_ATU_CTL_MAC_AVB setter Luke Howard
2026-05-27 0:42 ` [PATCH net-next 4/6] net: dsa: mv88e6xxx: MQPRIO support Luke Howard
2026-05-27 0:42 ` [PATCH net-next 5/6] net: dsa: mv88e6xxx: CBS support Luke Howard
2026-05-27 9:28 ` Cedric Jehasse
2026-05-27 11:04 ` Luke Howard
2026-05-27 0:42 ` [PATCH net-next 6/6] dt-bindings: net: dsa: mv88e6xxx: add mv88e6xxx-avb-mode property Luke Howard
2026-05-27 15:04 ` Conor Dooley
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=946d52d4-1456-4cf8-9dfa-9bba96121dcb@blackwall.org \
--to=razor@blackwall.org \
--cc=andrew+netdev@lunn.ch \
--cc=bridge@lists.linux.dev \
--cc=cedric.jehasse@luminex.be \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=ivecera@redhat.com \
--cc=jiri@resnulli.us \
--cc=kieran@sienda.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lukeh@padl.com \
--cc=max@huntershome.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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
all inboxes | Powered by JetHome®