All of lore.kernel.org
 help / color / mirror / Atom feed
* [net-next PATCH] net: dsa: rtl8366: Properly clear member config
@ 2020-09-05 10:32 Linus Walleij
  2020-09-06 17:40 ` Jakub Kicinski
  0 siblings, 1 reply; 4+ messages in thread
From: Linus Walleij @ 2020-09-05 10:32 UTC (permalink / raw)
  To: Andrew Lunn, Vivien Didelot, Florian Fainelli, netdev, David S . Miller
  Cc: Linus Walleij

When removing a port from a VLAN we are just erasing the
member config for the VLAN, which is wrong: other ports
can be using it.

Just mask off the port and only zero out the rest of the
member config once ports using of the VLAN are removed
from it.

Reported-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/net/dsa/rtl8366.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/net/dsa/rtl8366.c b/drivers/net/dsa/rtl8366.c
index 2dcde7a91721..bd3c947976ce 100644
--- a/drivers/net/dsa/rtl8366.c
+++ b/drivers/net/dsa/rtl8366.c
@@ -471,13 +471,19 @@ int rtl8366_vlan_del(struct dsa_switch *ds, int port,
 				return ret;
 
 			if (vid == vlanmc.vid) {
-				/* clear VLAN member configurations */
-				vlanmc.vid = 0;
-				vlanmc.priority = 0;
-				vlanmc.member = 0;
-				vlanmc.untag = 0;
-				vlanmc.fid = 0;
-
+				/* Remove this port from the VLAN */
+				vlanmc.member &= ~BIT(port);
+				vlanmc.untag &= ~BIT(port);
+				/*
+				 * If no ports are members of this VLAN
+				 * anymore then clear the whole member
+				 * config so it can be reused.
+				 */
+				if (!vlanmc.member && vlanmc.untag) {
+					vlanmc.vid = 0;
+					vlanmc.priority = 0;
+					vlanmc.fid = 0;
+				}
 				ret = smi->ops->set_vlan_mc(smi, i, &vlanmc);
 				if (ret) {
 					dev_err(smi->dev,
-- 
2.26.2


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

* Re: [net-next PATCH] net: dsa: rtl8366: Properly clear member config
  2020-09-05 10:32 [net-next PATCH] net: dsa: rtl8366: Properly clear member config Linus Walleij
@ 2020-09-06 17:40 ` Jakub Kicinski
  2020-09-06 19:23   ` Linus Walleij
  0 siblings, 1 reply; 4+ messages in thread
From: Jakub Kicinski @ 2020-09-06 17:40 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Andrew Lunn, Vivien Didelot, Florian Fainelli, netdev, David S . Miller

On Sat,  5 Sep 2020 12:32:33 +0200 Linus Walleij wrote:
> When removing a port from a VLAN we are just erasing the
> member config for the VLAN, which is wrong: other ports
> can be using it.
> 
> Just mask off the port and only zero out the rest of the
> member config once ports using of the VLAN are removed
> from it.
> 
> Reported-by: Florian Fainelli <f.fainelli@gmail.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

I see you labeled this for net-net, but it reads like a fix, is it not?

Fixes: d8652956cf37 ("net: dsa: realtek-smi: Add Realtek SMI driver")

Like commit 15ab7906cc92 ("net: dsa: rtl8366: Fix VLAN semantics") had?

> diff --git a/drivers/net/dsa/rtl8366.c b/drivers/net/dsa/rtl8366.c
> index 2dcde7a91721..bd3c947976ce 100644
> --- a/drivers/net/dsa/rtl8366.c
> +++ b/drivers/net/dsa/rtl8366.c
> @@ -471,13 +471,19 @@ int rtl8366_vlan_del(struct dsa_switch *ds, int port,
>  				return ret;
>  
>  			if (vid == vlanmc.vid) {
> -				/* clear VLAN member configurations */
> -				vlanmc.vid = 0;
> -				vlanmc.priority = 0;
> -				vlanmc.member = 0;
> -				vlanmc.untag = 0;
> -				vlanmc.fid = 0;
> -
> +				/* Remove this port from the VLAN */
> +				vlanmc.member &= ~BIT(port);
> +				vlanmc.untag &= ~BIT(port);
> +				/*
> +				 * If no ports are members of this VLAN
> +				 * anymore then clear the whole member
> +				 * config so it can be reused.
> +				 */
> +				if (!vlanmc.member && vlanmc.untag) {
> +					vlanmc.vid = 0;
> +					vlanmc.priority = 0;
> +					vlanmc.fid = 0;
> +				}
>  				ret = smi->ops->set_vlan_mc(smi, i, &vlanmc);
>  				if (ret) {
>  					dev_err(smi->dev,


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

* Re: [net-next PATCH] net: dsa: rtl8366: Properly clear member config
  2020-09-06 17:40 ` Jakub Kicinski
@ 2020-09-06 19:23   ` Linus Walleij
  2020-09-06 19:34     ` Jakub Kicinski
  0 siblings, 1 reply; 4+ messages in thread
From: Linus Walleij @ 2020-09-06 19:23 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Andrew Lunn, Vivien Didelot, Florian Fainelli, netdev, David S . Miller

On Sun, Sep 6, 2020 at 7:41 PM Jakub Kicinski <kuba@kernel.org> wrote:
> On Sat,  5 Sep 2020 12:32:33 +0200 Linus Walleij wrote:
> > When removing a port from a VLAN we are just erasing the
> > member config for the VLAN, which is wrong: other ports
> > can be using it.
> >
> > Just mask off the port and only zero out the rest of the
> > member config once ports using of the VLAN are removed
> > from it.
> >
> > Reported-by: Florian Fainelli <f.fainelli@gmail.com>
> > Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
>
> I see you labeled this for net-net, but it reads like a fix, is it not?
>
> Fixes: d8652956cf37 ("net: dsa: realtek-smi: Add Realtek SMI driver")
>
> Like commit 15ab7906cc92 ("net: dsa: rtl8366: Fix VLAN semantics") had?

Yes you're right, also it is pretty separate from the other patches to
this driver so there shouldn't be any annoying conflicts.

If you're applying the patch could you add it
in the process, or do you want me to resend?

Yours,
Linus Walleij

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

* Re: [net-next PATCH] net: dsa: rtl8366: Properly clear member config
  2020-09-06 19:23   ` Linus Walleij
@ 2020-09-06 19:34     ` Jakub Kicinski
  0 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2020-09-06 19:34 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Andrew Lunn, Vivien Didelot, Florian Fainelli, netdev, David S . Miller

On Sun, 6 Sep 2020 21:23:37 +0200 Linus Walleij wrote:
> On Sun, Sep 6, 2020 at 7:41 PM Jakub Kicinski <kuba@kernel.org> wrote:
> > On Sat,  5 Sep 2020 12:32:33 +0200 Linus Walleij wrote:  
> > > When removing a port from a VLAN we are just erasing the
> > > member config for the VLAN, which is wrong: other ports
> > > can be using it.
> > >
> > > Just mask off the port and only zero out the rest of the
> > > member config once ports using of the VLAN are removed
> > > from it.
> > >
> > > Reported-by: Florian Fainelli <f.fainelli@gmail.com>
> > > Signed-off-by: Linus Walleij <linus.walleij@linaro.org>  
> >
> > I see you labeled this for net-net, but it reads like a fix, is it not?
> >
> > Fixes: d8652956cf37 ("net: dsa: realtek-smi: Add Realtek SMI driver")
> >
> > Like commit 15ab7906cc92 ("net: dsa: rtl8366: Fix VLAN semantics") had?  
> 
> Yes you're right, also it is pretty separate from the other patches to
> this driver so there shouldn't be any annoying conflicts.
> 
> If you're applying the patch could you add it
> in the process, or do you want me to resend?

Done & applied to net, thank you!

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

end of thread, other threads:[~2020-09-06 19:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-05 10:32 [net-next PATCH] net: dsa: rtl8366: Properly clear member config Linus Walleij
2020-09-06 17:40 ` Jakub Kicinski
2020-09-06 19:23   ` Linus Walleij
2020-09-06 19:34     ` Jakub Kicinski

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.