aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2014-09-29 16:29:15 -0400
committerDavid S. Miller <davem@davemloft.net>2014-10-01 16:34:25 -0400
commitd0bf4a9e92b9a93ffeeacbd7b6cb83e0ee3dc2ef (patch)
tree1ba29128caa07307632b6219c1692308ec89983a /include/linux
parentb248230c34970a6c1c17c591d63b464e8d2cfc33 (diff)
net: cleanup and document skb fclone layout
Lets use a proper structure to clearly document and implement skb fast clones. Then, we might experiment more easily alternative layouts. This patch adds a new skb_fclone_busy() helper, used by tcp and xfrm, to stop leaking of implementation details. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/skbuff.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 262efdbc346b..d8f7d74d5a4d 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -781,6 +781,31 @@ struct sk_buff *alloc_skb_with_frags(unsigned long header_len,
781 int *errcode, 781 int *errcode,
782 gfp_t gfp_mask); 782 gfp_t gfp_mask);
783 783
784/* Layout of fast clones : [skb1][skb2][fclone_ref] */
785struct sk_buff_fclones {
786 struct sk_buff skb1;
787
788 struct sk_buff skb2;
789
790 atomic_t fclone_ref;
791};
792
793/**
794 * skb_fclone_busy - check if fclone is busy
795 * @skb: buffer
796 *
797 * Returns true is skb is a fast clone, and its clone is not freed.
798 */
799static inline bool skb_fclone_busy(const struct sk_buff *skb)
800{
801 const struct sk_buff_fclones *fclones;
802
803 fclones = container_of(skb, struct sk_buff_fclones, skb1);
804
805 return skb->fclone == SKB_FCLONE_ORIG &&
806 fclones->skb2.fclone == SKB_FCLONE_CLONE;
807}
808
784static inline struct sk_buff *alloc_skb_fclone(unsigned int size, 809static inline struct sk_buff *alloc_skb_fclone(unsigned int size,
785 gfp_t priority) 810 gfp_t priority)
786{ 811{