From: Martin KaFai Lau <martin.lau@linux.dev>
To: Jordan Rife <jrife@google.com>
Cc: linux-kselftest@vger.kernel.org, netdev@vger.kernel.org,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Eduard Zingerman <eddyz87@gmail.com>, Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@kernel.org>,
Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>,
Jiri Olsa <jolsa@kernel.org>, Mykola Lysenko <mykolal@fb.com>,
Shuah Khan <shuah@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Jesper Dangaard Brouer <hawk@kernel.org>,
Daan De Meyer <daan.j.demeyer@gmail.com>,
bpf@vger.kernel.org
Subject: Re: [PATCH v1 bpf-next 1/8] selftests/bpf: Introduce sock_addr_testmod
Date: Tue, 2 Apr 2024 10:57:03 -0700 [thread overview]
Message-ID: <007e30b4-31aa-41b0-9e19-f7e2a385773e@linux.dev> (raw)
In-Reply-To: <20240329191907.1808635-2-jrife@google.com>
On 3/29/24 12:18 PM, Jordan Rife wrote:
> +static int do_sock_op(int op, struct sockaddr *addr, int addrlen)
This function can be made as a new kfunc in bpf_testmod.c. The
sock_create_kern() could be moved to here also. Take a look at the
register_btf_kfunc_id_set() usage in bpf_testmod.c and how those registered
kfunc(s) can be called by the bpf prog in progs/*.
If the do_kernel_{bind,connect,sendmsg} and the sock_create_kern need a
sleepable context, it will need to mark the kfunc KF_SLEEPABLE. The kfunc can be
registered to the BPF_PROG_TYPE_SYSCALL sleepable prog type. There are some
examples in progs/kfunc_call_test.c and how the "syscall" bpf prog can be run by
bpf_prog_test_run_opts().
The result (e.g. ensuring the addr and addrlen have not been changed) can be
checked in the bpf prog itself. Then the new sock_addr_testmod is not needed.
> +{
> + switch (op) {
> + case BIND:
> + return do_kernel_bind(addr, addrlen);
> + case CONNECT:
> + return do_kernel_connect(addr, addrlen);
> + case SENDMSG:
> + return do_kernel_sendmsg(addr, addrlen);
> + default:
> + return -EINVAL;
> + }
> +}
> +
next prev parent reply other threads:[~2024-04-02 17:57 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-29 19:18 [PATCH v1 bpf-next 0/8] selftests/bpf: Add sockaddr tests for kernel networking Jordan Rife
2024-03-29 19:18 ` [PATCH v1 bpf-next 1/8] selftests/bpf: Introduce sock_addr_testmod Jordan Rife
2024-03-29 22:09 ` Andrii Nakryiko
2024-03-29 22:09 ` Andrii Nakryiko
2024-04-02 17:57 ` Martin KaFai Lau [this message]
2024-04-02 18:14 ` Jordan Rife
2024-03-29 19:18 ` [PATCH v1 bpf-next 2/8] selftests/bpf: Add module load helpers Jordan Rife
2024-03-29 19:18 ` [PATCH v1 bpf-next 3/8] selftests/bpf: Factor out cmp_addr Jordan Rife
2024-03-29 19:18 ` [PATCH v1 bpf-next 4/8] selftests/bpf: Add recv_msg_from_client to network helpers Jordan Rife
2024-04-02 22:33 ` Martin KaFai Lau
2024-03-29 19:18 ` [PATCH v1 bpf-next 5/8] selftests/bpf: Factor out load_path and defines from test_sock_addr Jordan Rife
2024-04-02 23:14 ` Martin KaFai Lau
2024-04-03 0:05 ` Jordan Rife
2024-03-29 19:18 ` [PATCH v1 bpf-next 6/8] selftests/bpf: Add setup/cleanup subcommands Jordan Rife
2024-03-29 19:18 ` [PATCH v1 bpf-next 7/8] selftests/bpf: Add sock_addr_kern prog_test Jordan Rife
2024-03-29 19:18 ` [PATCH v1 bpf-next 8/8] selftests/bpf: Fix bind program for big endian systems Jordan Rife
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=007e30b4-31aa-41b0-9e19-f7e2a385773e@linux.dev \
--to=martin.lau@linux.dev \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daan.j.demeyer@gmail.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=hawk@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=jrife@google.com \
--cc=kpsingh@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mykolal@fb.com \
--cc=netdev@vger.kernel.org \
--cc=sdf@google.com \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=yonghong.song@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;
as well as URLs for NNTP newsgroup(s).