Skip to content

Commit 5c08d7e

Browse files
Linus Walleijgregkh
authored andcommitted
net: dsa: rtl8366: Check VLAN ID and not ports
[ Upstream commit e8521e5 ] There has been some confusion between the port number and the VLAN ID in this driver. What we need to check for validity is the VLAN ID, nothing else. The current confusion came from assigning a few default VLANs for default routing and we need to rewrite that properly. Instead of checking if the port number is a valid VLAN ID, check the actual VLAN IDs passed in to the callback one by one as expected. Fixes: d865295 ("net: dsa: realtek-smi: Add Realtek SMI driver") Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 3c1f070 commit 5c08d7e

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

drivers/net/dsa/rtl8366.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -339,10 +339,12 @@ int rtl8366_vlan_prepare(struct dsa_switch *ds, int port,
339339
const struct switchdev_obj_port_vlan *vlan)
340340
{
341341
struct realtek_smi *smi = ds->priv;
342+
u16 vid;
342343
int ret;
343344

344-
if (!smi->ops->is_vlan_valid(smi, port))
345-
return -EINVAL;
345+
for (vid = vlan->vid_begin; vid < vlan->vid_end; vid++)
346+
if (!smi->ops->is_vlan_valid(smi, vid))
347+
return -EINVAL;
346348

347349
dev_info(smi->dev, "prepare VLANs %04x..%04x\n",
348350
vlan->vid_begin, vlan->vid_end);
@@ -370,8 +372,9 @@ void rtl8366_vlan_add(struct dsa_switch *ds, int port,
370372
u16 vid;
371373
int ret;
372374

373-
if (!smi->ops->is_vlan_valid(smi, port))
374-
return;
375+
for (vid = vlan->vid_begin; vid < vlan->vid_end; vid++)
376+
if (!smi->ops->is_vlan_valid(smi, vid))
377+
return;
375378

376379
dev_info(smi->dev, "add VLAN on port %d, %s, %s\n",
377380
port,

0 commit comments

Comments
 (0)