]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
xsk: respect the offsets when copying frags
authorBui Quang Minh <minhquangbui99@gmail.com>
Sat, 26 Apr 2025 08:12:19 +0000 (15:12 +0700)
committerJakub Kicinski <kuba@kernel.org>
Tue, 29 Apr 2025 21:26:26 +0000 (14:26 -0700)
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.

Signed-off-by: Bui Quang Minh <minhquangbui99@gmail.com>
Link: https://patch.msgid.link/20250426081220.40689-2-minhquangbui99@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/core/xdp.c

index ea819764ae39a36362fb32643dae6c783af5c271..89111c68e5450e2608e9470cee489011c380f783 100644 (file)
@@ -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);