654-avoid_skb_cow_realloc.patch 679 B

123456789101112131415161718192021
  1. --- a/include/linux/skbuff.h
  2. +++ b/include/linux/skbuff.h
  3. @@ -1850,12 +1850,15 @@ static inline int skb_clone_writable(con
  4. static inline int __skb_cow(struct sk_buff *skb, unsigned int headroom,
  5. int cloned)
  6. {
  7. + unsigned int alloc_headroom = headroom;
  8. int delta = 0;
  9. if (headroom < NET_SKB_PAD)
  10. - headroom = NET_SKB_PAD;
  11. - if (headroom > skb_headroom(skb))
  12. - delta = headroom - skb_headroom(skb);
  13. + alloc_headroom = NET_SKB_PAD;
  14. + if (headroom > skb_headroom(skb) ||
  15. + (cloned && alloc_headroom > skb_headroom(skb))) {
  16. + delta = alloc_headroom - skb_headroom(skb);
  17. + }
  18. if (delta || cloned)
  19. return pskb_expand_head(skb, ALIGN(delta, NET_SKB_PAD), 0,