Skip to contentSkip to conversation

FAILED: patch "[PATCH] usb: gadget: u_ether: Fix MTU size mismatch with RX packet" failed to apply to 4.14-stable tree

PATCH [email protected] 2 participants 3 messages Jan 11, 2021 – Feb 22, 2021

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 4.14-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 0a88fa221ce911c331bf700d2214c5b2f77414d3 Mon Sep 17 00:00:00 2001
From: Manish Narani <[email protected]>
Date: Tue, 17 Nov 2020 12:43:35 +0530
Subject: [PATCH] usb: gadget: u_ether: Fix MTU size mismatch with RX packet
size

Fix the MTU size issue with RX packet size as the host sends the packet with extra bytes containing ethernet header. This causes failure when user sets the MTU size to the maximum i.e. 15412. In this case the ethernet packet received will be of length 15412 plus the ethernet header length. This patch fixes the issue where there is a check that RX packet length must not be more than max packet length.

Fixes bba787a860fa ("usb: gadget: ether: Allow jumbo frames")
Cc stable <[email protected]>
drivers/usb/gadget/function/u_ether.c +5 -4
index 31ea76adcc0d..c019f2b0c0af 100644
@@ -45,9 +45,10 @@
 #define UETH__VERSION	"29-May-2008"
 
 /* Experiments show that both Linux and Windows hosts allow up to 16k
- * frame sizes. Set the max size to 15k+52 to prevent allocating 32k
+ * frame sizes. Set the max MTU size to 15k+52 to prevent allocating 32k
  * blocks and still have efficient handling. */
-#define GETHER_MAX_ETH_FRAME_LEN 15412
+#define GETHER_MAX_MTU_SIZE 15412
+#define GETHER_MAX_ETH_FRAME_LEN (GETHER_MAX_MTU_SIZE + ETH_HLEN)
 
 struct eth_dev {
 	/* lock is held while accessing port_usb
@@ -786,7 +787,7 @@ struct eth_dev *gether_setup_name(struct usb_gadget *g,
 
 	/* MTU range: 14 - 15412 */
 	net->min_mtu = ETH_HLEN;
-	net->max_mtu = GETHER_MAX_ETH_FRAME_LEN;
+	net->max_mtu = GETHER_MAX_MTU_SIZE;
 
 	dev->gadget = g;
 	SET_NETDEV_DEV(net, &g->dev);
@@ -848,7 +849,7 @@ struct net_device *gether_setup_name_default(const char *netname)
 
 	/* MTU range: 14 - 15412 */
 	net->min_mtu = ETH_HLEN;
-	net->max_mtu = GETHER_MAX_ETH_FRAME_LEN;
+	net->max_mtu = GETHER_MAX_MTU_SIZE;
 
 	return net;
 }
#1 lore raw

Hi Greg,

Quoted 5 lines · On Mon, Jan 11, 2021 at 09:43:33AM +0100, [email protected] wrote:

The patch below does not apply to the 4.14-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

Here is the backport along with eea52743eb56 ("USB: Gadget Ethernet: Re-enable Jumbo frames.") for easy backporting. And looks like that should have been in stable by itself.

--
Regards
Sudip

From 91b75a430da3f5d346342e812b31b553e41d083a Mon Sep 17 00:00:00 2001
From: John Greb <[email protected]>
Date: Sun, 6 May 2018 20:01:57 +0000
Subject: [PATCH 1/2] USB: Gadget Ethernet: Re-enable Jumbo frames.

commit eea52743eb5654ec6f52b0e8b4aefec952543697 upstream

Fixes: <b3e3893e1253> ("net: use core MTU range checking") which patched only one of two functions used to setup the USB Gadget Ethernet driver, causing a serious performance regression in the ability to increase mtu size above 1500.

---
 drivers/usb/gadget/function/u_ether.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/usb/gadget/function/u_ether.c +4 -0
index 716edd593a99..0b24c365d988 100644
@@ -850,6 +850,10 @@ struct net_device *gether_setup_name_default(const char *netname)
 	net->ethtool_ops = &ops;
 	SET_NETDEV_DEVTYPE(net, &gadget_type);
 
+	/* MTU range: 14 - 15412 */
+	net->min_mtu = ETH_HLEN;
+	net->max_mtu = GETHER_MAX_ETH_FRAME_LEN;
+
 	return net;
 }
 EXPORT_SYMBOL_GPL(gether_setup_name_default);
Signature · 1 line
2.30.0

From 600a331b4ec9bca91677a2fb7704f900c4b210ee Mon Sep 17 00:00:00 2001
From: Manish Narani <[email protected]>
Date: Tue, 17 Nov 2020 12:43:35 +0530
Subject: [PATCH 2/2] usb: gadget: u_ether: Fix MTU size mismatch with RX
packet size

commit 0a88fa221ce911c331bf700d2214c5b2f77414d3 upstream

Fix the MTU size issue with RX packet size as the host sends the packet with extra bytes containing ethernet header. This causes failure when user sets the MTU size to the maximum i.e. 15412. In this case the ethernet packet received will be of length 15412 plus the ethernet header length. This patch fixes the issue where there is a check that RX packet length must not be more than max packet length.

Fixes bba787a860fa ("usb: gadget: ether: Allow jumbo frames")
Cc stable <[email protected]>
---
 drivers/usb/gadget/function/u_ether.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/usb/gadget/function/u_ether.c +5 -4
index 0b24c365d988..989682cc8686 100644
@@ -49,9 +49,10 @@
 #define UETH__VERSION	"29-May-2008"
 
 /* Experiments show that both Linux and Windows hosts allow up to 16k
- * frame sizes. Set the max size to 15k+52 to prevent allocating 32k
+ * frame sizes. Set the max MTU size to 15k+52 to prevent allocating 32k
  * blocks and still have efficient handling. */
-#define GETHER_MAX_ETH_FRAME_LEN 15412
+#define GETHER_MAX_MTU_SIZE 15412
+#define GETHER_MAX_ETH_FRAME_LEN (GETHER_MAX_MTU_SIZE + ETH_HLEN)
 
 struct eth_dev {
 	/* lock is held while accessing port_usb
@@ -790,7 +791,7 @@ struct eth_dev *gether_setup_name(struct usb_gadget *g,
 
 	/* MTU range: 14 - 15412 */
 	net->min_mtu = ETH_HLEN;
-	net->max_mtu = GETHER_MAX_ETH_FRAME_LEN;
+	net->max_mtu = GETHER_MAX_MTU_SIZE;
 
 	dev->gadget = g;
 	SET_NETDEV_DEV(net, &g->dev);
@@ -852,7 +853,7 @@ struct net_device *gether_setup_name_default(const char *netname)
 
 	/* MTU range: 14 - 15412 */
 	net->min_mtu = ETH_HLEN;
-	net->max_mtu = GETHER_MAX_ETH_FRAME_LEN;
+	net->max_mtu = GETHER_MAX_MTU_SIZE;
 
 	return net;
 }
Signature · 1 line
2.30.0
author maintainer
#2 lore raw
Quoted 11 lines · Sudip Mukherjee

Hi Greg,

Quoted 5 lines · On Mon, Jan 11, 2021 at 09:43:33AM +0100, [email protected] wrote:

The patch below does not apply to the 4.14-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

Here is the backport along with eea52743eb56 ("USB: Gadget Ethernet: Re-enable Jumbo frames.") for easy backporting. And looks like that should have been in stable by itself.

Now queued up, thanks.

greg k-h