net: cdc_ncm: reduce skb truesize in rx path
authorBjørn Mork <bjorn@mork.no>
Fri, 30 May 2014 07:31:03 +0000 (09:31 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 2 Jun 2014 23:01:30 +0000 (16:01 -0700)
Cloning the big skbs we use for USB buffering chokes up TCP and
SCTP because the socket memory limits are hitting earlier than
they should. It is better to unconditionally copy the unwrapped
packets to freshly allocated skbs.

Reported-by: Jim Baxter <jim_baxter@mentor.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/usb/cdc_ncm.c

index 93c9ca9..2bbbd65 100644 (file)
@@ -1289,12 +1289,11 @@ next_ndp:
                        break;
 
                } else {
-                       skb = skb_clone(skb_in, GFP_ATOMIC);
+                       /* create a fresh copy to reduce truesize */
+                       skb = netdev_alloc_skb_ip_align(dev->net,  len);
                        if (!skb)
                                goto error;
-                       skb->len = len;
-                       skb->data = ((u8 *)skb_in->data) + offset;
-                       skb_set_tail_pointer(skb, len);
+                       memcpy(skb_put(skb, len), skb_in->data + offset, len);
                        usbnet_skb_return(dev, skb);
                        payload += len; /* count payload bytes in this NTB */
                }