Skip to content

Commit 636e8ad

Browse files
vladimirolteandavem330
authored andcommitted
net: dsa: don't error out when drivers return ETH_DATA_LEN in .port_max_mtu()
Currently, when dsa_slave_change_mtu() is called on a user port where dev->max_mtu is 1500 (as returned by ds->ops->port_max_mtu()), the code will stumble upon this check: if (new_master_mtu > mtu_limit) return -ERANGE; because new_master_mtu is adjusted for the tagger overhead but mtu_limit is not. But it would be good if the logic went through, for example if the DSA master really depends on an MTU adjustment to accept DSA-tagged frames. To make the code pass through the check, we need to adjust mtu_limit for the overhead as well, if the minimum restriction was caused by the DSA user port's MTU (dev->max_mtu). A DSA user port MTU and a DSA master MTU are always offset by the protocol overhead. Currently no drivers return 1500 .port_max_mtu(), but this is only temporary and a bug in itself - mv88e6xxx should have done that, but since commit b9c587f ("dsa: mv88e6xxx: Include tagger overhead when setting MTU for DSA and CPU ports") it no longer does. This is a preparation for fixing that. Fixes: bfcb813 ("net: dsa: configure the MTU for switch ports") Signed-off-by: Vladimir Oltean <[email protected]> Reviewed-by: Simon Horman <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b830c96 commit 636e8ad

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

net/dsa/slave.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1933,6 +1933,7 @@ int dsa_slave_change_mtu(struct net_device *dev, int new_mtu)
19331933
int new_master_mtu;
19341934
int old_master_mtu;
19351935
int mtu_limit;
1936+
int overhead;
19361937
int cpu_mtu;
19371938
int err;
19381939

@@ -1961,9 +1962,10 @@ int dsa_slave_change_mtu(struct net_device *dev, int new_mtu)
19611962
largest_mtu = slave_mtu;
19621963
}
19631964

1964-
mtu_limit = min_t(int, master->max_mtu, dev->max_mtu);
1965+
overhead = dsa_tag_protocol_overhead(cpu_dp->tag_ops);
1966+
mtu_limit = min_t(int, master->max_mtu, dev->max_mtu + overhead);
19651967
old_master_mtu = master->mtu;
1966-
new_master_mtu = largest_mtu + dsa_tag_protocol_overhead(cpu_dp->tag_ops);
1968+
new_master_mtu = largest_mtu + overhead;
19671969
if (new_master_mtu > mtu_limit)
19681970
return -ERANGE;
19691971

@@ -1998,8 +2000,7 @@ int dsa_slave_change_mtu(struct net_device *dev, int new_mtu)
19982000

19992001
out_port_failed:
20002002
if (new_master_mtu != old_master_mtu)
2001-
dsa_port_mtu_change(cpu_dp, old_master_mtu -
2002-
dsa_tag_protocol_overhead(cpu_dp->tag_ops));
2003+
dsa_port_mtu_change(cpu_dp, old_master_mtu - overhead);
20032004
out_cpu_failed:
20042005
if (new_master_mtu != old_master_mtu)
20052006
dev_set_mtu(master, old_master_mtu);

0 commit comments

Comments
 (0)