Re: [PATCH bpf-next v4 3/3] selftests/bpf: xdp: test dev_xdp_install() rejects device-bound program

[email protected]
Newsgroups org.kernel.vger.bpf
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Multi-line comment opening `/*` is not on its own line, violating BPF subsystem coding style.
--

--- Patch [3]: [PATCH bpf-next v4 3/3] selftests/bpf: xdp: test dev_xdp_install() rejects device-bound program ---
commit b147dadba98d80bfb5e1c977447162a9b3e3bc29
Author: Jiayuan Chen <[email protected]>

selftests/bpf: xdp: test dev_xdp_install() rejects device-bound program

This commit adds a test to ensure that device-bound XDP programs cannot be
swapped into a generic XDP link via BPF_LINK_UPDATE, bypassing the original
checks in dev_xdp_attach().

> diff --git a/tools/testing/selftests/bpf/prog_tests/xdp_dev_bound_only.c b/tools/testing/selftests/bpf/prog_tests/xdp_dev_bound_only.c
> index 7dd18c6d06c60..4a13f8ec43009 100644
> --- a/tools/testing/selftests/bpf/prog_tests/xdp_dev_bound_only.c
> +++ b/tools/testing/selftests/bpf/prog_tests/xdp_dev_bound_only.c

[ ... ]

> @@ -59,3 +61,50 @@ void test_xdp_dev_bound_only_offdev(void)
>  	 */
>  	SYS_NOFAIL("ip netns del " LOCAL_NETNS);
>  }
> +
> +/* A device-bound program must not run on the XDP software path.
> + * dev_xdp_attach() rejected such programs, but bpf_xdp_link_update() reaches
> + * dev_xdp_install() directly and bypasses it, so the check has to live in
> + * dev_xdp_install(). Create a generic (SKB) XDP link with a normal program,
> + * then try to swap in a device-bound program via BPF_LINK_UPDATE.
> + */

[Severity: Low]
This isn't a bug, but does this multi-line comment follow the preferred BPF
subsystem comment style? 

The BPF subsystem guidelines prefer the opening /* to be on its own line for
multi-line comments, with the comment text starting on the next line.

> +void test_xdp_dev_bound_only_link_update(void)
> +{
> +	LIBBPF_OPTS(bpf_link_create_opts, lopts, .flags = XDP_FLAGS_SKB_MODE);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
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.