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

net: skb_share_check() should use consume_skb()

In order to avoid false drop_monitor indications, we should
call consume_skb() if skb_clone() was successful.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Eric Dumazet and committed by
David S. Miller
47061bc4 cc72d100

+6 -3
+6 -3
include/linux/skbuff.h
··· 846 846 * 847 847 * NULL is returned on a memory allocation failure. 848 848 */ 849 - static inline struct sk_buff *skb_share_check(struct sk_buff *skb, 850 - gfp_t pri) 849 + static inline struct sk_buff *skb_share_check(struct sk_buff *skb, gfp_t pri) 851 850 { 852 851 might_sleep_if(pri & __GFP_WAIT); 853 852 if (skb_shared(skb)) { 854 853 struct sk_buff *nskb = skb_clone(skb, pri); 855 - kfree_skb(skb); 854 + 855 + if (likely(nskb)) 856 + consume_skb(skb); 857 + else 858 + kfree_skb(skb); 856 859 skb = nskb; 857 860 } 858 861 return skb;