]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mlxsw: spectrum_span: Support LAG under mirror-to-gretap
authorPetr Machata <petrm@mellanox.com>
Mon, 14 May 2018 06:40:44 +0000 (09:40 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 14 May 2018 20:41:43 +0000 (16:41 -0400)
When resolving a path that the packet will take after being encapsulated
in mirror-to-gretap scenarios, one of the devices en route could be a
LAG. In that case, mirror to first up slave that corresponds to a front
panel port.

Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c

index e5f4f7620ab70bc7cd9bf46439b5f7ddec26fc16..da3f7f527360147addf627e1a12ac87eced09e78 100644 (file)
@@ -245,6 +245,19 @@ mlxsw_sp_span_entry_vlan(const struct net_device *vlan_dev,
        return vlan_dev_real_dev(vlan_dev);
 }
 
+static struct net_device *
+mlxsw_sp_span_entry_lag(struct net_device *lag_dev)
+{
+       struct net_device *dev;
+       struct list_head *iter;
+
+       netdev_for_each_lower_dev(lag_dev, dev, iter)
+               if ((dev->flags & IFF_UP) && mlxsw_sp_port_dev_check(dev))
+                       return dev;
+
+       return NULL;
+}
+
 static __maybe_unused int
 mlxsw_sp_span_entry_tunnel_parms_common(struct net_device *edev,
                                        union mlxsw_sp_l3addr saddr,
@@ -278,6 +291,14 @@ mlxsw_sp_span_entry_tunnel_parms_common(struct net_device *edev,
                edev = mlxsw_sp_span_entry_vlan(edev, &vid);
        }
 
+       if (netif_is_lag_master(edev)) {
+               if (!(edev->flags & IFF_UP))
+                       goto unoffloadable;
+               edev = mlxsw_sp_span_entry_lag(edev);
+               if (!edev)
+                       goto unoffloadable;
+       }
+
        if (!mlxsw_sp_port_dev_check(edev))
                goto unoffloadable;