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>
This commit is contained in:

committed by
David S. Miller

parent
b248230c34
commit
d0bf4a9e92
@@ -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)
|
||||
{
|
||||
|
Reference in New Issue
Block a user