All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/3] Add missing types to bpftool, libbpf
@ 2018-04-16 21:41 Andrey Ignatov
  2018-04-16 21:41 ` [PATCH bpf-next 1/3] bpftool: Add missing prog types and attach types Andrey Ignatov
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Andrey Ignatov @ 2018-04-16 21:41 UTC (permalink / raw)
  To: ast, daniel; +Cc: Andrey Ignatov, netdev, kernel-team

Add support for various BPF prog types and attach types that have been added to
kernel recently but not to bpftool or libbpf yet.


Andrey Ignatov (3):
  bpftool: Add missing prog types and attach types
  libbpf: Support guessing post_bind{4,6} progs
  libbpf: Type functions for raw tracepoints

 tools/bpf/bpftool/cgroup.c | 19 ++++++++++++++++---
 tools/bpf/bpftool/prog.c   |  3 +++
 tools/lib/bpf/libbpf.c     |  8 ++++++++
 tools/lib/bpf/libbpf.h     |  2 ++
 4 files changed, 29 insertions(+), 3 deletions(-)

-- 
2.9.5

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH bpf-next 1/3] bpftool: Add missing prog types and attach types
  2018-04-16 21:41 [PATCH bpf-next 0/3] Add missing types to bpftool, libbpf Andrey Ignatov
@ 2018-04-16 21:41 ` Andrey Ignatov
  2018-04-16 23:52   ` Jakub Kicinski
  2018-04-16 21:41 ` [PATCH bpf-next 2/3] libbpf: Support guessing post_bind{4,6} progs Andrey Ignatov
  2018-04-16 21:41 ` [PATCH bpf-next 3/3] libbpf: Type functions for raw tracepoints Andrey Ignatov
  2 siblings, 1 reply; 7+ messages in thread
From: Andrey Ignatov @ 2018-04-16 21:41 UTC (permalink / raw)
  To: ast, daniel; +Cc: Andrey Ignatov, netdev, kernel-team

Add missing prog types to `bpftool prog` and missing attach types to
`bpftool cgroup`.

Signed-off-by: Andrey Ignatov <rdna@fb.com>
---
 tools/bpf/bpftool/cgroup.c | 19 ++++++++++++++++---
 tools/bpf/bpftool/prog.c   |  3 +++
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/tools/bpf/bpftool/cgroup.c b/tools/bpf/bpftool/cgroup.c
index cae32a6..8689916 100644
--- a/tools/bpf/bpftool/cgroup.c
+++ b/tools/bpf/bpftool/cgroup.c
@@ -16,15 +16,28 @@
 #define HELP_SPEC_ATTACH_FLAGS						\
 	"ATTACH_FLAGS := { multi | override }"
 
-#define HELP_SPEC_ATTACH_TYPES						\
-	"ATTACH_TYPE := { ingress | egress | sock_create | sock_ops | device }"
+#define HELP_SPEC_ATTACH_TYPES						       \
+	"       ATTACH_TYPE := { ingress | egress | sock_create |\n"	       \
+	"                        sock_ops | stream_parser |\n"		       \
+	"                        stream_verdict | device | msg_verdict |\n"    \
+	"                        bind4 | bind6 | connect4 | connect6 |\n"      \
+	"                        post_bind4 | post_bind6 }"
 
 static const char * const attach_type_strings[] = {
 	[BPF_CGROUP_INET_INGRESS] = "ingress",
 	[BPF_CGROUP_INET_EGRESS] = "egress",
 	[BPF_CGROUP_INET_SOCK_CREATE] = "sock_create",
 	[BPF_CGROUP_SOCK_OPS] = "sock_ops",
+	[BPF_SK_SKB_STREAM_PARSER] = "stream_parser",
+	[BPF_SK_SKB_STREAM_VERDICT] = "stream_verdict",
 	[BPF_CGROUP_DEVICE] = "device",
+	[BPF_SK_MSG_VERDICT] = "msg_verdict",
+	[BPF_CGROUP_INET4_BIND] = "bind4",
+	[BPF_CGROUP_INET6_BIND] = "bind6",
+	[BPF_CGROUP_INET4_CONNECT] = "connect4",
+	[BPF_CGROUP_INET6_CONNECT] = "connect6",
+	[BPF_CGROUP_INET4_POST_BIND] = "post_bind4",
+	[BPF_CGROUP_INET6_POST_BIND] = "post_bind6",
 	[__MAX_BPF_ATTACH_TYPE] = NULL,
 };
 
@@ -282,7 +295,7 @@ static int do_help(int argc, char **argv)
 		"       %s %s detach CGROUP ATTACH_TYPE PROG\n"
 		"       %s %s help\n"
 		"\n"
-		"       " HELP_SPEC_ATTACH_TYPES "\n"
+		HELP_SPEC_ATTACH_TYPES "\n"
 		"       " HELP_SPEC_ATTACH_FLAGS "\n"
 		"       " HELP_SPEC_PROGRAM "\n"
 		"       " HELP_SPEC_OPTIONS "\n"
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
index f7a8108..548adb9 100644
--- a/tools/bpf/bpftool/prog.c
+++ b/tools/bpf/bpftool/prog.c
@@ -68,6 +68,9 @@ static const char * const prog_type_name[] = {
 	[BPF_PROG_TYPE_SOCK_OPS]	= "sock_ops",
 	[BPF_PROG_TYPE_SK_SKB]		= "sk_skb",
 	[BPF_PROG_TYPE_CGROUP_DEVICE]	= "cgroup_device",
+	[BPF_PROG_TYPE_SK_MSG]		= "sk_msg",
+	[BPF_PROG_TYPE_RAW_TRACEPOINT]	= "raw_tracepoint",
+	[BPF_PROG_TYPE_CGROUP_SOCK_ADDR] = "cgroup_sock_addr",
 };
 
 static void print_boot_time(__u64 nsecs, char *buf, unsigned int size)
-- 
2.9.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH bpf-next 2/3] libbpf: Support guessing post_bind{4,6} progs
  2018-04-16 21:41 [PATCH bpf-next 0/3] Add missing types to bpftool, libbpf Andrey Ignatov
  2018-04-16 21:41 ` [PATCH bpf-next 1/3] bpftool: Add missing prog types and attach types Andrey Ignatov
@ 2018-04-16 21:41 ` Andrey Ignatov
  2018-04-16 21:41 ` [PATCH bpf-next 3/3] libbpf: Type functions for raw tracepoints Andrey Ignatov
  2 siblings, 0 replies; 7+ messages in thread
From: Andrey Ignatov @ 2018-04-16 21:41 UTC (permalink / raw)
  To: ast, daniel; +Cc: Andrey Ignatov, netdev, kernel-team

libbpf can guess prog type and expected attach type based on section
name. Add hints for "cgroup/post_bind4" and "cgroup/post_bind6" section
names.

Existing "cgroup/sock" is not changed, i.e. expected_attach_type for it
is not set to `BPF_CGROUP_INET_SOCK_CREATE`, for backward compatibility.

Signed-off-by: Andrey Ignatov <rdna@fb.com>
---
 tools/lib/bpf/libbpf.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 5922443..0fcc447 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -1859,6 +1859,9 @@ static void bpf_program__set_expected_attach_type(struct bpf_program *prog,
 
 #define BPF_PROG_SEC(string, ptype) BPF_PROG_SEC_FULL(string, ptype, 0)
 
+#define BPF_S_PROG_SEC(string, ptype) \
+	BPF_PROG_SEC_FULL(string, BPF_PROG_TYPE_CGROUP_SOCK, ptype)
+
 #define BPF_SA_PROG_SEC(string, ptype) \
 	BPF_PROG_SEC_FULL(string, BPF_PROG_TYPE_CGROUP_SOCK_ADDR, ptype)
 
@@ -1889,10 +1892,13 @@ static const struct {
 	BPF_SA_PROG_SEC("cgroup/bind6",	BPF_CGROUP_INET6_BIND),
 	BPF_SA_PROG_SEC("cgroup/connect4", BPF_CGROUP_INET4_CONNECT),
 	BPF_SA_PROG_SEC("cgroup/connect6", BPF_CGROUP_INET6_CONNECT),
+	BPF_S_PROG_SEC("cgroup/post_bind4", BPF_CGROUP_INET4_POST_BIND),
+	BPF_S_PROG_SEC("cgroup/post_bind6", BPF_CGROUP_INET6_POST_BIND),
 };
 
 #undef BPF_PROG_SEC
 #undef BPF_PROG_SEC_FULL
+#undef BPF_S_PROG_SEC
 #undef BPF_SA_PROG_SEC
 
 static int bpf_program__identify_section(struct bpf_program *prog)
-- 
2.9.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH bpf-next 3/3] libbpf: Type functions for raw tracepoints
  2018-04-16 21:41 [PATCH bpf-next 0/3] Add missing types to bpftool, libbpf Andrey Ignatov
  2018-04-16 21:41 ` [PATCH bpf-next 1/3] bpftool: Add missing prog types and attach types Andrey Ignatov
  2018-04-16 21:41 ` [PATCH bpf-next 2/3] libbpf: Support guessing post_bind{4,6} progs Andrey Ignatov
@ 2018-04-16 21:41 ` Andrey Ignatov
  2 siblings, 0 replies; 7+ messages in thread
From: Andrey Ignatov @ 2018-04-16 21:41 UTC (permalink / raw)
  To: ast, daniel; +Cc: Andrey Ignatov, netdev, kernel-team

Add missing pieces for BPF_PROG_TYPE_RAW_TRACEPOINT in libbpf:
* is- and set- functions;
* support guessing prog type.

Signed-off-by: Andrey Ignatov <rdna@fb.com>
---
 tools/lib/bpf/libbpf.c | 2 ++
 tools/lib/bpf/libbpf.h | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 0fcc447..3d35bac 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -1845,6 +1845,7 @@ BPF_PROG_TYPE_FNS(kprobe, BPF_PROG_TYPE_KPROBE);
 BPF_PROG_TYPE_FNS(sched_cls, BPF_PROG_TYPE_SCHED_CLS);
 BPF_PROG_TYPE_FNS(sched_act, BPF_PROG_TYPE_SCHED_ACT);
 BPF_PROG_TYPE_FNS(tracepoint, BPF_PROG_TYPE_TRACEPOINT);
+BPF_PROG_TYPE_FNS(raw_tracepoint, BPF_PROG_TYPE_RAW_TRACEPOINT);
 BPF_PROG_TYPE_FNS(xdp, BPF_PROG_TYPE_XDP);
 BPF_PROG_TYPE_FNS(perf_event, BPF_PROG_TYPE_PERF_EVENT);
 
@@ -1877,6 +1878,7 @@ static const struct {
 	BPF_PROG_SEC("classifier",	BPF_PROG_TYPE_SCHED_CLS),
 	BPF_PROG_SEC("action",		BPF_PROG_TYPE_SCHED_ACT),
 	BPF_PROG_SEC("tracepoint/",	BPF_PROG_TYPE_TRACEPOINT),
+	BPF_PROG_SEC("raw_tracepoint/",	BPF_PROG_TYPE_RAW_TRACEPOINT),
 	BPF_PROG_SEC("xdp",		BPF_PROG_TYPE_XDP),
 	BPF_PROG_SEC("perf_event",	BPF_PROG_TYPE_PERF_EVENT),
 	BPF_PROG_SEC("cgroup/skb",	BPF_PROG_TYPE_CGROUP_SKB),
diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
index a3a62a5..8b24248 100644
--- a/tools/lib/bpf/libbpf.h
+++ b/tools/lib/bpf/libbpf.h
@@ -185,6 +185,7 @@ int bpf_program__nth_fd(struct bpf_program *prog, int n);
  */
 int bpf_program__set_socket_filter(struct bpf_program *prog);
 int bpf_program__set_tracepoint(struct bpf_program *prog);
+int bpf_program__set_raw_tracepoint(struct bpf_program *prog);
 int bpf_program__set_kprobe(struct bpf_program *prog);
 int bpf_program__set_sched_cls(struct bpf_program *prog);
 int bpf_program__set_sched_act(struct bpf_program *prog);
@@ -194,6 +195,7 @@ void bpf_program__set_type(struct bpf_program *prog, enum bpf_prog_type type);
 
 bool bpf_program__is_socket_filter(struct bpf_program *prog);
 bool bpf_program__is_tracepoint(struct bpf_program *prog);
+bool bpf_program__is_raw_tracepoint(struct bpf_program *prog);
 bool bpf_program__is_kprobe(struct bpf_program *prog);
 bool bpf_program__is_sched_cls(struct bpf_program *prog);
 bool bpf_program__is_sched_act(struct bpf_program *prog);
-- 
2.9.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH bpf-next 1/3] bpftool: Add missing prog types and attach types
  2018-04-16 21:41 ` [PATCH bpf-next 1/3] bpftool: Add missing prog types and attach types Andrey Ignatov
@ 2018-04-16 23:52   ` Jakub Kicinski
  2018-04-16 23:57     ` Andrey Ignatov
  0 siblings, 1 reply; 7+ messages in thread
From: Jakub Kicinski @ 2018-04-16 23:52 UTC (permalink / raw)
  To: Andrey Ignatov; +Cc: ast, daniel, netdev, kernel-team

On Mon, 16 Apr 2018 14:41:57 -0700, Andrey Ignatov wrote:
> diff --git a/tools/bpf/bpftool/cgroup.c b/tools/bpf/bpftool/cgroup.c
> index cae32a6..8689916 100644
> --- a/tools/bpf/bpftool/cgroup.c
> +++ b/tools/bpf/bpftool/cgroup.c
> @@ -16,15 +16,28 @@
>  #define HELP_SPEC_ATTACH_FLAGS						\
>  	"ATTACH_FLAGS := { multi | override }"
>  
> -#define HELP_SPEC_ATTACH_TYPES						\
> -	"ATTACH_TYPE := { ingress | egress | sock_create | sock_ops | device }"
> +#define HELP_SPEC_ATTACH_TYPES						       \
> +	"       ATTACH_TYPE := { ingress | egress | sock_create |\n"	       \
> +	"                        sock_ops | stream_parser |\n"		       \
> +	"                        stream_verdict | device | msg_verdict |\n"    \
> +	"                        bind4 | bind6 | connect4 | connect6 |\n"      \
> +	"                        post_bind4 | post_bind6 }"
>  

Would you mind updating the man page in Documentation/ as well?

Thanks!

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH bpf-next 1/3] bpftool: Add missing prog types and attach types
  2018-04-16 23:52   ` Jakub Kicinski
@ 2018-04-16 23:57     ` Andrey Ignatov
  2018-04-17 10:31       ` Quentin Monnet
  0 siblings, 1 reply; 7+ messages in thread
From: Andrey Ignatov @ 2018-04-16 23:57 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: ast, daniel, netdev, kernel-team

Jakub Kicinski <kubakici@wp.pl> [Mon, 2018-04-16 16:53 -0700]:
> On Mon, 16 Apr 2018 14:41:57 -0700, Andrey Ignatov wrote:
> > diff --git a/tools/bpf/bpftool/cgroup.c b/tools/bpf/bpftool/cgroup.c
> > index cae32a6..8689916 100644
> > --- a/tools/bpf/bpftool/cgroup.c
> > +++ b/tools/bpf/bpftool/cgroup.c
> > @@ -16,15 +16,28 @@
> >  #define HELP_SPEC_ATTACH_FLAGS						\
> >  	"ATTACH_FLAGS := { multi | override }"
> >  
> > -#define HELP_SPEC_ATTACH_TYPES						\
> > -	"ATTACH_TYPE := { ingress | egress | sock_create | sock_ops | device }"
> > +#define HELP_SPEC_ATTACH_TYPES						       \
> > +	"       ATTACH_TYPE := { ingress | egress | sock_create |\n"	       \
> > +	"                        sock_ops | stream_parser |\n"		       \
> > +	"                        stream_verdict | device | msg_verdict |\n"    \
> > +	"                        bind4 | bind6 | connect4 | connect6 |\n"      \
> > +	"                        post_bind4 | post_bind6 }"
> >  
> 
> Would you mind updating the man page in Documentation/ as well?

Sure. Will update and send v2.

-- 
Andrey Ignatov

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH bpf-next 1/3] bpftool: Add missing prog types and attach types
  2018-04-16 23:57     ` Andrey Ignatov
@ 2018-04-17 10:31       ` Quentin Monnet
  0 siblings, 0 replies; 7+ messages in thread
From: Quentin Monnet @ 2018-04-17 10:31 UTC (permalink / raw)
  To: Andrey Ignatov, Jakub Kicinski; +Cc: ast, daniel, netdev, kernel-team

2018-04-16 16:57 UTC-0700 ~ Andrey Ignatov <rdna@fb.com>
> Jakub Kicinski <kubakici@wp.pl> [Mon, 2018-04-16 16:53 -0700]:
>> On Mon, 16 Apr 2018 14:41:57 -0700, Andrey Ignatov wrote:
>>> diff --git a/tools/bpf/bpftool/cgroup.c b/tools/bpf/bpftool/cgroup.c
>>> index cae32a6..8689916 100644
>>> --- a/tools/bpf/bpftool/cgroup.c
>>> +++ b/tools/bpf/bpftool/cgroup.c
>>> @@ -16,15 +16,28 @@
>>>  #define HELP_SPEC_ATTACH_FLAGS						\
>>>  	"ATTACH_FLAGS := { multi | override }"
>>>  
>>> -#define HELP_SPEC_ATTACH_TYPES						\
>>> -	"ATTACH_TYPE := { ingress | egress | sock_create | sock_ops | device }"
>>> +#define HELP_SPEC_ATTACH_TYPES						       \
>>> +	"       ATTACH_TYPE := { ingress | egress | sock_create |\n"	       \
>>> +	"                        sock_ops | stream_parser |\n"		       \
>>> +	"                        stream_verdict | device | msg_verdict |\n"    \
>>> +	"                        bind4 | bind6 | connect4 | connect6 |\n"      \
>>> +	"                        post_bind4 | post_bind6 }"
>>>  
>>
>> Would you mind updating the man page in Documentation/ as well?
> 
> Sure. Will update and send v2.
> 

Hi Andrey,

In addition to the Documentation, there would also be the bash completion
to update. The patch below should make it, please feel free to incorporate
it to your changes if it seems alright to you. Otherwise I'll submit it as
a follow-up.

Quentin

---

diff --git a/tools/bpf/bpftool/bash-completion/bpftool b/tools/bpf/bpftool/bash-completion/bpftool
index 71cc5dec3685..dad9109c2800 100644
--- a/tools/bpf/bpftool/bash-completion/bpftool
+++ b/tools/bpf/bpftool/bash-completion/bpftool
@@ -374,7 +374,8 @@ _bpftool()
                     ;;
                 attach|detach)
                     local ATTACH_TYPES='ingress egress sock_create sock_ops \
-                        device'
+                        stream_parser stream_verdict device msg_verdict bind4 \
+                        bind6 connect4 connect6 post_bind4 post_bind6'
                     local ATTACH_FLAGS='multi override'
                     local PROG_TYPE='id pinned tag'
                     case $prev in
@@ -382,7 +383,9 @@ _bpftool()
                             _filedir
                             return 0
                             ;;
-                        ingress|egress|sock_create|sock_ops|device)
+                        ingress|egress|sock_create|sock_ops|stream_parser|\
+                            stream_verdict|device|msg_verdict|bind4|bind6|\
+                            connect4|connect6|post_bind4|post_bind6)
                             COMPREPLY=( $( compgen -W "$PROG_TYPE" -- \
                                 "$cur" ) )
                             return 0

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-04-17 10:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-16 21:41 [PATCH bpf-next 0/3] Add missing types to bpftool, libbpf Andrey Ignatov
2018-04-16 21:41 ` [PATCH bpf-next 1/3] bpftool: Add missing prog types and attach types Andrey Ignatov
2018-04-16 23:52   ` Jakub Kicinski
2018-04-16 23:57     ` Andrey Ignatov
2018-04-17 10:31       ` Quentin Monnet
2018-04-16 21:41 ` [PATCH bpf-next 2/3] libbpf: Support guessing post_bind{4,6} progs Andrey Ignatov
2018-04-16 21:41 ` [PATCH bpf-next 3/3] libbpf: Type functions for raw tracepoints Andrey Ignatov

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.