From: sashiko-bot@kernel.org
To: "Jakub Sitnicki" <jakub@cloudflare.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net-next 05/14] selftests/bpf: Test skb_ext on cloned skbs
Date: Sat, 15 Aug 2026 08:14:50 +0000 [thread overview]
Message-ID: <20260815081450.E84391F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260814-bpf-meta-inside-skb-ext-v1-5-767edd862656@cloudflare.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Flawed assertion for `if_nametoindex` return value silently ignores errors.
- [Low] Multi-line comments do not follow the BPF subsystem comment style guidelines.
--
--- Patch [5]: [PATCH net-next 05/14] selftests/bpf: Test skb_ext on cloned skbs ---
commit 52378eb340683567339caa62c46774dede8267b1
Author: Jakub Sitnicki <jakub@cloudflare.com>
selftests/bpf: Test skb_ext on cloned skbs
This patch covers skb_ext behavior when an skb is cloned by TC mirred. It adds
tests to verify that the extension written at tap ingress is readable from the
mirred clone and that COW works when the extension is modified.
> diff --git a/tools/testing/selftests/bpf/prog_tests/xdp_context_test_run.c b/tools/testing/selftests/bpf/prog_tests/xdp_context_test_run.c
> index fd340e5538a34..58b793cf14e59 100644
> --- a/tools/testing/selftests/bpf/prog_tests/xdp_context_test_run.c
> +++ b/tools/testing/selftests/bpf/prog_tests/xdp_context_test_run.c
> @@ -694,6 +694,95 @@ void test_xdp_context_lwt_encap(void)
> test_xdp_meta__destroy(skel);
> }
>
> +/* Test if skb_ext survives skb clone (via tc mirred).
> + * dummy_prog runs on the clone (dummy ingress).
> + */
[Severity: Low]
This isn't a bug, but the multi-line comment does not follow the BPF subsystem
style guidelines. Should the opening /* be placed on its own line?
> +static void test_mirred_clone_ext(struct test_xdp_meta *skel,
> + struct bpf_program *dummy_prog)
> +{
> + LIBBPF_OPTS(bpf_tc_hook, tc_hook, .attach_point = BPF_TC_INGRESS);
> + LIBBPF_OPTS(bpf_tc_opts, tc_opts, .handle = 1, .priority = 1);
> + struct netns_obj *ns = NULL;
> + int dummy_ifindex;
> + int tap_ifindex;
> + int tap_fd = -1;
> + int ret;
> +
> + skel->bss->test_pass = false;
> +
> + ns = netns_new("mirred_clone", true);
> + if (!ASSERT_OK_PTR(ns, "netns_new"))
> + return;
> +
> + /* Dummy dev: attach reader */
> + SYS(close, "ip link add name " DUMMY_NAME " type dummy");
> + SYS(close, "ip link set dev " DUMMY_NAME " up");
> +
> + dummy_ifindex = if_nametoindex(DUMMY_NAME);
> + if (!ASSERT_GE(dummy_ifindex, 0, "dummy_ifindex"))
[Severity: Medium]
Since if_nametoindex() returns 0 on failure, will ASSERT_GE(..., 0) incorrectly
evaluate 0 as a success? If the interface lookup fails, won't the test proceed
with an invalid interface index (0) instead of catching the failure here?
> + goto close;
> +
> + tc_hook.ifindex = dummy_ifindex;
> + ret = bpf_tc_hook_create(&tc_hook);
> + if (!ASSERT_OK(ret, "dummy_hook_create"))
> + goto close;
> +
> + tc_opts.prog_fd = bpf_program__fd(dummy_prog);
> + ret = bpf_tc_attach(&tc_hook, &tc_opts);
> + if (!ASSERT_OK(ret, "dummy_attach"))
> + goto close;
> +
> + /* TAP dev: attach writer + mirred to dummy */
> + tap_fd = open_tuntap(TAP_NAME, true);
> + if (!ASSERT_GE(tap_fd, 0, "open_tuntap"))
> + goto close;
> +
> + SYS(close, "ip link set dev " TAP_NAME " up");
> +
> + tap_ifindex = if_nametoindex(TAP_NAME);
> + if (!ASSERT_GE(tap_ifindex, 0, "tap_ifindex"))
[Severity: Medium]
Similarly, will this assertion accept 0 as a valid interface index on failure
and result in confusing downstream errors during bpf_tc_hook_create()?
> + goto close;
[ ... ]
> diff --git a/tools/testing/selftests/bpf/progs/test_xdp_meta.c b/tools/testing/selftests/bpf/progs/test_xdp_meta.c
> index 43840ee32d359..1b6bb20ee7e85 100644
> --- a/tools/testing/selftests/bpf/progs/test_xdp_meta.c
> +++ b/tools/testing/selftests/bpf/progs/test_xdp_meta.c
> @@ -874,4 +875,49 @@ int tc_skb_ext_double_alloc(struct __sk_buff *ctx)
> return TC_ACT_UNSPEC;
> }
>
> +static const __u8 meta_zero[META_SIZE] = {};
> +
> +volatile bool clone_cow_done;
> +
> +/* Overwrite skb_ext on the clone via F_CREATE (COW) -- must not affect original.
> + * Runs on the dummy ingress (clone side), synchronously during tc mirred.
> + */
[Severity: Low]
This isn't a bug, but could the opening /* be placed on its own line to adhere
to the preferred kernel multi-line comment style used in the BPF subsystem?
> +SEC("tc")
> +int tc_skb_ext_clone_redir_cow(struct __sk_buff *ctx)
> +{
> + struct bpf_dynptr meta;
> +
> + if (bpf_dynptr_from_skb_ext(ctx, 0, BPF_SKB_EXT_F_CREATE, &meta))
> + return TC_ACT_SHOT;
> +
> + /* Zero out the clone's ext -- must not affect original */
> + bpf_dynptr_write(&meta, 0, (void *)meta_zero, META_SIZE, 0);
> +
> + clone_cow_done = true;
> + return TC_ACT_SHOT;
> +}
> +
> +/* Verify COW isolation at kfree_skb time: once clone_cow_done is set,
> + * check that the original skb still has meta_want.
> + */
[Severity: Low]
This isn't a bug, but could the opening /* be placed on its own line to adhere
to the preferred kernel multi-line comment style used in the BPF subsystem?
> +SEC("tp_btf/kfree_skb")
> +int BPF_PROG(tp_kfree_skb_cow_check, struct sk_buff *skb)
> +{
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260814-bpf-meta-inside-skb-ext-v1-0-767edd862656@cloudflare.com?part=5
next prev parent reply other threads:[~2026-08-15 8:14 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-14 8:14 [PATCH net-next 00/14] skb extension for BPF metadata Jakub Sitnicki
2026-08-14 8:14 ` [PATCH net-next 01/14] bpf: Introduce per-packet metadata storage for BPF programs Jakub Sitnicki
2026-08-15 8:14 ` sashiko-bot
2026-08-14 8:14 ` [PATCH net-next 02/14] bpf: Allow access to bpf_sock_ops_kern->skb Jakub Sitnicki
2026-08-14 8:14 ` [PATCH net-next 03/14] bpf: Make BPF skb extension survive packet scrubbing Jakub Sitnicki
2026-08-15 8:14 ` sashiko-bot
2026-08-14 8:14 ` [PATCH net-next 04/14] selftests/bpf: Add tests for bpf_dynptr_from_skb_ext Jakub Sitnicki
2026-08-15 8:14 ` sashiko-bot
2026-08-14 8:14 ` [PATCH net-next 05/14] selftests/bpf: Test skb_ext on cloned skbs Jakub Sitnicki
2026-08-15 8:14 ` sashiko-bot [this message]
2026-08-14 8:14 ` [PATCH net-next 06/14] selftests/bpf: Test skb_ext survival across veth and GRE Jakub Sitnicki
2026-08-15 8:14 ` sashiko-bot
2026-08-14 8:14 ` [PATCH net-next 07/14] selftests/bpf: Test skb_ext read from cgroup_skb and sk_filter hooks Jakub Sitnicki
2026-08-15 8:14 ` sashiko-bot
2026-08-14 8:14 ` [PATCH net-next 08/14] selftests/bpf: Test skb_ext read from sock_ops and LSM hooks Jakub Sitnicki
2026-08-15 8:14 ` sashiko-bot
2026-08-14 8:14 ` [PATCH net-next 09/14] selftests/bpf: Test skb_ext read from kfree_skb tracepoint Jakub Sitnicki
2026-08-15 8:14 ` sashiko-bot
2026-08-14 8:14 ` [PATCH net-next 10/14] selftests/bpf: Test skb_ext read from netfilter hook Jakub Sitnicki
2026-08-14 8:14 ` [PATCH net-next 11/14] selftests/bpf: Test skb_ext from LWT in, out, and xmit hooks Jakub Sitnicki
2026-08-15 8:14 ` sashiko-bot
2026-08-14 8:14 ` [PATCH net-next 12/14] selftests/bpf: Test skb_ext read from seg6local End.BPF hook Jakub Sitnicki
2026-08-15 8:14 ` sashiko-bot
2026-08-14 8:14 ` [PATCH net-next 13/14] selftests/bpf: Test skb_ext read from sk_skb stream verdict hook Jakub Sitnicki
2026-08-15 8:14 ` sashiko-bot
2026-08-14 8:14 ` [PATCH net-next 14/14] selftests/bpf: Use non-trivial test payload in xdp_context tests Jakub Sitnicki
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=20260815081450.E84391F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=jakub@cloudflare.com \
--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