skbuff: add a parameter to __skb_frag_unref

This is a prerequisite patch, the next one is enabling recycling of
skbs and fragments. Add an extra argument on __skb_frag_unref() to
handle recycling, and update the current users of the function with that.

Signed-off-by: Matteo Croce <mcroce@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: hongrongxuan <hongrongxuan@huawei.com>
This commit is contained in:
Matteo Croce 2021-06-07 21:02:37 +02:00 committed by Jianping Liu
parent 9483d0fd8c
commit 198e415825
5 changed files with 10 additions and 8 deletions

View File

@ -2501,7 +2501,7 @@ static void skb_put_frags(struct sk_buff *skb, unsigned int hdr_space,
if (length == 0) {
/* don't need this page */
__skb_frag_unref(frag);
__skb_frag_unref(frag, false);
--skb_shinfo(skb)->nr_frags;
} else {
size = min(length, (unsigned) PAGE_SIZE);

View File

@ -526,7 +526,7 @@ static int mlx4_en_complete_rx_desc(struct mlx4_en_priv *priv,
fail:
while (nr > 0) {
nr--;
__skb_frag_unref(skb_shinfo(skb)->frags + nr);
__skb_frag_unref(skb_shinfo(skb)->frags + nr, false);
}
return 0;
}

View File

@ -3018,10 +3018,12 @@ static inline void skb_frag_ref(struct sk_buff *skb, int f)
/**
* __skb_frag_unref - release a reference on a paged fragment.
* @frag: the paged fragment
* @recycle: recycle the page if allocated via page_pool
*
* Releases a reference on the paged fragment @frag.
* Releases a reference on the paged fragment @frag
* or recycles the page via the page_pool API.
*/
static inline void __skb_frag_unref(skb_frag_t *frag)
static inline void __skb_frag_unref(skb_frag_t *frag, bool recycle)
{
put_page(skb_frag_page(frag));
}
@ -3035,7 +3037,7 @@ static inline void __skb_frag_unref(skb_frag_t *frag)
*/
static inline void skb_frag_unref(struct sk_buff *skb, int f)
{
__skb_frag_unref(&skb_shinfo(skb)->frags[f]);
__skb_frag_unref(&skb_shinfo(skb)->frags[f], false);
}
/**

View File

@ -622,7 +622,7 @@ static void skb_release_data(struct sk_buff *skb)
skb_zcopy_clear(skb, true);
for (i = 0; i < shinfo->nr_frags; i++)
__skb_frag_unref(&shinfo->frags[i]);
__skb_frag_unref(&shinfo->frags[i], false);
if (shinfo->frag_list)
kfree_skb_list(shinfo->frag_list);
@ -3438,7 +3438,7 @@ int skb_shift(struct sk_buff *tgt, struct sk_buff *skb, int shiftlen)
fragto = &skb_shinfo(tgt)->frags[merge];
skb_frag_size_add(fragto, skb_frag_size(fragfrom));
__skb_frag_unref(fragfrom);
__skb_frag_unref(fragfrom, false);
}
/* Reposition in the original skb */

View File

@ -128,7 +128,7 @@ static void destroy_record(struct tls_record_info *record)
int i;
for (i = 0; i < record->num_frags; i++)
__skb_frag_unref(&record->frags[i]);
__skb_frag_unref(&record->frags[i], false);
kfree(record);
}