]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
net: dsa: properly fall back to software bridging
authorVladimir Oltean <vladimir.oltean@nxp.com>
Mon, 23 Aug 2021 21:22:56 +0000 (00:22 +0300)
committerDavid S. Miller <davem@davemloft.net>
Tue, 24 Aug 2021 08:30:58 +0000 (09:30 +0100)
If the driver does not implement .port_bridge_{join,leave}, then we must
fall back to standalone operation on that port, and trigger the error
path of dsa_port_bridge_join. This sets dp->bridge_dev = NULL.

In turn, having a non-NULL dp->bridge_dev when there is no offloading
support makes the following things go wrong:

- dsa_default_offload_fwd_mark make the wrong decision in setting
  skb->offload_fwd_mark. It should set skb->offload_fwd_mark = 0 for
  ports that don't offload the bridge, which should instruct the bridge
  to forward in software. But this does not happen, dp->bridge_dev is
  incorrectly set to point to the bridge, so the bridge is told that
  packets have been forwarded in hardware, which they haven't.

- switchdev objects (MDBs, VLANs) should not be offloaded by ports that
  don't offload the bridge. Standalone ports should behave as packet-in,
  packet-out and the bridge should not be able to manipulate the pvid of
  the port, or tag stripping on egress, or ingress filtering. This
  should already work fine because dsa_slave_port_obj_add has:

case SWITCHDEV_OBJ_ID_PORT_VLAN:
if (!dsa_port_offloads_bridge_port(dp, obj->orig_dev))
return -EOPNOTSUPP;

err = dsa_slave_vlan_add(dev, obj, extack);

  but since dsa_port_offloads_bridge_port works based on dp->bridge_dev,
  this is again sabotaging us.

All the above work in case the port has an unoffloaded LAG interface, so
this is well exercised code, we should apply it for plain unoffloaded
bridge ports too.

Reported-by: Alvin Šipraga <alsi@bang-olufsen.dk>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/dsa/slave.c
net/dsa/switch.c

index eb9d9e53c53610de9d6741f431f14d99135c600c..f785d24fcf2324f5978aa75e5baa7324bcda8672 100644 (file)
@@ -2009,6 +2009,11 @@ static int dsa_slave_changeupper(struct net_device *dev,
                        err = dsa_port_bridge_join(dp, info->upper_dev, extack);
                        if (!err)
                                dsa_bridge_mtu_normalization(dp);
+                       if (err == -EOPNOTSUPP) {
+                               NL_SET_ERR_MSG_MOD(extack,
+                                                  "Offloading not supported");
+                               err = 0;
+                       }
                        err = notifier_from_errno(err);
                } else {
                        dsa_port_bridge_leave(dp, info->upper_dev);
index fd1a1c6bf9cf2c8acaa49db14f9080097d218815..dd042fd7f800afb41fc54df19b28452a7c12c872 100644 (file)
@@ -92,8 +92,10 @@ static int dsa_switch_bridge_join(struct dsa_switch *ds,
        struct dsa_switch_tree *dst = ds->dst;
        int err;
 
-       if (dst->index == info->tree_index && ds->index == info->sw_index &&
-           ds->ops->port_bridge_join) {
+       if (dst->index == info->tree_index && ds->index == info->sw_index) {
+               if (!ds->ops->port_bridge_join)
+                       return -EOPNOTSUPP;
+
                err = ds->ops->port_bridge_join(ds, info->port, info->br);
                if (err)
                        return err;