hv_netvsc: Add support to set MTU reservation from guest side
Subsystems (3)
Haiyang Zhang
maintainerPATCH 1/1 hv_netvsc: Add support to set MTU reservation from guest side
When packet encapsulation is in use, the MTU needs to be reduced for headroom reservation.
The existing code takes the updated MTU value only from the host side. But vSwitch extensions, such as Open vSwitch, require the flexibility to change the MTU to different values from within a guest during the lifecycle of a vNIC, when the encapsulation protocol is changed. The patch supports this kind of MTU changes.
--- drivers/net/hyperv/netvsc_drv.c | 3 +-- drivers/net/hyperv/rndis_filter.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-)
drivers/net/hyperv/netvsc_drv.c +1 -2
@@ -743,8 +743,7 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu)if (nvdev->nvsp_version >=NVSP_PROTOCOL_VERSION_2 ) limit =NETVSC_MTU -ETH_HLEN ; -/* Hyper-V hosts don't support MTU < ETH_DATA_LEN (1500) */ -if (mtu <ETH_DATA_LEN || mtu > limit) +if (mtu <68 || mtu > limit)return -EINVAL ; nvdev->start_remove = true;
drivers/net/hyperv/rndis_filter.c +1 -1
@@ -1053,7 +1053,7 @@ int rndis_filter_device_add(struct hv_device *dev, ret =rndis_filter_query_device (rndis_device,RNDIS_OID_GEN_MAXIMUM_FRAME_SIZE , &mtu, &size); -if (ret ==0 && size ==sizeof (u32)) +if (ret ==0 && size ==sizeof (u32) && mtu < net_device->ndev->mtu) net_device->ndev->mtu = mtu;/* Get the mac address */
Signature · 1 line
1.7.4.1
Quoted 20 lines · Haiyang Zhang
When packet encapsulation is in use, the MTU needs to be reduced for headroom reservation.
The existing code takes the updated MTU value only from the host side. But vSwitch extensions, such as Open vSwitch, require the flexibility to change the MTU to different values from within a guest during the lifecycle of a vNIC, when the encapsulation protocol is changed. The patch supports this kind of MTU changes.Signed-off-by Haiyang Zhang <[email protected]>Reviewed-by K. Y. Srinivasan <[email protected]>--- drivers/net/hyperv/netvsc_drv.c | 3 +-- drivers/net/hyperv/rndis_filter.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-)drivers/net/hyperv/netvsc_drv.c +0
-0
drivers/net/hyperv/netvsc_drv.c static int netvsc_change_mtu(struct net_device *ndev, int mtu) · line 746
Quoted 6 lines
drivers/net/hyperv/netvsc_drv.c +1
-2@@ -743,8 +743,7 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu)if (nvdev->nvsp_version >=NVSP_PROTOCOL_VERSION_2 ) limit =NETVSC_MTU -ETH_HLEN ; -/* Hyper-V hosts don't support MTU < ETH_DATA_LEN (1500) */ -if (mtu <ETH_DATA_LEN || mtu > limit) +if (mtu <68 || mtu > limit)
How did you calculate 68? Avoid magic numbers like this, make it a define.
regards,
dan carpenter
David Miller
maintainerFrom: Dan Carpenter <[email protected]>
Date: Fri, 3 Jul 2015 14:28:47 +0300
Quoted 24 lines · Haiyang Zhang
Quoted 23 lines
When packet encapsulation is in use, the MTU needs to be reduced for headroom reservation.
The existing code takes the updated MTU value only from the host side. But vSwitch extensions, such as Open vSwitch, require the flexibility to change the MTU to different values from within a guest during the lifecycle of a vNIC, when the encapsulation protocol is changed. The patch supports this kind of MTU changes.Signed-off-by Haiyang Zhang <[email protected]>Reviewed-by K. Y. Srinivasan <[email protected]>--- drivers/net/hyperv/netvsc_drv.c | 3 +-- drivers/net/hyperv/rndis_filter.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-)drivers/net/hyperv/netvsc_drv.c +0
-0@@ -743,8 +743,7 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu)if (nvdev->nvsp_version >=NVSP_PROTOCOL_VERSION_2 ) limit =NETVSC_MTU -ETH_HLEN ;
Quoted 6 lines
drivers/net/hyperv/netvsc_drv.c static int netvsc_change_mtu(struct net_device *ndev, int mtu) · line 746
Quoted 3 lines
drivers/net/hyperv/netvsc_drv.c +1
-2-/* Hyper-V hosts don't support MTU < ETH_DATA_LEN (1500) */ -if (mtu <ETH_DATA_LEN || mtu > limit) +if (mtu <68 || mtu > limit)How did you calculate 68? Avoid magic numbers like this, make it a define.
Agreed.
Haiyang Zhang
maintainerQuoted 41 lines
-----Original Message-----
From: David Miller [mailto:[email protected]]
Sent: Friday, July 3, 2015 12:17 PM
To: [email protected]
Cc: Haiyang Zhang; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]
Subject: Re: [PATCH net-next]hv_netvsc: Add support to set MTU reservation from guest sideFrom: Dan Carpenter <[email protected]>
Date: Fri, 3 Jul 2015 14:28:47 +0300Quoted 9 lines · Haiyang Zhang
Quoted 8 lines
When packet encapsulation is in use, the MTU needs to be reduced for headroom reservation.
The existing code takes the updated MTU value only from the host side. But vSwitch extensions, such as Open vSwitch, require the flexibility to change the MTU to different values from within a guest during the lifecycle of a vNIC, when the encapsulation protocol is changed. The patch supports this kind of MTU changes.Quoted 8 lines
Review
Quoted 8 lines
Signed-off-by Haiyang Zhang <[email protected]>Reviewed-by K. Y. Srinivasan <[email protected]>--- drivers/net/hyperv/netvsc_drv.c | 3 +-- drivers/net/hyperv/rndis_filter.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-)(quoted diff) +0
-0
b/drivers/net/hyperv/netvsc_drv.cQuoted 4 lines
drivers/net/hyperv/netvsc_drv.c static int netvsc_change_mtu(struct net_device
Quoted 4 lines
index 358475e..68e7ece 100644
drivers/net/hyperv/netvsc_drv.c +0
-0@@ -743,8 +743,7 @@ static int netvsc_change_mtu(struct net_device*ndev, int mtu)
Quoted 3 lines
Quoted 3 lines
drivers/net/hyperv/netvsc_drv.c +0
-0if (nvdev->nvsp_version >=NVSP_PROTOCOL_VERSION_2 ) limit =NETVSC_MTU -ETH_HLEN ;
Quoted 8 lines
Quoted 6 lines
drivers/net/hyperv/netvsc_drv.c static int netvsc_change_mtu(struct net_device *ndev, int mtu) · line 746
Quoted 3 lines
drivers/net/hyperv/netvsc_drv.c +1
-2-/* Hyper-V hosts don't support MTU < ETH_DATA_LEN (1500) */ -if (mtu <ETH_DATA_LEN || mtu > limit) +if (mtu <68 || mtu > limit)How did you calculate 68? Avoid magic numbers like this, make it a define.
Agreed.
The number 68 is same as the common code in eth_change_mtu(). I think it came from the protocol requirement:
https://en.wikipedia.org/wiki/Maximum_transmission_unit
Sure, I will put the number in a define, and resubmit the patch.
Thanks,
- Haiyang