diff options
-rw-r--r-- | include/linux/skbuff.h | 17 | ||||
-rw-r--r-- | net/core/skbuff.c | 19 |
2 files changed, 20 insertions, 16 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 1a2611030d36..75c963103b9f 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h | |||
@@ -304,6 +304,7 @@ struct sk_buff { | |||
304 | 304 | ||
305 | #include <asm/system.h> | 305 | #include <asm/system.h> |
306 | 306 | ||
307 | extern void kfree_skb(struct sk_buff *skb); | ||
307 | extern void __kfree_skb(struct sk_buff *skb); | 308 | extern void __kfree_skb(struct sk_buff *skb); |
308 | extern struct sk_buff *__alloc_skb(unsigned int size, | 309 | extern struct sk_buff *__alloc_skb(unsigned int size, |
309 | gfp_t priority, int fclone); | 310 | gfp_t priority, int fclone); |
@@ -404,22 +405,6 @@ static inline struct sk_buff *skb_get(struct sk_buff *skb) | |||
404 | */ | 405 | */ |
405 | 406 | ||
406 | /** | 407 | /** |
407 | * kfree_skb - free an sk_buff | ||
408 | * @skb: buffer to free | ||
409 | * | ||
410 | * Drop a reference to the buffer and free it if the usage count has | ||
411 | * hit zero. | ||
412 | */ | ||
413 | static inline void kfree_skb(struct sk_buff *skb) | ||
414 | { | ||
415 | if (likely(atomic_read(&skb->users) == 1)) | ||
416 | smp_rmb(); | ||
417 | else if (likely(!atomic_dec_and_test(&skb->users))) | ||
418 | return; | ||
419 | __kfree_skb(skb); | ||
420 | } | ||
421 | |||
422 | /** | ||
423 | * skb_cloned - is the buffer a clone | 408 | * skb_cloned - is the buffer a clone |
424 | * @skb: buffer to check | 409 | * @skb: buffer to check |
425 | * | 410 | * |
diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 2144952d1c6c..01abf1e8990b 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c | |||
@@ -356,6 +356,24 @@ void __kfree_skb(struct sk_buff *skb) | |||
356 | } | 356 | } |
357 | 357 | ||
358 | /** | 358 | /** |
359 | * kfree_skb - free an sk_buff | ||
360 | * @skb: buffer to free | ||
361 | * | ||
362 | * Drop a reference to the buffer and free it if the usage count has | ||
363 | * hit zero. | ||
364 | */ | ||
365 | void kfree_skb(struct sk_buff *skb) | ||
366 | { | ||
367 | if (unlikely(!skb)) | ||
368 | return; | ||
369 | if (likely(atomic_read(&skb->users) == 1)) | ||
370 | smp_rmb(); | ||
371 | else if (likely(!atomic_dec_and_test(&skb->users))) | ||
372 | return; | ||
373 | __kfree_skb(skb); | ||
374 | } | ||
375 | |||
376 | /** | ||
359 | * skb_clone - duplicate an sk_buff | 377 | * skb_clone - duplicate an sk_buff |
360 | * @skb: buffer to clone | 378 | * @skb: buffer to clone |
361 | * @gfp_mask: allocation priority | 379 | * @gfp_mask: allocation priority |
@@ -1799,6 +1817,7 @@ void __init skb_init(void) | |||
1799 | 1817 | ||
1800 | EXPORT_SYMBOL(___pskb_trim); | 1818 | EXPORT_SYMBOL(___pskb_trim); |
1801 | EXPORT_SYMBOL(__kfree_skb); | 1819 | EXPORT_SYMBOL(__kfree_skb); |
1820 | EXPORT_SYMBOL(kfree_skb); | ||
1802 | EXPORT_SYMBOL(__pskb_pull_tail); | 1821 | EXPORT_SYMBOL(__pskb_pull_tail); |
1803 | EXPORT_SYMBOL(__alloc_skb); | 1822 | EXPORT_SYMBOL(__alloc_skb); |
1804 | EXPORT_SYMBOL(pskb_copy); | 1823 | EXPORT_SYMBOL(pskb_copy); |