diff mbox series

[net,1/2] net/mlx4_en: Change min MTU size to ETH_MIN_MTU

Message ID 1543754077-18643-2-git-send-email-tariqt@mellanox.com
State Accepted, archived
Delegated to: David Miller
Headers show
Series [net,1/2] net/mlx4_en: Change min MTU size to ETH_MIN_MTU | expand

Commit Message

Tariq Toukan Dec. 2, 2018, 12:34 p.m. UTC
From: Eran Ben Elisha <eranbe@mellanox.com>

NIC driver minimal MTU size shall be set to ETH_MIN_MTU, as defined in
the RFC791 and in the network stack. Remove old mlx4_en only define for
it, which was set to wrong value.

Fixes: b80f71f5816f ("ethernet/mellanox: use core min/max MTU checking")
Signed-off-by: Eran Ben Elisha <eranbe@mellanox.com>
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 4 ++--
 drivers/net/ethernet/mellanox/mlx4/mlx4_en.h   | 1 -
 2 files changed, 2 insertions(+), 3 deletions(-)

Comments

David Laight Dec. 4, 2018, 4:59 p.m. UTC | #1
From: Tariq Toukan
> Sent: 02 December 2018 12:35
> From: Eran Ben Elisha <eranbe@mellanox.com>
> 
> NIC driver minimal MTU size shall be set to ETH_MIN_MTU, as defined in
> the RFC791 and in the network stack. Remove old mlx4_en only define for
> it, which was set to wrong value.
...
> 
> -	/* MTU range: 46 - hw-specific max */
> -	dev->min_mtu = MLX4_EN_MIN_MTU;
> +	/* MTU range: 68 - hw-specific max */
> +	dev->min_mtu = ETH_MIN_MTU;
>  	dev->max_mtu = priv->max_mtu;

Where does 68 come from?
The minimum size of an ethernet packet including the mac addresses
and CRC is 64 bytes - but that would never be an 'mtu'.

Since 64 - 46 = 18, the 46 probably excludes both MAC addresses,
the ethertype/length and the CRC.
This is 'sort of' the minimum mtu for an ethernet frame.

I'm not sure which values are supposed to be in dev->min/max_mtu.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Eric Dumazet Dec. 4, 2018, 5:04 p.m. UTC | #2
On 12/04/2018 08:59 AM, David Laight wrote:
> From: Tariq Toukan
>> Sent: 02 December 2018 12:35
>> From: Eran Ben Elisha <eranbe@mellanox.com>
>>
>> NIC driver minimal MTU size shall be set to ETH_MIN_MTU, as defined in
>> the RFC791 and in the network stack. Remove old mlx4_en only define for
>> it, which was set to wrong value.
> ...
>>
>> -	/* MTU range: 46 - hw-specific max */
>> -	dev->min_mtu = MLX4_EN_MIN_MTU;
>> +	/* MTU range: 68 - hw-specific max */
>> +	dev->min_mtu = ETH_MIN_MTU;
>>  	dev->max_mtu = priv->max_mtu;
> 
> Where does 68 come from?

Min IPv4 MTU per RFC791

> The minimum size of an ethernet packet including the mac addresses
> and CRC is 64 bytes - but that would never be an 'mtu'.
> 
> Since 64 - 46 = 18, the 46 probably excludes both MAC addresses,
> the ethertype/length and the CRC.
> This is 'sort of' the minimum mtu for an ethernet frame.
> 
> I'm not sure which values are supposed to be in dev->min/max_mtu.

I am not sure we really care, only syzkaller can possibly.
David Laight Dec. 4, 2018, 5:17 p.m. UTC | #3
From: Eric Dumazet
> Sent: 04 December 2018 17:04
> 
> On 12/04/2018 08:59 AM, David Laight wrote:
> > From: Tariq Toukan
> >> Sent: 02 December 2018 12:35
> >> From: Eran Ben Elisha <eranbe@mellanox.com>
> >>
> >> NIC driver minimal MTU size shall be set to ETH_MIN_MTU, as defined in
> >> the RFC791 and in the network stack. Remove old mlx4_en only define for
> >> it, which was set to wrong value.
> > ...
> >>
> >> -	/* MTU range: 46 - hw-specific max */
> >> -	dev->min_mtu = MLX4_EN_MIN_MTU;
> >> +	/* MTU range: 68 - hw-specific max */
> >> +	dev->min_mtu = ETH_MIN_MTU;
> >>  	dev->max_mtu = priv->max_mtu;
> >
> > Where does 68 come from?
> 
> Min IPv4 MTU per RFC791

Which has nothing to do with an ethernet driver.
Indeed, IIRC, it is the smallest maximum frame size that IPv4
can work over.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
David Laight Dec. 4, 2018, 5:21 p.m. UTC | #4
From: Eric Dumazet
> Sent: 04 December 2018 17:04
> On 12/04/2018 08:59 AM, David Laight wrote:
> > From: Tariq Toukan
> >> Sent: 02 December 2018 12:35
> >> From: Eran Ben Elisha <eranbe@mellanox.com>
> >>
> >> NIC driver minimal MTU size shall be set to ETH_MIN_MTU, as defined in
> >> the RFC791 and in the network stack. Remove old mlx4_en only define for
> >> it, which was set to wrong value.
> > ...
> >>
> >> -	/* MTU range: 46 - hw-specific max */
> >> -	dev->min_mtu = MLX4_EN_MIN_MTU;
> >> +	/* MTU range: 68 - hw-specific max */
> >> +	dev->min_mtu = ETH_MIN_MTU;
> >>  	dev->max_mtu = priv->max_mtu;
> >
> > Where does 68 come from?
> 
> Min IPv4 MTU per RFC791

Maybe I'm just confused and these are the ranges that the 'maximum mtu'
can be set to.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Cong Wang Dec. 5, 2018, 5:24 a.m. UTC | #5
On Tue, Dec 4, 2018 at 9:06 AM Eric Dumazet <eric.dumazet@gmail.com> wrote:
>
>
>
> On 12/04/2018 08:59 AM, David Laight wrote:
> > Where does 68 come from?
>
> Min IPv4 MTU per RFC791
>

What's wrong with using IPV4_MIN_MTU instead of 68
even in just comment?
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index b744cd49a785..6b88881b8e35 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -3493,8 +3493,8 @@  int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
 		dev->gso_partial_features = NETIF_F_GSO_UDP_TUNNEL_CSUM;
 	}
 
-	/* MTU range: 46 - hw-specific max */
-	dev->min_mtu = MLX4_EN_MIN_MTU;
+	/* MTU range: 68 - hw-specific max */
+	dev->min_mtu = ETH_MIN_MTU;
 	dev->max_mtu = priv->max_mtu;
 
 	mdev->pndev[port] = dev;
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
index 485d856546c6..8137454e2534 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
@@ -161,7 +161,6 @@ 
 #define MLX4_SELFTEST_LB_MIN_MTU (MLX4_LOOPBACK_TEST_PAYLOAD + NET_IP_ALIGN + \
 				  ETH_HLEN + PREAMBLE_LEN)
 
-#define MLX4_EN_MIN_MTU		46
 /* VLAN_HLEN is added twice,to support skb vlan tagged with multiple
  * headers. (For example: ETH_P_8021Q and ETH_P_8021AD).
  */