Skip to content

Commit

Permalink
sfc: check MTU against minimum threshold
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Bert Kenward authored and David S. Miller committed Sep 6, 2016
1 parent f1e4ba5 commit 72a31d8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
12 changes: 11 additions & 1 deletion drivers/net/ethernet/sfc/efx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
3 changes: 3 additions & 0 deletions drivers/net/ethernet/sfc/net_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down

0 comments on commit 72a31d8

Please sign in to comment.