Subject: Re: Minimum MTU Mess

From: Andrew Lunn <[email-masked]>
Date: Wed, 7 Sep 2016 22:31:12 +0200

Hi Jarod

> -	/*	MTU must be positive.	 */
> -	if (new_mtu < 0)
> +	if (new_mtu < dev->min_mtu) {
> +		netdev_err(dev, "Invalid MTU %d requested, hw min %d\n",
> +			   new_mtu, dev->min_mtu);
>  		return -EINVAL;
> +	}
> +
> +	if (new_mtu > dev->max_mtu) {
> +		netdev_err(dev, "Invalid MTU %d requested, hw max %d\n",
> +			   new_mtu, dev->min_mtu);
> +		return -EINVAL;
> +	}

I doubt you can make such a big change like this in one go. Can you
really guarantee all interfaces, of what ever type, will have some
value for dev->min_mtu and dev->max_mtu? What may fly is something
more like:

> +	if (dev->max_mtu && new_mtu > dev->max_mtu) {
> +		netdev_err(dev, "Invalid MTU %d requested, hw max %d\n",
> +			   new_mtu, dev->min_mtu);
> +		return -EINVAL;
> +	}

Maybe in a few cycles you can add a WARN_ON(!dev->max_mtu), and a few
cycles after that go with (new_mtu > dev->max_mtu).

  Andrew