Skip to content

Conversation

kernel-patches-daemon-bpf-rc[bot]
Copy link

Pull request for series with
subject: xsk: refactors around generic xmit side
version: 2
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1006276

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: dd948aa
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1006276
version: 2

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: 5730dac
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1006276
version: 2

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: 5730dac
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1006276
version: 2

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: 5730dac
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1006276
version: 2

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: 9b5c111
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1006276
version: 2

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: 1193c46
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1006276
version: 2

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: 105eb5d
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1006276
version: 2

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: d43029f
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1006276
version: 2

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: d43029f
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1006276
version: 2

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: d43029f
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1006276
version: 2

@kernel-patches-daemon-bpf-rc kernel-patches-daemon-bpf-rc bot force-pushed the bpf-next_base branch 6 times, most recently from e0b1dc1 to ce3f403 Compare October 4, 2025 16:32
@kernel-patches-daemon-bpf-rc kernel-patches-daemon-bpf-rc bot force-pushed the bpf-next_base branch 4 times, most recently from 22821ea to 3bfc6dc Compare October 7, 2025 22:35
@theihor
Copy link
Contributor

theihor commented Oct 7, 2025

This is a test message

Inline review:

commit 44a8057d9daec9219b38510f080f9ef22aca001d
Author: Maciej Fijalkowski <[email protected]>

xsk: wrap generic metadata handling onto separate function

This commit refactors xsk_build_skb() by extracting metadata handling
into a new xsk_skb_metadata() function. It also adds metadata support
for devices with IFF_TX_SKB_NO_LINEAR flag.

> diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
> index f7e0d254a..7b0c68a70 100644
> --- a/net/xdp/xsk.c
> +++ b/net/xdp/xsk.c

[ ... ]

> +static int xsk_skb_metadata(struct sk_buff *skb, void *buffer,
> +			    struct xdp_desc *desc, struct xsk_buff_pool *pool,
> +			    u32 hr)
> +{
> +	struct xsk_tx_metadata *meta = NULL;
> +
> +	if (unlikely(pool->tx_metadata_len == 0))
> +		return -EINVAL;
> +
> +	meta = buffer - pool->tx_metadata_len;
> +	if (unlikely(!xsk_buff_valid_tx_metadata(meta)))
> +		return -EINVAL;
> +
> +	if (meta->flags & XDP_TXMD_FLAGS_CHECKSUM) {
> +		if (unlikely(meta->request.csum_start +
> +			     meta->request.csum_offset +
> +			     sizeof(__sum16) > desc->len))
> +			return -EINVAL;
> +
> +		skb->csum_start = hr + meta->request.csum_start;
> +		skb->csum_offset = meta->request.csum_offset;
> +		skb->ip_summed = CHECKSUM_PARTIAL;
> +
> +		if (unlikely(pool->tx_sw_csum)) {
> +			int err;
> +
> +			err = skb_checksum_help(skb);
> +			if (err)
> +				return err;
> +		}
> +	}
> +
> +	if (meta->flags & XDP_TXMD_FLAGS_LAUNCH_TIME)
> +		skb->skb_mstamp_ns = meta->request.launch_time;
> +	xsk_tx_metadata_to_compl(meta, &skb_shinfo(skb)->xsk_meta);
> +
> +	return 0;
> +}
> +
>  static struct sk_buff *xsk_build_skb_zerocopy(struct xdp_sock *xs,
>  					      struct xdp_desc *desc)
>  {
> @@ -669,6 +708,9 @@ static struct sk_buff *xsk_build_skb_zerocopy(struct xdp_sock *xs,
>  	int err, i;
>  	u64 addr;
>
> +	addr = desc->addr;
> +	buffer = xsk_buff_raw_get_data(pool, addr);
> +
>  	if (!skb) {
>  		hr = max(NET_SKB_PAD, L1_CACHE_ALIGN(xs->dev->needed_headroom));
>
> @@ -679,6 +721,11 @@ static struct sk_buff *xsk_build_skb_zerocopy(struct xdp_sock *xs,
>  		skb_reserve(skb, hr);
>
>  		xsk_skb_init_misc(skb, xs, desc->addr);
> +		if (desc->options & XDP_TX_METADATA) {
> +			err = xsk_skb_metadata(skb, buffer, desc, pool, hr);
> +			if (unlikely(err))
> +				return ERR_PTR(err);

Does this leak the skb allocated by sock_alloc_send_skb()?

When xsk_skb_metadata() fails here, the function returns ERR_PTR(err)
directly without freeing the skb. The caller xsk_build_skb() sets
skb = NULL after getting the error, so the free_err path won't clean
it up either since it checks if (skb && !skb_shinfo(skb)->nr_frags).

> +		}
>  	} else {
>  		xsk_addr = kmem_cache_zalloc(xsk_tx_generic_cache, GFP_KERNEL);
>  		if (!xsk_addr)

[ ... ]

--

This review is generated by an AI bot. It may be wrong.
AI review job summary: https://github.com/kernel-patches/bpf/actions/runs/18018331618
In-Reply-To-Subject: xsk: wrap generic metadata handling onto separate function

@kernel-patches-daemon-bpf-rc kernel-patches-daemon-bpf-rc bot force-pushed the bpf-next_base branch 4 times, most recently from 5ba1e72 to c9241b4 Compare October 10, 2025 17:08
@kernel-patches-daemon-bpf-rc kernel-patches-daemon-bpf-rc bot force-pushed the bpf-next_base branch 10 times, most recently from db45b16 to cf0c057 Compare October 16, 2025 23:46
@kernel-patches-daemon-bpf-rc kernel-patches-daemon-bpf-rc bot force-pushed the bpf-next_base branch 4 times, most recently from 83f20be to b7224b3 Compare October 19, 2025 02:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants