summaryrefslogtreecommitdiff
path: root/net/core/skbuff.c
diff options
context:
space:
mode:
authorPaolo Abeni <pabeni@redhat.com>2017-06-12 12:23:41 +0300
committerDavid S. Miller <davem@davemloft.net>2017-06-12 17:01:29 +0300
commit3889a803e1da9bd7cd10d6504bf281ee7e55dfd6 (patch)
treea02fdf7382352a186732bb51028ccebcdc2afde1 /net/core/skbuff.c
parent78d6102256fe46fcd0c78798a9391cf1f112f117 (diff)
downloadlinux-3889a803e1da9bd7cd10d6504bf281ee7e55dfd6.tar.xz
net: factor out a helper to decrement the skb refcount
The same code is replicated in 3 different places; move it to a common helper. Signed-off-by: Paolo Abeni <pabeni@redhat.com> Acked-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/skbuff.c')
-rw-r--r--net/core/skbuff.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index e508c1eae67f..747263c49838 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -694,12 +694,9 @@ EXPORT_SYMBOL(__kfree_skb);
*/
void kfree_skb(struct sk_buff *skb)
{
- if (unlikely(!skb))
- return;
- if (likely(atomic_read(&skb->users) == 1))
- smp_rmb();
- else if (likely(!atomic_dec_and_test(&skb->users)))
+ if (!skb_unref(skb))
return;
+
trace_kfree_skb(skb, __builtin_return_address(0));
__kfree_skb(skb);
}
@@ -746,12 +743,9 @@ EXPORT_SYMBOL(skb_tx_error);
*/
void consume_skb(struct sk_buff *skb)
{
- if (unlikely(!skb))
- return;
- if (likely(atomic_read(&skb->users) == 1))
- smp_rmb();
- else if (likely(!atomic_dec_and_test(&skb->users)))
+ if (!skb_unref(skb))
return;
+
trace_consume_skb(skb);
__kfree_skb(skb);
}