Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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")
Signed-off-by: Manish Narani <manish.narani@xilinx.com>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/1605597215-122027-1-git-send-email-manish.narani@xilinx.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Manish Narani and committed by
Greg Kroah-Hartman
0a88fa22 c91d3a6b

+5 -4
+5 -4
drivers/usb/gadget/function/u_ether.c
··· 45 45 #define UETH__VERSION "29-May-2008" 46 46 47 47 /* Experiments show that both Linux and Windows hosts allow up to 16k 48 - * frame sizes. Set the max size to 15k+52 to prevent allocating 32k 48 + * frame sizes. Set the max MTU size to 15k+52 to prevent allocating 32k 49 49 * blocks and still have efficient handling. */ 50 - #define GETHER_MAX_ETH_FRAME_LEN 15412 50 + #define GETHER_MAX_MTU_SIZE 15412 51 + #define GETHER_MAX_ETH_FRAME_LEN (GETHER_MAX_MTU_SIZE + ETH_HLEN) 51 52 52 53 struct eth_dev { 53 54 /* lock is held while accessing port_usb ··· 787 786 788 787 /* MTU range: 14 - 15412 */ 789 788 net->min_mtu = ETH_HLEN; 790 - net->max_mtu = GETHER_MAX_ETH_FRAME_LEN; 789 + net->max_mtu = GETHER_MAX_MTU_SIZE; 791 790 792 791 dev->gadget = g; 793 792 SET_NETDEV_DEV(net, &g->dev); ··· 849 848 850 849 /* MTU range: 14 - 15412 */ 851 850 net->min_mtu = ETH_HLEN; 852 - net->max_mtu = GETHER_MAX_ETH_FRAME_LEN; 851 + net->max_mtu = GETHER_MAX_MTU_SIZE; 853 852 854 853 return net; 855 854 }