geneve: check MTU for a minimum in geneve_change_mtu()
authorAlexey Kodanev <alexey.kodanev@oracle.com>
Thu, 19 Apr 2018 12:42:31 +0000 (15:42 +0300)
committerDavid S. Miller <davem@davemloft.net>
Fri, 20 Apr 2018 15:20:05 +0000 (11:20 -0400)
geneve_change_mtu() will be used not only as ndo_change_mtu() callback,
but also to verify a user specified MTU on a new link creation in the
next patch.

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/geneve.c

index b650f84..ae649f6 100644 (file)
@@ -942,11 +942,10 @@ tx_error:
 
 static int geneve_change_mtu(struct net_device *dev, int new_mtu)
 {
-       /* Only possible if called internally, ndo_change_mtu path's new_mtu
-        * is guaranteed to be between dev->min_mtu and dev->max_mtu.
-        */
        if (new_mtu > dev->max_mtu)
                new_mtu = dev->max_mtu;
+       else if (new_mtu < dev->min_mtu)
+               new_mtu = dev->min_mtu;
 
        dev->mtu = new_mtu;
        return 0;