diff options
| author | Vijay Subramanian <subramanian.vijay@gmail.com> | 2014-10-02 13:00:43 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2014-10-04 20:34:25 -0400 |
| commit | c8753d55afb436fd6a25c8bbe8d783f6dcf1c9f8 (patch) | |
| tree | 4d0cffb662c877a9a15bdf7bb84f2db35f4c33ec /net/core | |
| parent | 9fab426de78140dc5cb0b85bbee6042c9c3d5ca5 (diff) | |
net: Cleanup skb cloning by adding SKB_FCLONE_FREE
SKB_FCLONE_UNAVAILABLE has overloaded meaning depending on type of skb.
1: If skb is allocated from head_cache, it indicates fclone is not available.
2: If skb is a companion fclone skb (allocated from fclone_cache), it indicates
it is available to be used.
To avoid confusion for case 2 above, this patch replaces
SKB_FCLONE_UNAVAILABLE with SKB_FCLONE_FREE where appropriate. For fclone
companion skbs, this indicates it is free for use.
SKB_FCLONE_UNAVAILABLE will now simply indicate skb is from head_cache and
cannot / will not have a companion fclone.
Signed-off-by: Vijay Subramanian <subramanian.vijay@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
| -rw-r--r-- | net/core/skbuff.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/net/core/skbuff.c b/net/core/skbuff.c index a0b312fa3047..28916e47f959 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c | |||
| @@ -265,7 +265,7 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask, | |||
| 265 | skb->fclone = SKB_FCLONE_ORIG; | 265 | skb->fclone = SKB_FCLONE_ORIG; |
| 266 | atomic_set(&fclones->fclone_ref, 1); | 266 | atomic_set(&fclones->fclone_ref, 1); |
| 267 | 267 | ||
| 268 | fclones->skb2.fclone = SKB_FCLONE_UNAVAILABLE; | 268 | fclones->skb2.fclone = SKB_FCLONE_FREE; |
| 269 | fclones->skb2.pfmemalloc = pfmemalloc; | 269 | fclones->skb2.pfmemalloc = pfmemalloc; |
| 270 | } | 270 | } |
| 271 | out: | 271 | out: |
| @@ -542,7 +542,7 @@ static void kfree_skbmem(struct sk_buff *skb) | |||
| 542 | fclones = container_of(skb, struct sk_buff_fclones, skb2); | 542 | fclones = container_of(skb, struct sk_buff_fclones, skb2); |
| 543 | 543 | ||
| 544 | /* Warning : We must perform the atomic_dec_and_test() before | 544 | /* Warning : We must perform the atomic_dec_and_test() before |
| 545 | * setting skb->fclone back to SKB_FCLONE_UNAVAILABLE, otherwise | 545 | * setting skb->fclone back to SKB_FCLONE_FREE, otherwise |
| 546 | * skb_clone() could set clone_ref to 2 before our decrement. | 546 | * skb_clone() could set clone_ref to 2 before our decrement. |
| 547 | * Anyway, if we are going to free the structure, no need to | 547 | * Anyway, if we are going to free the structure, no need to |
| 548 | * rewrite skb->fclone. | 548 | * rewrite skb->fclone. |
| @@ -553,7 +553,7 @@ static void kfree_skbmem(struct sk_buff *skb) | |||
| 553 | /* The clone portion is available for | 553 | /* The clone portion is available for |
| 554 | * fast-cloning again. | 554 | * fast-cloning again. |
| 555 | */ | 555 | */ |
| 556 | skb->fclone = SKB_FCLONE_UNAVAILABLE; | 556 | skb->fclone = SKB_FCLONE_FREE; |
| 557 | } | 557 | } |
| 558 | break; | 558 | break; |
| 559 | } | 559 | } |
| @@ -874,7 +874,7 @@ struct sk_buff *skb_clone(struct sk_buff *skb, gfp_t gfp_mask) | |||
| 874 | return NULL; | 874 | return NULL; |
| 875 | 875 | ||
| 876 | if (skb->fclone == SKB_FCLONE_ORIG && | 876 | if (skb->fclone == SKB_FCLONE_ORIG && |
| 877 | n->fclone == SKB_FCLONE_UNAVAILABLE) { | 877 | n->fclone == SKB_FCLONE_FREE) { |
| 878 | n->fclone = SKB_FCLONE_CLONE; | 878 | n->fclone = SKB_FCLONE_CLONE; |
| 879 | /* As our fastclone was free, clone_ref must be 1 at this point. | 879 | /* As our fastclone was free, clone_ref must be 1 at this point. |
| 880 | * We could use atomic_inc() here, but it is faster | 880 | * We could use atomic_inc() here, but it is faster |
