BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Vladimir Vdovin" <deliran@verdict.gg>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next 1/1] selftests: drv-net: add XDP RX checksum metadata tests
Date: Wed, 08 Jul 2026 13:19:18 +0000	[thread overview]
Message-ID: <20260708131919.0C7691F000E9@smtp.kernel.org> (raw)
In-Reply-To: <6c7a059057d309e999b706b5b547be9c620ce544.1783514455.git.deliran@verdict.gg>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] The BPF program overwrites checksum metadata on every packet, which may cause TCP tests to spuriously fail if trailing control packets lack checksum offload.
- [Low] Multi-line comments do not follow the mandatory BPF subsystem comment style (opening `/*` must be on its own line).
--

--- Patch [1]: [PATCH bpf-next 1/1] selftests: drv-net: add XDP RX checksum metadata tests ---
commit d0f16a1bf595df9c0de880826075e44c316407e0
Author: Vladimir Vdovin <deliran@verdict.gg>

selftests: drv-net: add XDP RX checksum metadata tests

Extend the xdp_metadata driver tests with coverage for
bpf_xdp_metadata_rx_checksum(). Adds a BPF program to read and store
the verdict, and Python tests to validate both valid and invalid RX
checksums.

> diff --git a/tools/testing/selftests/drivers/net/hw/xdp_metadata.py b/tools/testing/selftests/drivers/net/hw/xdp_metadata.py
> index 33a1985356d90..687c43a1797a4 100644
> --- a/tools/testing/selftests/drivers/net/hw/xdp_metadata.py
> +++ b/tools/testing/selftests/drivers/net/hw/xdp_metadata.py
[ ... ]
> @@ -130,6 +146,91 @@ def test_xdp_rss_hash(cfg, proto):
>              f"RSS hash type should include L4 for {proto.upper()} traffic")
>  
>  
> +def _require_rx_csum_meta(cfg):
[ ... ]
> +@ksft_variants([
> +    KsftNamedVariant("tcp", "tcp"),
> +    KsftNamedVariant("udp", "udp"),
> +])
> +def test_xdp_rx_csum_valid(cfg, proto):
[ ... ]
> +    csum = bpf_map_dump(csum_map_id)
> +
> +    pkt_cnt = csum.get(_CSUM_KEY_PKT_CNT, 0)
> +    err_cnt = csum.get(_CSUM_KEY_ERR_CNT, 0)
> +    ip_summed = csum.get(_CSUM_KEY_IP_SUMMED, 0)
> +
> +    ksft_ge(pkt_cnt, 1, comment="should have received at least one packet")
> +    ksft_eq(err_cnt, 0, comment=f"RX checksum error count: {err_cnt}")
> +
> +    ksft_pr(f"  ip_summed: {ip_summed:#x} cksum: "
> +            f"{csum.get(_CSUM_KEY_CKSUM, 0):#010x} "
> +            f"level: {csum.get(_CSUM_KEY_LEVEL, 0)}")
> +    ksft_ne(ip_summed & (XDP_CHECKSUM_UNNECESSARY | XDP_CHECKSUM_COMPLETE), 0,
> +            "device should report a checksum verdict for a valid packet")

[Severity: Medium]
Will this test sporadically fail for TCP traffic? Since multiple packets might
be exchanged, the final state of ip_summed could be from a trailing control
packet (like FIN or RST) that lacks checksum offload, leading to a failure
here.

> +
> +
> +def test_xdp_rx_csum_invalid(cfg):
[ ... ]
> diff --git a/tools/testing/selftests/net/lib/xdp_metadata.bpf.c b/tools/testing/selftests/net/lib/xdp_metadata.bpf.c
> index f71f59215239f..70decae0a6637 100644
> --- a/tools/testing/selftests/net/lib/xdp_metadata.bpf.c
> +++ b/tools/testing/selftests/net/lib/xdp_metadata.bpf.c
[ ... ]
> @@ -40,6 +41,24 @@ struct {
>  	__uint(max_entries, 4);
>  } map_rss SEC(".maps");
>  
> +/* RX checksum results: key 0 = ip_summed bitmask, key 1 = hw cksum value,
> + * key 2 = cksum level, key 3 = packet count, key 4 = error count.
> + */

[Severity: Low]
This isn't a bug, but the BPF subsystem prefers multi-line comments to have
the opening /* on its own line. Could this be adjusted?

> +enum {
> +	CSUM_KEY_IP_SUMMED = 0,
[ ... ]
> @@ -55,8 +74,20 @@ enum xdp_rss_hash_type {
>  	XDP_RSS_L4_ICMP = 1U << 8,
>  };
>  
> +/* Mirror of enum xdp_checksum from include/net/xdp.h.
> + * Needed because the enum is not part of UAPI headers.
> + */

[Severity: Low]
This isn't a bug, but could the opening /* be placed on its own line
to match BPF comment style?

> +enum xdp_checksum {
> +	XDP_CHECKSUM_NONE = 1U << 0,
[ ... ]
> @@ -78,41 +109,39 @@ static __always_inline __u16 get_dest_port(void *l4, void *data_end,
>  	return 0;
>  }
>  
> -SEC("xdp")
> -int xdp_rss_hash(struct xdp_md *ctx)
> +/* Return true when the packet matches the L4 protocol and destination
> + * port configured in map_xdp_setup (zero/unset filters match anything).
> + */

[Severity: Low]
This isn't a bug, but could the opening /* be placed on its own line
to match BPF comment style?

> +static __always_inline bool xdp_match_setup(struct xdp_md *ctx)
>  {
[ ... ]
> @@ -160,4 +204,46 @@ int xdp_rss_hash(struct xdp_md *ctx)
>  	return XDP_PASS;
>  }
>  
> +SEC("xdp")
> +int xdp_rx_csum(struct xdp_md *ctx)
> +{
[ ... ]
> +	ret = bpf_xdp_metadata_rx_checksum(ctx, &ip_summed, &cksum,
> +					   &cksum_level);
> +	if (ret < 0) {
> +		key = CSUM_KEY_ERR_CNT;
> +		cnt = bpf_map_lookup_elem(&map_csum, &key);
> +		if (cnt)
> +			__sync_fetch_and_add(cnt, 1);
> +		return XDP_PASS;
> +	}
> +
> +	key = CSUM_KEY_IP_SUMMED;
> +	val = (__u32)ip_summed;
> +	bpf_map_update_elem(&map_csum, &key, &val, BPF_ANY);

[Severity: Medium]
Does this update overwrite the checksum metadata on every packet? If so, the
map will only contain the verdict of the last processed packet, which could
be an empty control packet without checksum offload, leading to incorrect test
failures. Can we accumulate the results or only update if the packet carries a
payload?

> +
> +	key = CSUM_KEY_CKSUM;
> +	bpf_map_update_elem(&map_csum, &key, &cksum, BPF_ANY);
> +
> +	key = CSUM_KEY_LEVEL;
> +	val = cksum_level;
> +	bpf_map_update_elem(&map_csum, &key, &val, BPF_ANY);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/6c7a059057d309e999b706b5b547be9c620ce544.1783514455.git.deliran@verdict.gg?part=1

  reply	other threads:[~2026-07-08 13:19 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-30 19:15 [RFC PATCH bpf-next v1 0/7] xdp: RX checksum metadata hint and checksum assertion over redirect Vladimir Vdovin
2026-06-30 19:15 ` [RFC PATCH bpf-next v1 1/7] xdp: let XDP programs assert the RX checksum " Vladimir Vdovin
2026-06-30 19:31   ` sashiko-bot
2026-06-30 19:15 ` [RFC PATCH bpf-next v1 2/7] selftests/bpf: add test for bpf_xdp_assert_rx_csum over cpumap Vladimir Vdovin
2026-06-30 19:27   ` sashiko-bot
2026-06-30 19:15 ` [RFC PATCH bpf-next v1 3/7] xdp: add bpf_xdp_metadata_rx_csum() RX metadata kfunc Vladimir Vdovin
2026-06-30 19:15 ` [RFC PATCH bpf-next v1 4/7] net/mlx5e: support the rx_csum XDP metadata hint Vladimir Vdovin
2026-06-30 19:15 ` [RFC PATCH bpf-next v1 5/7] ice: " Vladimir Vdovin
2026-06-30 19:27   ` sashiko-bot
2026-06-30 19:15 ` [RFC PATCH bpf-next v1 6/7] veth: " Vladimir Vdovin
2026-06-30 19:27   ` sashiko-bot
2026-06-30 19:15 ` [RFC PATCH bpf-next v1 7/7] selftests/bpf: cover bpf_xdp_metadata_rx_csum in xdp_metadata Vladimir Vdovin
2026-06-30 19:27   ` sashiko-bot
2026-06-30 21:18 ` [RFC PATCH bpf-next v1 0/7] xdp: RX checksum metadata hint and checksum assertion over redirect Stanislav Fomichev
2026-06-30 22:16   ` Lorenzo Bianconi
2026-07-01 17:10     ` Vladimir Vdovin
2026-07-02 14:52       ` Lorenzo Bianconi
2026-07-04 16:41         ` Jesper Dangaard Brouer
2026-07-08 12:51         ` [PATCH bpf-next 0/1] selftests: drv-net: XDP RX checksum metadata test Vladimir Vdovin
2026-07-08 12:51           ` [PATCH bpf-next 1/1] selftests: drv-net: add XDP RX checksum metadata tests Vladimir Vdovin
2026-07-08 13:19             ` sashiko-bot [this message]
2026-07-08 13:28             ` bot+bpf-ci
2026-07-08 15:12           ` [PATCH bpf-next 0/1] selftests: drv-net: XDP RX checksum metadata test Lorenzo Bianconi

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=20260708131919.0C7691F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=deliran@verdict.gg \
    --cc=sashiko-reviews@lists.linux.dev \
    /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