All of lore.kernel.org
 help / color / mirror / Atom feed
From: Martin KaFai Lau <martin.lau@linux.dev>
To: Amery Hung <ameryhung@gmail.com>
Cc: netdev@vger.kernel.org, alexei.starovoitov@gmail.com,
	andrii@kernel.org, daniel@iogearbox.net, tj@kernel.org,
	memxor@gmail.com, martin.lau@kernel.org, kernel-team@meta.com,
	bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v2 3/3] selftests/bpf: Test multi_st_ops and calling kfuncs from different programs
Date: Wed, 6 Aug 2025 16:20:00 -0700	[thread overview]
Message-ID: <c9140ce6-8352-4aaa-8b18-d35d762c0d63@linux.dev> (raw)
In-Reply-To: <20250806162540.681679-4-ameryhung@gmail.com>

On 8/6/25 9:25 AM, Amery Hung wrote:
> +static void test_st_ops_id_ops_mapping(void)
> +{
> +	struct struct_ops_id_ops_mapping1 *skel1 = NULL;
> +	struct struct_ops_id_ops_mapping2 *skel2 = NULL;
> +	LIBBPF_OPTS(bpf_test_run_opts, topts);

A default topts is not needed. Passing NULL is as good, so removed.

> +	struct bpf_map_info info = {};
> +	__u32 len = sizeof(info);
> +	int err, pid, prog1_fd, prog2_fd;
> +
> +	skel1 = struct_ops_id_ops_mapping1__open_and_load();
> +	if (!ASSERT_OK_PTR(skel1, "struct_ops_id_ops_mapping1__open"))
> +		goto out;
> +
> +	skel2 = struct_ops_id_ops_mapping2__open_and_load();
> +	if (!ASSERT_OK_PTR(skel2, "struct_ops_id_ops_mapping2__open"))
> +		goto out;
> +
> +	err = bpf_map_get_info_by_fd(bpf_map__fd(skel1->maps.st_ops_map),
> +				     &info, &len);
> +	if (!ASSERT_OK(err, "bpf_map_get_info_by_fd"))
> +		goto out;
> +
> +	skel1->bss->st_ops_id = info.id;
> +
> +	err = bpf_map_get_info_by_fd(bpf_map__fd(skel2->maps.st_ops_map),
> +				     &info, &len);
> +	if (!ASSERT_OK(err, "bpf_map_get_info_by_fd"))
> +		goto out;
> +
> +	skel2->bss->st_ops_id = info.id;
> +
> +	err = struct_ops_id_ops_mapping1__attach(skel1);
> +	if (!ASSERT_OK(err, "struct_ops_id_ops_mapping1__attach"))
> +		goto out;
> +
> +	err = struct_ops_id_ops_mapping2__attach(skel2);
> +	if (!ASSERT_OK(err, "struct_ops_id_ops_mapping2__attach"))
> +		goto out;
> +
> +	/* run tracing prog that calls .test_1 and checks return */
> +	pid = getpid();
> +	skel1->bss->test_pid = pid;
> +	skel2->bss->test_pid = pid;
> +	sys_gettid();
> +	skel1->bss->test_pid = 0;
> +	skel2->bss->test_pid = 0;
> +
> +	/* run syscall_prog that calls .test_1 and checks return */
> +	prog1_fd = bpf_program__fd(skel1->progs.syscall_prog);
> +	err = bpf_prog_test_run_opts(prog1_fd, &topts);
> +	ASSERT_OK(err, "bpf_prog_test_run_opts");
> +
> +	prog2_fd = bpf_program__fd(skel2->progs.syscall_prog);
> +	err = bpf_prog_test_run_opts(prog2_fd, &topts);
> +	ASSERT_OK(err, "bpf_prog_test_run_opts");
> +
> +	ASSERT_EQ(skel1->bss->test_err, 0, "skel1->bss->test_err");
> +	ASSERT_EQ(skel2->bss->test_err, 0, "skel2->bss->test_err");
> +
> +out:
> +	if (skel1)
> +		struct_ops_id_ops_mapping1__destroy(skel1);
> +	if (skel2)

NULL check on skel[12] is not needed, so removed.

Applied. Thanks.

> +		struct_ops_id_ops_mapping2__destroy(skel2);
> +}
> +

  reply	other threads:[~2025-08-06 23:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-06 16:25 [PATCH bpf-next v2 0/3] Allow struct_ops to create map id to Amery Hung
2025-08-06 16:25 ` [PATCH bpf-next v2 1/3] bpf: Allow struct_ops to get map id by kdata Amery Hung
2025-08-06 16:25 ` [PATCH bpf-next v2 2/3] selftests/bpf: Add multi_st_ops that supports multiple instances Amery Hung
2025-08-06 23:16   ` Martin KaFai Lau
2025-08-06 16:25 ` [PATCH bpf-next v2 3/3] selftests/bpf: Test multi_st_ops and calling kfuncs from different programs Amery Hung
2025-08-06 23:20   ` Martin KaFai Lau [this message]
2025-08-06 23:20 ` [PATCH bpf-next v2 0/3] Allow struct_ops to create map id to patchwork-bot+netdevbpf

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=c9140ce6-8352-4aaa-8b18-d35d762c0d63@linux.dev \
    --to=martin.lau@linux.dev \
    --cc=alexei.starovoitov@gmail.com \
    --cc=ameryhung@gmail.com \
    --cc=andrii@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@meta.com \
    --cc=martin.lau@kernel.org \
    --cc=memxor@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=tj@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.