diff mbox series

[bpf-next] bpf: allow CGROUP_SKB programs to use bpf_skb_cgroup_id() helper

Message ID 20190606203012.130071-1-guro@fb.com
State Accepted
Delegated to: BPF Maintainers
Headers show
Series [bpf-next] bpf: allow CGROUP_SKB programs to use bpf_skb_cgroup_id() helper | expand

Commit Message

Roman Gushchin June 6, 2019, 8:30 p.m. UTC
Currently bpf_skb_cgroup_id() is not supported for CGROUP_SKB
programs. An attempt to load such a program generates an error
like this:

    libbpf:
    0: (b7) r6 = 0
    ...
    9: (85) call bpf_skb_cgroup_id#79
    unknown func bpf_skb_cgroup_id#79

There are no particular reasons for denying it, and we have some
use cases where it might be useful.

So let's add it to the list of allowed helpers.

Signed-off-by: Roman Gushchin <guro@fb.com>
Cc: Yonghong Song <yhs@fb.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
---
 net/core/filter.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Martin KaFai Lau June 6, 2019, 9:51 p.m. UTC | #1
On Thu, Jun 06, 2019 at 01:30:12PM -0700, Roman Gushchin wrote:
> Currently bpf_skb_cgroup_id() is not supported for CGROUP_SKB
> programs. An attempt to load such a program generates an error
> like this:
> 
>     libbpf:
>     0: (b7) r6 = 0
>     ...
>     9: (85) call bpf_skb_cgroup_id#79
>     unknown func bpf_skb_cgroup_id#79
> 
> There are no particular reasons for denying it, and we have some
> use cases where it might be useful.
> 
> So let's add it to the list of allowed helpers.
Acked-by: Martin KaFai Lau <kafai@fb.com>
Daniel Borkmann June 7, 2019, midnight UTC | #2
On 06/06/2019 10:30 PM, Roman Gushchin wrote:
> Currently bpf_skb_cgroup_id() is not supported for CGROUP_SKB
> programs. An attempt to load such a program generates an error
> like this:
> 
>     libbpf:
>     0: (b7) r6 = 0
>     ...
>     9: (85) call bpf_skb_cgroup_id#79
>     unknown func bpf_skb_cgroup_id#79
> 
> There are no particular reasons for denying it, and we have some
> use cases where it might be useful.
> 
> So let's add it to the list of allowed helpers.
> 
> Signed-off-by: Roman Gushchin <guro@fb.com>
> Cc: Yonghong Song <yhs@fb.com>
> Cc: Alexei Starovoitov <ast@kernel.org>
> Cc: Daniel Borkmann <daniel@iogearbox.net>

Applied, thanks!
Roman Gushchin June 7, 2019, 12:09 a.m. UTC | #3
On Fri, Jun 07, 2019 at 02:00:20AM +0200, Daniel Borkmann wrote:
> On 06/06/2019 10:30 PM, Roman Gushchin wrote:
> > Currently bpf_skb_cgroup_id() is not supported for CGROUP_SKB
> > programs. An attempt to load such a program generates an error
> > like this:
> > 
> >     libbpf:
> >     0: (b7) r6 = 0
> >     ...
> >     9: (85) call bpf_skb_cgroup_id#79
> >     unknown func bpf_skb_cgroup_id#79
> > 
> > There are no particular reasons for denying it, and we have some
> > use cases where it might be useful.
> > 
> > So let's add it to the list of allowed helpers.
> > 
> > Signed-off-by: Roman Gushchin <guro@fb.com>
> > Cc: Yonghong Song <yhs@fb.com>
> > Cc: Alexei Starovoitov <ast@kernel.org>
> > Cc: Daniel Borkmann <daniel@iogearbox.net>
> 
> Applied, thanks!

Thank you, Daniel!
diff mbox series

Patch

diff --git a/net/core/filter.c b/net/core/filter.c
index 55bfc941d17a..f2777dc0b624 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -5919,6 +5919,10 @@  cg_skb_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;
+#ifdef CONFIG_SOCK_CGROUP_DATA
+	case BPF_FUNC_skb_cgroup_id:
+		return &bpf_skb_cgroup_id_proto;
+#endif
 #ifdef CONFIG_INET
 	case BPF_FUNC_tcp_sock:
 		return &bpf_tcp_sock_proto;