net: use skb_unref() in napi_consume_skb()
authorPaolo Abeni <pabeni@redhat.com>
Wed, 14 Jun 2017 09:48:48 +0000 (11:48 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 14 Jun 2017 19:23:51 +0000 (15:23 -0400)
The commit 83ada39bb79d ("net: factor out a helper to decrement the
skb refcount") provided and used a helper for decrementing skb usage,
but I missed at least a spot for it.

This change remove some more duplicated code reusing skb_unref() in
napi_consume_skb(), too. The helper uses an additional, unneeded
unlikely(!skb) test - napi_consume_skb() already check it a few lines
above - but the compiler is smart enough to optimize the duplicated
test out.

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/skbuff.c

index 304602784c3b78249c73609e8aad9cbc55e70e66..c4d2c1f824bb217d25091a66e23c568c60053fb2 100644 (file)
@@ -817,10 +817,9 @@ void napi_consume_skb(struct sk_buff *skb, int budget)
                return;
        }
 
-       if (likely(atomic_read(&skb->users) == 1))
-               smp_rmb();
-       else if (likely(!atomic_dec_and_test(&skb->users)))
+       if (!skb_unref(skb))
                return;
+
        /* if reaching here SKB is ready to free */
        trace_consume_skb(skb);