Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The assertion `ASSERT_GE(tc_hook.ifindex, 0)` incorrectly accepts 0 as a valid interface index, masking `if_nametoindex()` failures.
--
--- Patch [12]: [PATCH net-next 12/14] selftests/bpf: Test skb_ext read from seg6local End.BPF hook ---
commit b36d673a00ed1b242e3b7537fce3622d564183f9
Author: Jakub Sitnicki <[email protected]>
selftests/bpf: Test skb_ext read from seg6local End.BPF hook
This patch adds a test for reading skb_ext from an lwt_seg6local context.
It sets up a three-namespace topology to verify that an skb_ext written
at TC egress can be successfully read back by a seg6local End.BPF hook
running in a different namespace.
> 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 7a7537ef80e75..5f9247941aa01 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
[ ... ]
> + /* NS1: write skb_ext at TC egress on veth1, then send.
> + * TC egress fires after seg6 encap, on the encapped packet.
> + */
> + nstoken = open_netns("seg6_1");
> + if (!ASSERT_OK_PTR(nstoken, "open seg6_1"))
> + goto cleanup;
> +
> + tc_hook.ifindex = if_nametoindex("veth1");
> + if (!ASSERT_GE(tc_hook.ifindex, 0, "ifindex veth1"))
[Severity: Medium]
Does this assertion properly detect an interface lookup failure?
When if_nametoindex() fails to find the network interface, it returns 0.
Using ASSERT_GE(..., 0) allows a return value of 0 to pass the check. If the
interface is missing, the test will proceed and likely fail later in
bpf_tc_hook_create(), which could obfuscate the true failure point.
Would it be better to ensure the index is strictly greater than 0 here?
> + goto cleanup;
> +
> + ret = bpf_tc_hook_create(&tc_hook);
> + if (!ASSERT_OK(ret, "bpf_tc_hook_create"))
> + goto cleanup;
> +
> + tc_opts.prog_fd = bpf_program__fd(skel->progs.tc_skb_ext_write);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260814-bpf-meta-inside-skb-ext-v1-0-767edd862656@cloudflare.com?part=12
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.