net: skb_share_check() should use consume_skb()
authorEric Dumazet <edumazet@google.com>
Fri, 3 Aug 2012 20:54:15 +0000 (20:54 +0000)
committerDavid S. Miller <davem@davemloft.net>
Sat, 4 Aug 2012 08:27:57 +0000 (01:27 -0700)
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>
include/linux/skbuff.h

index 7632c87da2c9fd66eab61b6c7415d5669b7aeefd..b33a3a1f205e45c747c9125a5b5920365ca2f8be 100644 (file)
@@ -846,13 +846,16 @@ static inline int skb_shared(const struct sk_buff *skb)
  *
  *     NULL is returned on a memory allocation failure.
  */
-static inline struct sk_buff *skb_share_check(struct sk_buff *skb,
-                                             gfp_t pri)
+static inline struct sk_buff *skb_share_check(struct sk_buff *skb, gfp_t pri)
 {
        might_sleep_if(pri & __GFP_WAIT);
        if (skb_shared(skb)) {
                struct sk_buff *nskb = skb_clone(skb, pri);
-               kfree_skb(skb);
+
+               if (likely(nskb))
+                       consume_skb(skb);
+               else
+                       kfree_skb(skb);
                skb = nskb;
        }
        return skb;