From: Yonghong Song <yonghong.song@linux.dev>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: bpf@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Jakub Sitnicki <jakub@cloudflare.com>,
John Fastabend <john.fastabend@gmail.com>,
kernel-team@fb.com, Martin KaFai Lau <martin.lau@kernel.org>
Subject: Re: [PATCH bpf-next v5 1/5] bpf: Add bpf_link support for sk_msg and sk_skb progs
Date: Sun, 7 Apr 2024 21:24:46 -0700 [thread overview]
Message-ID: <471352dd-a0f1-4d28-8ad7-3c0cad5c6924@linux.dev> (raw)
In-Reply-To: <CAEf4BzZTM5Ce+EEhTWPkt4C5PjtC9JRrWQzw1ZGU_oiCqQSi7Q@mail.gmail.com>
On 4/6/24 11:47 AM, Andrii Nakryiko wrote:
> On Sat, Apr 6, 2024 at 9:04 AM Yonghong Song <yonghong.song@linux.dev> wrote:
>> Add bpf_link support for sk_msg and sk_skb programs. We have an
>> internal request to support bpf_link for sk_msg programs so user
>> space can have a uniform handling with bpf_link based libbpf
>> APIs. Using bpf_link based libbpf API also has a benefit which
>> makes system robust by decoupling prog life cycle and
>> attachment life cycle.
>>
>> Reviewed-by: John Fastabend <john.fastabend@gmail.com>
>> Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
>> ---
>> include/linux/bpf.h | 6 +
>> include/linux/skmsg.h | 4 +
>> include/uapi/linux/bpf.h | 5 +
>> kernel/bpf/syscall.c | 4 +
>> net/core/sock_map.c | 270 ++++++++++++++++++++++++++++++---
>> tools/include/uapi/linux/bpf.h | 5 +
>> 6 files changed, 277 insertions(+), 17 deletions(-)
>>
> Please check bpf_prog_attach_check_attach_type(), it probably should
> be updated as well. Other than that looks good.
We are fine here. In function attach_type_to_prog_type(), we already
have checking:
case BPF_SK_MSG_VERDICT:
return BPF_PROG_TYPE_SK_MSG;
case BPF_SK_SKB_STREAM_PARSER:
case BPF_SK_SKB_STREAM_VERDICT:
case BPF_SK_SKB_VERDICT:
return BPF_PROG_TYPE_SK_SKB;
>
> [...]
>
>> static int sock_map_prog_update(struct bpf_map *map, struct bpf_prog *prog,
>> - struct bpf_prog *old, u32 which)
>> + struct bpf_prog *old, struct bpf_link *link,
>> + u32 which)
>> {
>> struct bpf_prog **pprog;
>> + struct bpf_link **plink;
>> int ret;
>>
>> - ret = sock_map_prog_lookup(map, &pprog, which);
>> + ret = sock_map_prog_link_lookup(map, &pprog, &plink, NULL, link && !prog, which);
>> if (ret)
>> - return ret;
>> + goto out;
> probably could have kept `return ret;` here?
>
>> - if (old)
>> - return psock_replace_prog(pprog, prog, old);
>> + if (old) {
>> + ret = psock_replace_prog(pprog, prog, old);
>> + if (!ret)
>> + *plink = NULL;
>> + } else {
>> + psock_set_prog(pprog, prog);
>> + if (link)
>> + *plink = link;
>> + }
>>
>> - psock_set_prog(pprog, prog);
>> - return 0;
>> +out:
> and wouldn't need out: then
Ack. I can make this change.
>
>> + return ret;
>> }
>>
> [...]
next prev parent reply other threads:[~2024-04-08 4:24 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-06 16:03 [PATCH bpf-next v5 0/5] bpf: Add bpf_link support for sk_msg and sk_skb progs Yonghong Song
2024-04-06 16:04 ` [PATCH bpf-next v5 1/5] " Yonghong Song
2024-04-06 18:47 ` Andrii Nakryiko
2024-04-08 4:24 ` Yonghong Song [this message]
2024-04-06 23:18 ` Eduard Zingerman
2024-04-08 5:01 ` Yonghong Song
2024-04-06 16:04 ` [PATCH bpf-next v5 2/5] libbpf: Add bpf_link support for BPF_PROG_TYPE_SOCKMAP Yonghong Song
2024-04-06 18:49 ` Andrii Nakryiko
2024-04-08 4:54 ` Yonghong Song
2024-04-06 16:04 ` [PATCH bpf-next v5 3/5] bpftool: Add link dump support for BPF_LINK_TYPE_SOCKMAP Yonghong Song
2024-04-06 16:04 ` [PATCH bpf-next v5 4/5] selftests/bpf: Refactor out helper functions for a few tests Yonghong Song
2024-04-06 16:04 ` [PATCH bpf-next v5 5/5] selftests/bpf: Add some tests with new bpf_program__attach_sockmap() APIs Yonghong Song
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=471352dd-a0f1-4d28-8ad7-3c0cad5c6924@linux.dev \
--to=yonghong.song@linux.dev \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=jakub@cloudflare.com \
--cc=john.fastabend@gmail.com \
--cc=kernel-team@fb.com \
--cc=martin.lau@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox