All of lore.kernel.org
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] net: dsa: microchip: fix bridging with more than two member" failed to apply to 5.16-stable tree
@ 2022-02-25 16:16 gregkh
  2022-02-25 17:14 ` Svenning Sørensen
  0 siblings, 1 reply; 5+ messages in thread
From: gregkh @ 2022-02-25 16:16 UTC (permalink / raw)
  To: sss, davem, o.rempel; +Cc: stable


The patch below does not apply to the 5.16-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 3d00827a90db6f79abc7cdc553887f89a2e0a184 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Svenning=20S=C3=B8rensen?= <sss@secomea.com>
Date: Fri, 18 Feb 2022 11:27:01 +0000
Subject: [PATCH] net: dsa: microchip: fix bridging with more than two member
 ports
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Commit b3612ccdf284 ("net: dsa: microchip: implement multi-bridge support")
plugged a packet leak between ports that were members of different bridges.
Unfortunately, this broke another use case, namely that of more than two
ports that are members of the same bridge.

After that commit, when a port is added to a bridge, hardware bridging
between other member ports of that bridge will be cleared, preventing
packet exchange between them.

Fix by ensuring that the Port VLAN Membership bitmap includes any existing
ports in the bridge, not just the port being added.

Fixes: b3612ccdf284 ("net: dsa: microchip: implement multi-bridge support")
Signed-off-by: Svenning Sørensen <sss@secomea.com>
Tested-by: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: David S. Miller <davem@davemloft.net>

diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index 55dbda04ea62..243f8ad6d06e 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -26,7 +26,7 @@ void ksz_update_port_member(struct ksz_device *dev, int port)
 	struct dsa_switch *ds = dev->ds;
 	u8 port_member = 0, cpu_port;
 	const struct dsa_port *dp;
-	int i;
+	int i, j;
 
 	if (!dsa_is_user_port(ds, port))
 		return;
@@ -45,13 +45,33 @@ void ksz_update_port_member(struct ksz_device *dev, int port)
 			continue;
 		if (!dsa_port_bridge_same(dp, other_dp))
 			continue;
+		if (other_p->stp_state != BR_STATE_FORWARDING)
+			continue;
 
-		if (other_p->stp_state == BR_STATE_FORWARDING &&
-		    p->stp_state == BR_STATE_FORWARDING) {
+		if (p->stp_state == BR_STATE_FORWARDING) {
 			val |= BIT(port);
 			port_member |= BIT(i);
 		}
 
+		/* Retain port [i]'s relationship to other ports than [port] */
+		for (j = 0; j < ds->num_ports; j++) {
+			const struct dsa_port *third_dp;
+			struct ksz_port *third_p;
+
+			if (j == i)
+				continue;
+			if (j == port)
+				continue;
+			if (!dsa_is_user_port(ds, j))
+				continue;
+			third_p = &dev->ports[j];
+			if (third_p->stp_state != BR_STATE_FORWARDING)
+				continue;
+			third_dp = dsa_to_port(ds, j);
+			if (dsa_port_bridge_same(other_dp, third_dp))
+				val |= BIT(j);
+		}
+
 		dev->dev_ops->cfg_port_member(dev, i, val | cpu_port);
 	}
 


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

* Re: FAILED: patch "[PATCH] net: dsa: microchip: fix bridging with more than two member" failed to apply to 5.16-stable tree
  2022-02-25 16:16 FAILED: patch "[PATCH] net: dsa: microchip: fix bridging with more than two member" failed to apply to 5.16-stable tree gregkh
@ 2022-02-25 17:14 ` Svenning Sørensen
  2022-02-26  7:38   ` gregkh
  0 siblings, 1 reply; 5+ messages in thread
From: Svenning Sørensen @ 2022-02-25 17:14 UTC (permalink / raw)
  To: gregkh, davem, o.rempel; +Cc: stable

gregkh@linuxfoundation wrote: 

>> The patch below does not apply to the 5.16-stable tree.
>> If someone wants it applied there, or to any other stable or longterm
>> tree, then please email the backport, including the original git commit
>> id to <stable@vger.kernel.org>.
...
>> ------------------ original commit in Linus's tree ------------------
>>From 3d00827a90db6f79abc7cdc553887f89a2e0a184 Mon Sep 17 00:00:00 2001

Hi Greg,

That's strange - it applies just fine without errors here:

--- snip ---
$ git log --oneline -n 1
f40e0f7a433b (HEAD -> linux-5.16.y, tag: v5.16.11, stable/linux-5.16.y) Linux 5.16.11
$ git cherry-pick -x 3d00827a90db6f79abc7cdc553887f89a2e0a184
[linux-5.16.y e1e17aca71a0] net: dsa: microchip: fix bridging with more than two member ports
 Date: Fri Feb 18 11:27:01 2022 +0000
 1 file changed, 23 insertions(+), 3 deletions(-)
--- snip ---

So I'm not sure what's needed for backporting?

Best regards,
Svenning Sørensen

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

* Re: FAILED: patch "[PATCH] net: dsa: microchip: fix bridging with more than two member" failed to apply to 5.16-stable tree
  2022-02-25 17:14 ` Svenning Sørensen
@ 2022-02-26  7:38   ` gregkh
       [not found]     ` <DB7PR08MB3867F9A962DA7A3B13408C12B53F9@DB7PR08MB3867.eurprd08.prod.outlook.com>
  0 siblings, 1 reply; 5+ messages in thread
From: gregkh @ 2022-02-26  7:38 UTC (permalink / raw)
  To: Svenning Sørensen; +Cc: davem, o.rempel, stable

On Fri, Feb 25, 2022 at 05:14:13PM +0000, Svenning Sørensen wrote:
> gregkh@linuxfoundation wrote: 
> 
> >> The patch below does not apply to the 5.16-stable tree.
> >> If someone wants it applied there, or to any other stable or longterm
> >> tree, then please email the backport, including the original git commit
> >> id to <stable@vger.kernel.org>.
> ...
> >> ------------------ original commit in Linus's tree ------------------
> >>>From 3d00827a90db6f79abc7cdc553887f89a2e0a184 Mon Sep 17 00:00:00 2001
> 
> Hi Greg,
> 
> That's strange - it applies just fine without errors here:
> 
> --- snip ---
> $ git log --oneline -n 1
> f40e0f7a433b (HEAD -> linux-5.16.y, tag: v5.16.11, stable/linux-5.16.y) Linux 5.16.11
> $ git cherry-pick -x 3d00827a90db6f79abc7cdc553887f89a2e0a184
> [linux-5.16.y e1e17aca71a0] net: dsa: microchip: fix bridging with more than two member ports
>  Date: Fri Feb 18 11:27:01 2022 +0000
>  1 file changed, 23 insertions(+), 3 deletions(-)
> --- snip ---
> 
> So I'm not sure what's needed for backporting?

Try building it :)

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

* Sv: FAILED: patch "[PATCH] net: dsa: microchip: fix bridging with more than two member" failed to apply to 5.16-stable tree
       [not found]     ` <DB7PR08MB3867F9A962DA7A3B13408C12B53F9@DB7PR08MB3867.eurprd08.prod.outlook.com>
@ 2022-02-26 13:17       ` Svenning Sørensen
  2022-02-28 10:58         ` gregkh
  0 siblings, 1 reply; 5+ messages in thread
From: Svenning Sørensen @ 2022-02-26 13:17 UTC (permalink / raw)
  To: gregkh, David S. Miller, Oleksij Rempel; +Cc: stable

Commit b3612ccdf284 ("net: dsa: microchip: implement multi-bridge support")
plugged a packet leak between ports that were members of different bridges.
Unfortunately, this broke another use case, namely that of more than two
ports that are members of the same bridge.

After that commit, when a port is added to a bridge, hardware bridging
between other member ports of that bridge will be cleared, preventing
packet exchange between them.

Fix by ensuring that the Port VLAN Membership bitmap includes any existing
ports in the bridge, not just the port being added.

Upstream commit 3d00827a90db6f79abc7cdc553887f89a2e0a184, backported to 5.16.

Fixes: b3612ccdf284 ("net: dsa: microchip: implement multi-bridge support")
Signed-off-by: Svenning Sørensen <sss@secomea.com>
Tested-by: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
---
 drivers/net/dsa/microchip/ksz_common.c | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index 8a04302018dc..7ab9ab58de65 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -26,7 +26,7 @@ void ksz_update_port_member(struct ksz_device *dev, int port)
        struct dsa_switch *ds = dev->ds;
        u8 port_member = 0, cpu_port;
        const struct dsa_port *dp;
-       int i;
+       int i, j;

        if (!dsa_is_user_port(ds, port))
                return;
@@ -45,13 +45,33 @@ void ksz_update_port_member(struct ksz_device *dev, int port)
                        continue;
                if (!dp->bridge_dev || dp->bridge_dev != other_dp->bridge_dev)
                        continue;
+               if (other_p->stp_state != BR_STATE_FORWARDING)
+                       continue;

-               if (other_p->stp_state == BR_STATE_FORWARDING &&
-                   p->stp_state == BR_STATE_FORWARDING) {
+               if (p->stp_state == BR_STATE_FORWARDING) {
                        val |= BIT(port);
                        port_member |= BIT(i);
                }

+               /* Retain port [i]'s relationship to other ports than [port] */
+               for (j = 0; j < ds->num_ports; j++) {
+                       const struct dsa_port *third_dp;
+                       struct ksz_port *third_p;
+
+                       if (j == i)
+                               continue;
+                       if (j == port)
+                               continue;
+                       if (!dsa_is_user_port(ds, j))
+                               continue;
+                       third_p = &dev->ports[j];
+                       if (third_p->stp_state != BR_STATE_FORWARDING)
+                               continue;
+                       third_dp = dsa_to_port(ds, j);
+                       if (third_dp->bridge_dev == dp->bridge_dev)
+                               val |= BIT(j);
+               }
+
                dev->dev_ops->cfg_port_member(dev, i, val | cpu_port);
        }

--
2.20.1

Backported upstream commit 3d00827a90db6f79abc7cdc553887f89a2e0a184 to 5.16.
Sorry about the subject; the MS webmail client doesn't seem allow me to change it when
replying to a message :(

Svenning

________________________________________
Fra: Svenning Sørensen <sss@secomea.com>
Sendt: 26. februar 2022 14:04
Til: gregkh@linuxfoundation.org
Emne: Sv: FAILED: patch "[PATCH] net: dsa: microchip: fix bridging with more than two member" failed to apply to 5.16-stable tree

gregkh@linuxfoundation wrote:
> >> The patch below does not apply to the 5.16-stable tree.
> >> ------------------ original commit in Linus's tree ------------------
> >>>From 3d00827a90db6f79abc7cdc553887f89a2e0a184 Mon Sep 17 00:00:00 2001
...
> > That's strange - it applies just fine without errors here:
> Try building it :)

Argh, yes, I should have thought of that - Sorry :)

It depended on another patch (implementing dsa_port_bridge_same()) which is
not in the 5.16 tree.

I'll send a properly backported version (which has been both compiled and
runtime tested) in a reply to this message; I hope this is a workable approach,
as I'm not really familiar with your workflow.

Best regards,
Svenning Sørensen

________________________________________
Fra: gregkh@linuxfoundation.org <gregkh@linuxfoundation.org>
Sendt: 26. februar 2022 08:38
Til: Svenning Sørensen
Cc: davem@davemloft.net; o.rempel@pengutronix.de; stable@vger.kernel.org
Emne: Re: FAILED: patch "[PATCH] net: dsa: microchip: fix bridging with more than two member" failed to apply to 5.16-stable tree

On Fri, Feb 25, 2022 at 05:14:13PM +0000, Svenning Sørensen wrote:
> gregkh@linuxfoundation wrote:
>
> >> The patch below does not apply to the 5.16-stable tree.
> >> If someone wants it applied there, or to any other stable or longterm
> >> tree, then please email the backport, including the original git commit
> >> id to <stable@vger.kernel.org>.
> ...
> >> ------------------ original commit in Linus's tree ------------------
> >>>From 3d00827a90db6f79abc7cdc553887f89a2e0a184 Mon Sep 17 00:00:00 2001
>
> Hi Greg,
>
> That's strange - it applies just fine without errors here:
>
> --- snip ---
> $ git log --oneline -n 1
> f40e0f7a433b (HEAD -> linux-5.16.y, tag: v5.16.11, stable/linux-5.16.y) Linux 5.16.11
> $ git cherry-pick -x 3d00827a90db6f79abc7cdc553887f89a2e0a184
> [linux-5.16.y e1e17aca71a0] net: dsa: microchip: fix bridging with more than two member ports
>  Date: Fri Feb 18 11:27:01 2022 +0000
>  1 file changed, 23 insertions(+), 3 deletions(-)
> --- snip ---
>
> So I'm not sure what's needed for backporting?

Try building it :)

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

* Re: Sv: FAILED: patch "[PATCH] net: dsa: microchip: fix bridging with more than two member" failed to apply to 5.16-stable tree
  2022-02-26 13:17       ` Sv: " Svenning Sørensen
@ 2022-02-28 10:58         ` gregkh
  0 siblings, 0 replies; 5+ messages in thread
From: gregkh @ 2022-02-28 10:58 UTC (permalink / raw)
  To: Svenning Sørensen; +Cc: David S. Miller, Oleksij Rempel, stable

On Sat, Feb 26, 2022 at 01:17:11PM +0000, Svenning Sørensen wrote:
> Commit b3612ccdf284 ("net: dsa: microchip: implement multi-bridge support")
> plugged a packet leak between ports that were members of different bridges.
> Unfortunately, this broke another use case, namely that of more than two
> ports that are members of the same bridge.
> 
> After that commit, when a port is added to a bridge, hardware bridging
> between other member ports of that bridge will be cleared, preventing
> packet exchange between them.
> 
> Fix by ensuring that the Port VLAN Membership bitmap includes any existing
> ports in the bridge, not just the port being added.
> 
> Upstream commit 3d00827a90db6f79abc7cdc553887f89a2e0a184, backported to 5.16.
> 
> Fixes: b3612ccdf284 ("net: dsa: microchip: implement multi-bridge support")
> Signed-off-by: Svenning Sørensen <sss@secomea.com>
> Tested-by: Oleksij Rempel <o.rempel@pengutronix.de>
> Signed-off-by: David S. Miller <davem@davemloft.net>
> ---
>  drivers/net/dsa/microchip/ksz_common.c | 26 +++++++++++++++++++++++---
>  1 file changed, 23 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
> index 8a04302018dc..7ab9ab58de65 100644
> --- a/drivers/net/dsa/microchip/ksz_common.c
> +++ b/drivers/net/dsa/microchip/ksz_common.c
> @@ -26,7 +26,7 @@ void ksz_update_port_member(struct ksz_device *dev, int port)
>         struct dsa_switch *ds = dev->ds;
>         u8 port_member = 0, cpu_port;
>         const struct dsa_port *dp;
> -       int i;
> +       int i, j;
> 
>         if (!dsa_is_user_port(ds, port))
>                 return;
> @@ -45,13 +45,33 @@ void ksz_update_port_member(struct ksz_device *dev, int port)
>                         continue;
>                 if (!dp->bridge_dev || dp->bridge_dev != other_dp->bridge_dev)
>                         continue;
> +               if (other_p->stp_state != BR_STATE_FORWARDING)
> +                       continue;
> 
> -               if (other_p->stp_state == BR_STATE_FORWARDING &&
> -                   p->stp_state == BR_STATE_FORWARDING) {
> +               if (p->stp_state == BR_STATE_FORWARDING) {
>                         val |= BIT(port);
>                         port_member |= BIT(i);
>                 }
> 
> +               /* Retain port [i]'s relationship to other ports than [port] */
> +               for (j = 0; j < ds->num_ports; j++) {
> +                       const struct dsa_port *third_dp;
> +                       struct ksz_port *third_p;
> +
> +                       if (j == i)
> +                               continue;
> +                       if (j == port)
> +                               continue;
> +                       if (!dsa_is_user_port(ds, j))
> +                               continue;
> +                       third_p = &dev->ports[j];
> +                       if (third_p->stp_state != BR_STATE_FORWARDING)
> +                               continue;
> +                       third_dp = dsa_to_port(ds, j);
> +                       if (third_dp->bridge_dev == dp->bridge_dev)
> +                               val |= BIT(j);
> +               }
> +
>                 dev->dev_ops->cfg_port_member(dev, i, val | cpu_port);
>         }
> 
> --
> 2.20.1
> 

Patch is whitespace corrupted (tabs -> spaces) and can not be applied at
all :(

Please fix up and resend.

thanks,

greg k-h

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

end of thread, other threads:[~2022-02-28 10:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-25 16:16 FAILED: patch "[PATCH] net: dsa: microchip: fix bridging with more than two member" failed to apply to 5.16-stable tree gregkh
2022-02-25 17:14 ` Svenning Sørensen
2022-02-26  7:38   ` gregkh
     [not found]     ` <DB7PR08MB3867F9A962DA7A3B13408C12B53F9@DB7PR08MB3867.eurprd08.prod.outlook.com>
2022-02-26 13:17       ` Sv: " Svenning Sørensen
2022-02-28 10:58         ` gregkh

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.