Re: [PATCH v3 net-next 2/2] net: deprecate eth_change_mtu, remove usage

From: Jakub Kicinski
Date: Mon Oct 17 2016 - 12:20:22 EST


On Fri, 7 Oct 2016 22:04:34 -0400, Jarod Wilson wrote:
> @@ -357,6 +356,8 @@ void ether_setup(struct net_device *dev)
> dev->type = ARPHRD_ETHER;
> dev->hard_header_len = ETH_HLEN;
> dev->mtu = ETH_DATA_LEN;
> + dev->min_mtu = ETH_MIN_MTU;
> + dev->max_mtu = ETH_DATA_LEN;
> dev->addr_len = ETH_ALEN;
> dev->tx_queue_len = 1000; /* Ethernet wants good queues */
> dev->flags = IFF_BROADCAST|IFF_MULTICAST;

This chunk seems to be breaking MTUs > 1500 for me.

On Fri, 7 Oct 2016 22:04:33 -0400, Jarod Wilson wrote:
> diff --git a/net/core/dev.c b/net/core/dev.c
> index f1fe26f..f376639 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -6499,9 +6499,18 @@ int dev_set_mtu(struct net_device *dev, int new_mtu)
> if (new_mtu == dev->mtu)
> return 0;
>
> - /* MTU must be positive. */
> - if (new_mtu < 0)
> + /* MTU must be positive, and in range */
> + if (new_mtu < 0 || new_mtu < dev->min_mtu) {
> + net_err_ratelimited("%s: Invalid MTU %d requested, hw min %d\n",
> + dev->name, new_mtu, dev->min_mtu);
> return -EINVAL;
> + }
> +
> + if (dev->max_mtu > 0 && new_mtu > dev->max_mtu) {
> + net_err_ratelimited("%s: Invalid MTU %d requested, hw max %d\n",
> + dev->name, new_mtu, dev->min_mtu);
> + return -EINVAL;
> + }

Please correct me if I'm wrong but it seems like we are now limiting
_all_ ethernet drivers to ETH_DATA_LEN in net-next.