diff mbox series

[v2,2/6] realtek: don't treat first multicast portmask entry as reserved

Message ID 20230506230535.1150881-3-jan@3e8.eu
State Accepted
Delegated to: Sander Vanheule
Headers show
Series realtek: fix management of mdb entries | expand

Commit Message

Jan Hoffmann May 6, 2023, 11:05 p.m. UTC
There doesn't appear to be a reason to do this, as only the last entry
is actually reserved for unknown multicast.

This also fixes two issues:
 - As the increment happened after the bounds check, the value of the
   actually reserved last entry could be overwritten.
 - On deletion of entries, a corresponding decrement was missing,
   causing the wrong entry to be marked as free.

Fixes: cde31976e375 ("realtek: Add support for Layer 2 Multicast")
Signed-off-by: Jan Hoffmann <jan@3e8.eu>
---
 target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c | 1 -
 target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c | 1 -
 2 files changed, 2 deletions(-)
diff mbox series

Patch

diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c
index fee63c36faa1..a9de70531237 100644
--- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c
+++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c
@@ -987,7 +987,6 @@  static int rtl83xx_mc_group_alloc(struct rtl838x_switch_priv *priv, int port)
 	}
 
 	set_bit(mc_group, priv->mc_group_bm);
-	mc_group++;  // We cannot use group 0, as this is used for lookup miss flooding
 	portmask = BIT_ULL(port) | BIT_ULL(priv->cpu_port); 
 	priv->r->write_mcast_pmask(mc_group, portmask);
 
diff --git a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c
index f9980ccacee1..90a6d6766051 100644
--- a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c
+++ b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c
@@ -974,7 +974,6 @@  static int rtl83xx_mc_group_alloc(struct rtl838x_switch_priv *priv, int port)
 	}
 
 	set_bit(mc_group, priv->mc_group_bm);
-	mc_group++;  /* We cannot use group 0, as this is used for lookup miss flooding */
 	portmask = BIT_ULL(port) | BIT_ULL(priv->cpu_port);
 	priv->r->write_mcast_pmask(mc_group, portmask);