Skip to content

Commit a42c8e3

Browse files
lunndavem330
authored andcommitted
net: dsa: Fix SWITCHDEV_ATTR_ID_PORT_PARENT_ID
SWITCHDEV_ATTR_ID_PORT_PARENT_ID is used by the software bridge when determining which ports to flood a packet out. If the packet originated from a switch, it assumes the switch has already flooded the packet out the switches ports, so the bridge should not flood the packet itself out switch ports. Ports on the same switch are expected to return the same parent ID when SWITCHDEV_ATTR_ID_PORT_PARENT_ID is called. DSA gets this wrong with clusters of switches. As far as the software bridge is concerned, the cluster is all one switch. A packet from any switch in the cluster can be assumed to have been flooded as needed out of all ports of the cluster, not just the switch it originated from. Hence all ports of a cluster should return the same parent. The old implementation did not, each switch in the cluster had its own ID. Also wrong was that the ID was not unique if multiple DSA instances are in operation. Use the tree ID as the parent ID, which is the same for all switches in a cluster and unique across switch clusters. Signed-off-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 8c5f9a8 commit a42c8e3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

net/dsa/slave.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,11 +355,12 @@ static int dsa_slave_port_attr_get(struct net_device *dev,
355355
{
356356
struct dsa_port *dp = dsa_slave_to_port(dev);
357357
struct dsa_switch *ds = dp->ds;
358+
struct dsa_switch_tree *dst = ds->dst;
358359

359360
switch (attr->id) {
360361
case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
361-
attr->u.ppid.id_len = sizeof(ds->index);
362-
memcpy(&attr->u.ppid.id, &ds->index, attr->u.ppid.id_len);
362+
attr->u.ppid.id_len = sizeof(dst->index);
363+
memcpy(&attr->u.ppid.id, &dst->index, attr->u.ppid.id_len);
363364
break;
364365
case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT:
365366
attr->u.brport_flags_support = 0;

0 commit comments

Comments
 (0)