All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Prankur gupta <prankgup@fb.com>
Cc: bpf <bpf@vger.kernel.org>, Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Kernel Team <kernel-team@fb.com>,
	prankur.07@gmail.com
Subject: Re: [PATCH bpf-next 1/2] bpf: Add support for {set|get} socket options from setsockopt BPF
Date: Mon, 16 Aug 2021 19:23:05 -0700	[thread overview]
Message-ID: <CAEf4BzacXvT5tsVe-xYSOYrxrf8B_02jG=Hv67SXhC-8rWcxrw@mail.gmail.com> (raw)
In-Reply-To: <20210816231716.3824813-2-prankgup@fb.com>

On Mon, Aug 16, 2021 at 4:17 PM Prankur gupta <prankgup@fb.com> wrote:
>
> Add logic to call bpf_setsockopt and bpf_getsockopt from
> setsockopt BPF programs.
> Example use case, when the user sets the IPV6_TCLASS socket option
> we would also like to change the tcp-cc for that socket.
> We don't have any use case for calling bpf_setsockopt from
> supposedly read-only sys_getsockopti, so it is made available to
> BPF_CGROUP_SETSOCKOPT only.
>
> Signed-off-by: Prankur gupta <prankgup@fb.com>
> ---
>  kernel/bpf/cgroup.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/kernel/bpf/cgroup.c b/kernel/bpf/cgroup.c
> index a1dedba4c174..9c92eff9af95 100644
> --- a/kernel/bpf/cgroup.c
> +++ b/kernel/bpf/cgroup.c
> @@ -1873,6 +1873,14 @@ cg_sockopt_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
>                 return &bpf_sk_storage_get_proto;
>         case BPF_FUNC_sk_storage_delete:
>                 return &bpf_sk_storage_delete_proto;
> +       case BPF_FUNC_setsockopt:
> +               if (prog->expected_attach_type == BPF_CGROUP_SETSOCKOPT)
> +                       return &bpf_sk_setsockopt_proto;
> +               return NULL;
> +       case BPF_FUNC_getsockopt:
> +               if (prog->expected_attach_type == BPF_CGROUP_SETSOCKOPT)
> +                       return &bpf_sk_getsockopt_proto;

Is there any problem enabling bpf_getsockopt() for
BPF_CGROUP_GETSOCKOPT program type?

> +               return NULL;
>  #endif
>  #ifdef CONFIG_INET
>         case BPF_FUNC_tcp_sock:
> --
> 2.30.2
>

  parent reply	other threads:[~2021-08-17  2:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-16 23:17 [PATCH bpf-next 0/2] Add support for bpf_setsockopt and bpf_getsockopt from BPF setsockopt Prankur gupta
2021-08-16 23:17 ` [PATCH bpf-next 1/2] bpf: Add support for {set|get} socket options from setsockopt BPF Prankur gupta
2021-08-17  0:02   ` Song Liu
2021-08-17  2:23   ` Andrii Nakryiko [this message]
2021-08-17 19:49     ` Prankur gupta
2021-08-17 20:31       ` Martin KaFai Lau
2021-08-16 23:17 ` [PATCH bpf-next 2/2] selftests/bpf: Add test for {set|get} socket option from setsockopt BPF program Prankur gupta
2021-08-17  0:20   ` Song Liu
2021-08-17  3:56     ` Song Liu
2021-08-17 22:42 [PATCH v2 bpf-next 0/2] Add support for bpf_setsockopt and Prankur gupta
2021-08-17 22:42 ` [PATCH bpf-next 1/2] bpf: Add support for {set|get} socket options from setsockopt BPF Prankur gupta

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='CAEf4BzacXvT5tsVe-xYSOYrxrf8B_02jG=Hv67SXhC-8rWcxrw@mail.gmail.com' \
    --to=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.com \
    --cc=prankgup@fb.com \
    --cc=prankur.07@gmail.com \
    /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.