Skip to content

Commit 2127c60

Browse files
Sebastian Andrzej Siewiorborkmann
authored andcommitted
xsk: Add truesize to skb_add_rx_frag().
xsk_build_skb() allocates a page and adds it to the skb via skb_add_rx_frag() and specifies 0 for truesize. This leads to a warning in skb_add_rx_frag() with CONFIG_DEBUG_NET enabled because size is larger than truesize. Increasing truesize requires to add the same amount to socket's sk_wmem_alloc counter in order not to underflow the counter during release in the destructor (sock_wfree()). Pass the size of the allocated page as truesize to skb_add_rx_frag(). Add this mount to socket's sk_wmem_alloc counter. Fixes: cf24f5a ("xsk: add support for AF_XDP multi-buffer on Tx path") Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Maciej Fijalkowski <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 11f5222 commit 2127c60

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

net/xdp/xsk.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,8 @@ static struct sk_buff *xsk_build_skb(struct xdp_sock *xs,
722722
memcpy(vaddr, buffer, len);
723723
kunmap_local(vaddr);
724724

725-
skb_add_rx_frag(skb, nr_frags, page, 0, len, 0);
725+
skb_add_rx_frag(skb, nr_frags, page, 0, len, PAGE_SIZE);
726+
refcount_add(PAGE_SIZE, &xs->sk.sk_wmem_alloc);
726727
}
727728

728729
if (first_frag && desc->options & XDP_TX_METADATA) {

0 commit comments

Comments
 (0)