Ethernet Bridge development
 help / color / mirror / Atom feed
* [PATCH bridge] Allow MSTI 0 state setting the same way as non-zero MSTI
@ 2026-09-15  8:23 Алексей
  2026-09-15 13:07 ` Ido Schimmel
  0 siblings, 1 reply; 2+ messages in thread
From: Алексей @ 2026-09-15  8:23 UTC (permalink / raw)
  To: razor, idosch, bridge

Hello!

For now kernel rejects setting MSTI 0 instance state in the same way as another instances.
I.e. any non-zero instance state can be set with the following command:
# bridge mst set dev <dev> msti <instance> state <state>

While MST 0 instance state cannot be set in the same way and requires another command:
# bridge link set dev <dev> state <state>

This look a little bit inconsistent.
The following change fixes it:

---
Allow setting the MSTI 0 state the same way as non-zero MSTI. 

Signed-off-by: Aleksey S. Kazantsev <ioctl@yandex.ru>

diff --git a/net/bridge/br_mst.c b/net/bridge/br_mst.c
index 43a300ae6bfa..852e21b88c69 100644
--- a/net/bridge/br_mst.c
+++ b/net/bridge/br_mst.c
@@ -112,14 +112,12 @@ int br_mst_set_state(struct net_bridge_port *p, u16 msti, u8 state,
        if (!vg)
                goto out;
 
-       /* MSTI 0 (CST) state changes are notified via the regular
+       /* MSTI 0 (CST) state changes are also can be notified via the regular
         * SWITCHDEV_ATTR_ID_PORT_STP_STATE.
         */
-       if (msti) {
-               err = switchdev_port_attr_set(p->dev, &attr, extack);
-               if (err && err != -EOPNOTSUPP)
-                       goto out;
-       }
+       err = switchdev_port_attr_set(p->dev, &attr, extack);
+       if (err && err != -EOPNOTSUPP)
+               goto out;
 
        err = 0;
        list_for_each_entry_rcu(v, &vg->vlan_list, vlist) {
@@ -294,7 +292,7 @@ int br_mst_fill_info(struct sk_buff *skb,
 
 static const struct nla_policy br_mst_nl_policy[IFLA_BRIDGE_MST_ENTRY_MAX + 1] = {
        [IFLA_BRIDGE_MST_ENTRY_MSTI] = NLA_POLICY_RANGE(NLA_U16,
-                                                  1, /* 0 reserved for CST */
+                                                  0,
                                                   VLAN_N_VID - 1),
        [IFLA_BRIDGE_MST_ENTRY_STATE] = NLA_POLICY_RANGE(NLA_U8,
                                                    BR_STATE_DISABLED,
--

Aleksey Kazantsev

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH bridge] Allow MSTI 0 state setting the same way as non-zero MSTI
  2026-09-15  8:23 [PATCH bridge] Allow MSTI 0 state setting the same way as non-zero MSTI Алексей
@ 2026-09-15 13:07 ` Ido Schimmel
  0 siblings, 0 replies; 2+ messages in thread
From: Ido Schimmel @ 2026-09-15 13:07 UTC (permalink / raw)
  To: Алексей; +Cc: razor, bridge

On Tue, Sep 15, 2026 at 11:23:17AM +0300, Алексей wrote:
> Hello!
> 
> For now kernel rejects setting MSTI 0 instance state in the same way as another instances.
> I.e. any non-zero instance state can be set with the following command:
> # bridge mst set dev <dev> msti <instance> state <state>
> 
> While MST 0 instance state cannot be set in the same way and requires another command:
> # bridge link set dev <dev> state <state>
> 
> This look a little bit inconsistent.
> The following change fixes it:
> 
> ---
> Allow setting the MSTI 0 state the same way as non-zero MSTI.
> 
> Signed-off-by: Aleksey S. Kazantsev <ioctl@yandex.ru>
> 
> diff --git a/net/bridge/br_mst.c b/net/bridge/br_mst.c
> index 43a300ae6bfa..852e21b88c69 100644
> --- a/net/bridge/br_mst.c
> +++ b/net/bridge/br_mst.c
> @@ -112,14 +112,12 @@ int br_mst_set_state(struct net_bridge_port *p, u16 msti, u8 state,
>         if (!vg)
>                 goto out;
> 
> -       /* MSTI 0 (CST) state changes are notified via the regular
> +       /* MSTI 0 (CST) state changes are also can be notified via the regular
>          * SWITCHDEV_ATTR_ID_PORT_STP_STATE.
>          */
> -       if (msti) {
> -               err = switchdev_port_attr_set(p->dev, &attr, extack);
> -               if (err && err != -EOPNOTSUPP)
> -                       goto out;
> -       }
> +       err = switchdev_port_attr_set(p->dev, &attr, extack);
> +       if (err && err != -EOPNOTSUPP)
> +               goto out;

1. This is going to conflict with:

https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/commit/?id=18a6fe05fb6e18de29fa90d388bb34044114b3d8

2. switchdev_port_attr_set() can block and msti 0 can be set from
softIRQ context, so you will get sleeping in an atomic context splat.

3. This is not how a patch is supposed to be submitted. Please refer to
the kernel docs regarding this and look at other bridge patches for
reference.

The code seems fine as-is.

> 
>         err = 0;
>         list_for_each_entry_rcu(v, &vg->vlan_list, vlist) {
> @@ -294,7 +292,7 @@ int br_mst_fill_info(struct sk_buff *skb,
> 
>  static const struct nla_policy br_mst_nl_policy[IFLA_BRIDGE_MST_ENTRY_MAX + 1] = {
>         [IFLA_BRIDGE_MST_ENTRY_MSTI] = NLA_POLICY_RANGE(NLA_U16,
> -                                                  1, /* 0 reserved for CST */
> +                                                  0,
>                                                    VLAN_N_VID - 1),
>         [IFLA_BRIDGE_MST_ENTRY_STATE] = NLA_POLICY_RANGE(NLA_U8,
>                                                     BR_STATE_DISABLED,
> --
> 
> Aleksey Kazantsev

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-15 13:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-15  8:23 [PATCH bridge] Allow MSTI 0 state setting the same way as non-zero MSTI Алексей
2026-09-15 13:07 ` Ido Schimmel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox