Skip to contentSkip to conversation

hv_netvsc: Add support to set MTU reservation from guest side

PATCH New Haiyang Zhang 1 participant 1 message Jun 26, 2015

Subsystems (3)
lore
Share & tools
lore

Haiyang Zhang

author maintainer
#0 lore raw

PATCH 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
index 358475e..68e7ece 100644
@@ -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
index 006c1b8..172824e 100644
@@ -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