Skip to content

Commit

Permalink
net: dsa: suppress appending ethtool stats to LAG DSA masters
Browse files Browse the repository at this point in the history
Similar to the discussion about tracking the admin/oper state of LAG DSA
masters, we have the problem here that struct dsa_port *cpu_dp caches a
single pair of orig_ethtool_ops and netdev_ops pointers.

So if we call dsa_master_setup(bond0, cpu_dp) where cpu_dp is also the
dev->dsa_ptr of one of the physical DSA masters, we'd effectively
overwrite what we cached from that physical netdev with what replaced
from the bonding interface.

We don't need DSA ethtool stats on the bonding interface when used as
DSA master, it's good enough to have them just on the physical DSA
masters, so suppress this logic.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
  • Loading branch information
Vladimir Oltean authored and Paolo Abeni committed Sep 20, 2022
1 parent 6e61b55 commit cfeb84a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions net/dsa/master.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@ static int dsa_master_ethtool_setup(struct net_device *dev)
struct dsa_switch *ds = cpu_dp->ds;
struct ethtool_ops *ops;

if (netif_is_lag_master(dev))
return 0;

ops = devm_kzalloc(ds->dev, sizeof(*ops), GFP_KERNEL);
if (!ops)
return -ENOMEM;
Expand All @@ -250,13 +253,19 @@ static void dsa_master_ethtool_teardown(struct net_device *dev)
{
struct dsa_port *cpu_dp = dev->dsa_ptr;

if (netif_is_lag_master(dev))
return;

dev->ethtool_ops = cpu_dp->orig_ethtool_ops;
cpu_dp->orig_ethtool_ops = NULL;
}

static void dsa_netdev_ops_set(struct net_device *dev,
const struct dsa_netdevice_ops *ops)
{
if (netif_is_lag_master(dev))
return;

dev->dsa_ptr->netdev_ops = ops;
}

Expand Down

0 comments on commit cfeb84a

Please sign in to comment.