diff options
author | Eric Dumazet <edumazet@google.com> | 2014-09-29 13:29:15 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-10-01 16:34:25 -0400 |
commit | d0bf4a9e92b9a93ffeeacbd7b6cb83e0ee3dc2ef (patch) | |
tree | 1ba29128caa07307632b6219c1692308ec89983a /include/linux/skbuff.h | |
parent | b248230c34970a6c1c17c591d63b464e8d2cfc33 (diff) | |
download | lwn-d0bf4a9e92b9a93ffeeacbd7b6cb83e0ee3dc2ef.tar.gz lwn-d0bf4a9e92b9a93ffeeacbd7b6cb83e0ee3dc2ef.zip |
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/skbuff.h')
-rw-r--r-- | include/linux/skbuff.h | 25 |
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, int *errcode, gfp_t gfp_mask); +/* Layout of fast clones : [skb1][skb2][fclone_ref] */ +struct sk_buff_fclones { + struct sk_buff skb1; + + struct sk_buff skb2; + + atomic_t fclone_ref; +}; + +/** + * skb_fclone_busy - check if fclone is busy + * @skb: buffer + * + * Returns true is skb is a fast clone, and its clone is not freed. + */ +static inline bool skb_fclone_busy(const struct sk_buff *skb) +{ + const struct sk_buff_fclones *fclones; + + fclones = container_of(skb, struct sk_buff_fclones, skb1); + + return skb->fclone == SKB_FCLONE_ORIG && + fclones->skb2.fclone == SKB_FCLONE_CLONE; +} + static inline struct sk_buff *alloc_skb_fclone(unsigned int size, gfp_t priority) { |