Skip to contentSkip to conversation

Fix CDC_EEM with 802.1Q VLAN and 1500 MTU

PATCH In review Ian Coolidge 2 participants 4 messages Nov 6, 2012 – Nov 7, 2012 1 message not in the archive

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover Fix CDC_EEM with 802.1Q VLAN and 1500 MTU

cdc_eem USB host driver and gadget driver both are broken in 1500 MTU case when using 802.1Q VLANs. In both cases, this is due to incomplete assumptions of Ethernet frame size.

Ian Coolidge (2):
usb: gadget: g_ether: fix frame size check
net: usb: cdc_eem: Fix rx skb allocation for 802.1Q VLANs

 drivers/net/usb/cdc_eem.c    |    4 ++++
 drivers/usb/gadget/u_ether.c |    3 ++-
 2 files changed, 6 insertions(+), 1 deletions(-)
Signature · 1 line
1.7.6.5
#1 lore raw

PATCH 1/2 usb: gadget: g_ether: fix frame size check

Checking skb->len against ETH_FRAME_LEN assumes a 1514 ethernet frame size. With an 802.1Q VLAN header, ethernet frame length can now be 1518. Validate frame length against that.

---
 drivers/usb/gadget/u_ether.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/usb/gadget/u_ether.c +2 -1
index 29c854b..ff2c70b 100644
@@ -19,6 +19,7 @@
 #include <linux/ctype.h>
 #include <linux/etherdevice.h>
 #include <linux/ethtool.h>
+#include <linux/if_vlan.h>
 
 #include "u_ether.h"
 
@@ -301,7 +302,7 @@ static void rx_complete(struct usb_ep *ep, struct usb_request *req)
 		while (skb2) {
 			if (status < 0
 					|| ETH_HLEN > skb2->len
-					|| skb2->len > ETH_FRAME_LEN) {
+					|| skb2->len > VLAN_ETH_FRAME_LEN) {
 				dev->net->stats.rx_errors++;
 				dev->net->stats.rx_length_errors++;
 				DBG(dev, "rx length %d\n", skb2->len);
Signature · 1 line
1.7.6.5
#2 lore raw

PATCH 2/2 net: usb: cdc_eem: Fix rx skb allocation for 802.1Q VLANs

In reply to Ian Coolidge

cdc_eem frames might need to contain 802.1Q VLAN Ethernet frames. Provide this information as an override to usbnet->rx_urb_size

---
 drivers/net/usb/cdc_eem.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/net/usb/cdc_eem.c +4 -0
index 439690b..63c38dc 100644
@@ -31,6 +31,7 @@
 #include <linux/usb/cdc.h>
 #include <linux/usb/usbnet.h>
 #include <linux/gfp.h>
+#include <linux/if_vlan.h>
 
 
 /*
@@ -94,6 +95,9 @@ static int eem_bind(struct usbnet *dev, struct usb_interface *intf)
 
 	dev->net->hard_header_len += EEM_HEAD + ETH_FCS_LEN;
 
+	/* octets we need to rx for a single ethernet frame */
+	dev->rx_urb_size = EEM_HEAD + ETH_FCS_LEN + VLAN_ETH_FRAME_LEN;
+
 	return 0;
 }
 
Signature · 1 line
1.7.6.5

A message that is not in the archive (sent off-list or not yet received): 1352235611-13066-1-git-send-email-iancoolidge-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org