Skip to content

Commit

Permalink
skbuff: add a parameter to __skb_frag_unref
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
teknoraver authored and davem330 committed Jun 7, 2021
1 parent c07aea3 commit c420c98
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion drivers/net/ethernet/marvell/sky2.c
Original file line number Diff line number Diff line change
Expand Up @@ -2503,7 +2503,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);
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/mellanox/mlx4/en_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 5 additions & 3 deletions include/linux/skbuff.h
Original file line number Diff line number Diff line change
Expand Up @@ -3081,10 +3081,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));
}
Expand All @@ -3098,7 +3100,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);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions net/core/skbuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,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);
Expand Down Expand Up @@ -3495,7 +3495,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 */
Expand Down
2 changes: 1 addition & 1 deletion net/tls/tls_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit c420c98

Please sign in to comment.