BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Rongzheng Wang" <testwrzwrz@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net v2 2/2] selftests/bpf: cover AF_XDP multi-buffer TX software checksum
Date: Sun, 25 Oct 2026 14:12:20 +0000	[thread overview]
Message-ID: <sashiko-outbox-184244@kernel.org> (raw)
In-Reply-To: <20261024141157.59301-3-testwrzwrz@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] selftests/bpf: generate_packet() copies ASCII MAC strings into ethhdr
--

commit 84305185f8b937f13eaa038de90ba93344b90447
Author: Rongzheng Wang <testwrzwrz@gmail.com>

selftests/bpf: cover AF_XDP multi-buffer TX software checksum

This commit extends test_xdp_metadata to send the test UDP packet both as a
single TX descriptor and split across two TX descriptors, verifying AF_XDP
metadata and software checksum calculation for both cases.

> diff --git a/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c b/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c
> index 5c31054ad4a4c..1cf70fb800fba 100644
> --- a/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c
> +++ b/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c
[ ... ]
> @@ -133,36 +135,36 @@ static void close_xsk(struct xsk *xsk)
>  	munmap(xsk->umem_area, UMEM_SIZE);
>  }
>  
> -static int generate_packet(struct xsk *xsk, __u16 dst_port)
> +static int generate_packet(struct xsk *xsk, __u16 dst_port, u16 split_len)
>  {
>  	struct xsk_tx_metadata *meta;
>  	struct xdp_desc *tx_desc;
>  	struct udphdr *udph;
>  	struct ethhdr *eth;
>  	struct iphdr *iph;
> +	u16 pkt_len;
> +	u32 num, addr;
>  	void *data;
>  	__u32 idx;
> +	u8 pkt[256];
>  	int ret;
>  
> -	ret = xsk_ring_prod__reserve(&xsk->tx, 1, &idx);
> -	if (!ASSERT_EQ(ret, 1, "xsk_ring_prod__reserve"))
> +	pkt_len = sizeof(*eth) + sizeof(*iph) + sizeof(*udph) + UDP_PAYLOAD_BYTES;
> +	if (!ASSERT_LT(split_len, pkt_len, "split_len"))
>  		return -1;
>  
> -	tx_desc = xsk_ring_prod__tx_desc(&xsk->tx, idx);
> -	tx_desc->addr = idx % (UMEM_NUM / 2) * UMEM_FRAME_SIZE + sizeof(struct xsk_tx_metadata);
> -	printf("%p: tx_desc[%u]->addr=%llx\n", xsk, idx, tx_desc->addr);
> -	data = xsk_umem__get_data(xsk->umem_area, tx_desc->addr);
> -
> -	meta = data - sizeof(struct xsk_tx_metadata);
> -	memset(meta, 0, sizeof(*meta));
> -	meta->flags = XDP_TXMD_FLAGS_TIMESTAMP;
> +	num = split_len ? 2 : 1;
> +	ret = xsk_ring_prod__reserve(&xsk->tx, num, &idx);
> +	if (!ASSERT_EQ(ret, num, "xsk_ring_prod__reserve"))
> +		return -1;
>  
> -	eth = data;
> +	memset(pkt, 0, sizeof(pkt));
> +	eth = (void *)pkt;
>  	iph = (void *)(eth + 1);
>  	udph = (void *)(iph + 1);
>  
> -	memcpy(eth->h_dest, "\x00\x00\x00\x00\x00\x02", ETH_ALEN);
> -	memcpy(eth->h_source, "\x00\x00\x00\x00\x00\x01", ETH_ALEN);
> +	memcpy(eth->h_dest, RX_MAC, ETH_ALEN);
> +	memcpy(eth->h_source, TX_MAC, ETH_ALEN);

[Severity: Medium]
Does this populate eth->h_dest and eth->h_source with ASCII characters
instead of the binary MAC addresses?

In tools/testing/selftests/bpf/prog_tests/xdp_metadata.c, TX_MAC and RX_MAC
are defined as colon-separated ASCII strings for iproute2 commands:

#define TX_MAC "00:00:00:00:00:01"
#define RX_MAC "00:00:00:00:00:02"

When test_xdp_metadata() calls generate_packet(), copying ETH_ALEN (6)
bytes from RX_MAC and TX_MAC writes the literal string "00:00:"
(30:30:3a:30:30:3a) into both eth->h_dest and eth->h_source, rather than
the 6-byte binary MAC addresses "\x00\x00\x00\x00\x00\x02" and
"\x00\x00\x00\x00\x00\x01".

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261024141157.59301-1-testwrzwrz@gmail.com?part=2

  reply	other threads:[~2026-10-25 14:12 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-24  9:12 [PATCH net] xsk: defer software checksum until the skb is complete Rongzheng Wang
2026-10-24  9:15 ` netdev-bot+sinfo
2026-10-24 11:35   ` 王荣峥
2026-10-24 12:25 ` Jason Xing
2026-10-24 14:11 ` [PATCH net v2 0/2] xsk: fix multi-buffer TX software checksum Rongzheng Wang
2026-10-24 14:11   ` [PATCH net v2 1/2] xsk: defer software checksum until the skb is complete Rongzheng Wang
2026-10-25  2:51     ` Jason Xing
2026-10-25  3:43       ` Rongzheng Wang
2026-10-26 11:15     ` Maciej Fijalkowski
2026-10-26 12:34       ` Magnus Karlsson
2026-10-26 14:27       ` Rongzheng Wang
2026-10-26 14:31         ` Magnus Karlsson
2026-10-24 14:11   ` [PATCH net v2 2/2] selftests/bpf: cover AF_XDP multi-buffer TX software checksum Rongzheng Wang
2026-10-25 14:12     ` sashiko-bot [this message]
2026-10-25 14:46     ` netdev-bot+sashiko
2026-10-26 14:55       ` Rongzheng Wang
2026-10-24 14:15   ` [PATCH net v2 0/2] xsk: fix " netdev-bot+sinfo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-184244@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=testwrzwrz@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox