2
0

030-7-kaweth-use-skb_cow_head-to-deal-with-cloned-skbs.patch 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. From 39fba7835aacda65284a86e611774cbba71dac20 Mon Sep 17 00:00:00 2001
  2. From: Eric Dumazet <edumazet@google.com>
  3. Date: Wed, 19 Apr 2017 09:59:26 -0700
  4. Subject: [PATCH] kaweth: use skb_cow_head() to deal with cloned skbs
  5. We can use skb_cow_head() to properly deal with clones,
  6. especially the ones coming from TCP stack that allow their head being
  7. modified. This avoids a copy.
  8. Signed-off-by: Eric Dumazet <edumazet@google.com>
  9. Cc: James Hughes <james.hughes@raspberrypi.org>
  10. Signed-off-by: David S. Miller <davem@davemloft.net>
  11. ---
  12. drivers/net/usb/kaweth.c | 18 ++++++------------
  13. 1 file changed, 6 insertions(+), 12 deletions(-)
  14. --- a/drivers/net/usb/kaweth.c
  15. +++ b/drivers/net/usb/kaweth.c
  16. @@ -812,18 +812,12 @@ static netdev_tx_t kaweth_start_xmit(str
  17. }
  18. /* We now decide whether we can put our special header into the sk_buff */
  19. - if (skb_cloned(skb) || skb_headroom(skb) < 2) {
  20. - /* no such luck - we make our own */
  21. - struct sk_buff *copied_skb;
  22. - copied_skb = skb_copy_expand(skb, 2, 0, GFP_ATOMIC);
  23. - dev_kfree_skb_irq(skb);
  24. - skb = copied_skb;
  25. - if (!copied_skb) {
  26. - kaweth->stats.tx_errors++;
  27. - netif_start_queue(net);
  28. - spin_unlock_irq(&kaweth->device_lock);
  29. - return NETDEV_TX_OK;
  30. - }
  31. + if (skb_cow_head(skb, 2)) {
  32. + kaweth->stats.tx_errors++;
  33. + netif_start_queue(net);
  34. + spin_unlock_irq(&kaweth->device_lock);
  35. + dev_kfree_skb_any(skb);
  36. + return NETDEV_TX_OK;
  37. }
  38. private_header = (__le16 *)__skb_push(skb, 2);