sfc: check MTU against minimum threshold
authorBert Kenward <bkenward@solarflare.com>
Tue, 6 Sep 2016 16:50:00 +0000 (17:50 +0100)
committerDavid S. Miller <davem@davemloft.net>
Tue, 6 Sep 2016 23:54:18 +0000 (16:54 -0700)
Reported-by: Ma Yuying <yuma@redhat.com>
Suggested-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Bert Kenward <bkenward@solarflare.com>
Reviewed-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/sfc/efx.c
drivers/net/ethernet/sfc/net_driver.h

index f3826ae28bac5348ba8b6ba94ca88ad8de661e83..3cf3557106c22f335ca5e04d2065e01d41056572 100644 (file)
@@ -2263,8 +2263,18 @@ static int efx_change_mtu(struct net_device *net_dev, int new_mtu)
        rc = efx_check_disabled(efx);
        if (rc)
                return rc;
-       if (new_mtu > EFX_MAX_MTU)
+       if (new_mtu > EFX_MAX_MTU) {
+               netif_err(efx, drv, efx->net_dev,
+                         "Requested MTU of %d too big (max: %d)\n",
+                         new_mtu, EFX_MAX_MTU);
                return -EINVAL;
+       }
+       if (new_mtu < EFX_MIN_MTU) {
+               netif_err(efx, drv, efx->net_dev,
+                         "Requested MTU of %d too small (min: %d)\n",
+                         new_mtu, EFX_MIN_MTU);
+               return -EINVAL;
+       }
 
        netif_dbg(efx, drv, efx->net_dev, "changing MTU to %d\n", new_mtu);
 
index 0a2504b5dad53f0e6f2018ac18c3bfd0124bd67c..99d8c82124bb5e2541085f8e92521b9c01722354 100644 (file)
@@ -76,6 +76,9 @@
 /* Maximum possible MTU the driver supports */
 #define EFX_MAX_MTU (9 * 1024)
 
+/* Minimum MTU, from RFC791 (IP) */
+#define EFX_MIN_MTU 68
+
 /* Size of an RX scatter buffer.  Small enough to pack 2 into a 4K page,
  * and should be a multiple of the cache line size.
  */