xsk: respect the offsets when copying frags
Subsystems (4)
v2 cover xsk: respect the offsets when copying frags
Hi everyone,
In commit 560d958c6c68 ("xsk: add generic XSk &xdp_buff -> skb conversion"), we introduce a helper to convert zerocopy xdp_buff to skb. However, in the frag copy, we mistakenly ignore the frag's offset. This series adds the missing offset when copying frags in xdp_copy_frags_from_zc(). This function is not used anywhere so no backport is needed.
This series also makes xdp_copy_frags_from_zc() use page allocation API page_pool_dev_alloc() instead of page_pool_dev_alloc_netmem() to avoid possible confusion of the returned value.
Thanks,
Quang Minh.
Bui Quang Minh (2):
xsk: respect the offsets when copying frags
xsk: convert xdp_copy_frags_from_zc() to use page_pool_dev_alloc()
net/core/xdp.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
Signature · 1 line
2.43.0
PATCH v2 1/2 xsk: respect the offsets when copying frags
In commit 560d958c6c68 ("xsk: add generic XSk &xdp_buff -> skb conversion"), we introduce a helper to convert zerocopy xdp_buff to skb. However, in the frag copy, we mistakenly ignore the frag's offset. This commit adds the missing offset when copying frags in xdp_copy_frags_from_zc(). This function is not used anywhere so no backport is needed.
--- net/core/xdp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
net/core/xdp.c +4 -3
@@ -698,7 +698,8 @@ static noinline bool xdp_copy_frags_from_zc(struct sk_buff *skb, nr_frags = xinfo->nr_frags;for (u32 i =0 ; i < nr_frags; i++) { -u32 len =skb_frag_size (&xinfo->frags[i]); +const skb_frag_t *frag = &xinfo->frags[i]; +u32 len =skb_frag_size (frag);u32 offset, truesize = len;netmem_ref netmem;
@@ -708,8 +709,8 @@ static noinline bool xdp_copy_frags_from_zc(struct sk_buff *skb,return false; } -memcpy (__netmem_address (netmem), -__netmem_address (xinfo->frags[i].netmem), +memcpy (__netmem_address (netmem) + offset, +__netmem_address (frag->netmem) +skb_frag_off (frag),LARGEST_ALIGN (len));__skb_fill_netmem_desc_noacc (sinfo, i, netmem, offset, len);
Signature · 1 line
2.43.0
PATCH v2 2/2 xsk: convert xdp_copy_frags_from_zc() to use page_pool_dev_alloc()
In reply to Bui Quang MinhThis commit makes xdp_copy_frags_from_zc() use page allocation API page_pool_dev_alloc() instead of page_pool_dev_alloc_netmem() to avoid possible confusion of the returned value.
--- net/core/xdp.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
net/core/xdp.c +7 -7
@@ -701,21 +701,21 @@ static noinline bool xdp_copy_frags_from_zc(struct sk_buff *skb,const skb_frag_t *frag = &xinfo->frags[i];u32 len =skb_frag_size (frag);u32 offset, truesize = len; -netmem_ref netmem; +struct page *page; - netmem =page_pool_dev_alloc_netmem (pp, &offset, &truesize); -if (unlikely (!netmem)) { + page =page_pool_dev_alloc (pp, &offset, &truesize); +if (unlikely (!page)) { sinfo->nr_frags = i;return false; } -memcpy (__netmem_address (netmem) + offset, -__netmem_address (frag->netmem) +skb_frag_off (frag), +memcpy (page_address (page) + offset, +skb_frag_page (frag) +skb_frag_off (frag),LARGEST_ALIGN (len)); -__skb_fill_netmem_desc_noacc (sinfo, i, netmem, offset, len); +__skb_fill_page_desc_noacc (sinfo, i, page, offset, len); tsize += truesize; - pfmemalloc |=netmem_is_pfmemalloc (netmem); + pfmemalloc |=page_is_pfmemalloc (page); } xdp_update_skb_shared_info(skb, nr_frags, xinfo->xdp_frags_size,
Signature · 1 line
2.43.0
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Sat, 26 Apr 2025 15:12:18 +0700 you wrote:
Hi everyone,
In commit
560d958c6c68("xsk: add generic XSk&xdp_buff-> skb conversion"), we introduce a helper to convert zerocopyxdp_buffto skb. However, in the frag copy, we mistakenly ignore the frag's offset. This series adds the missing offset when copying frags inxdp_copy_frags_from_zc(). This function is not used anywhere so no backport is needed.[...]
Here is the summary with links:
- [net-next,v2,1/2] xsk: respect the offsets when copying frags
https://git.kernel.org/netdev/net-next/c/ebaebc5eaf43
- [net-next,v2,2/2] xsk: convert xdp_copy_frags_from_zc() to use page_pool_dev_alloc()
https://git.kernel.org/netdev/net-next/c/7ead4405e06f
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html