[bpf-next,1/3] bpftool: Add missing prog types and attach types

Message ID 5dd2cc619f2eed089e7da9bd7f64031278d6b4fe.1523914232.git.rdna@fb.com
State Changes Requested
Delegated to: BPF Maintainers
Headers show
Series
  • Add missing types to bpftool, libbpf
Related show

Commit Message

Andrey Ignatov April 16, 2018, 9:41 p.m.
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(-)

Comments

Jakub Kicinski April 16, 2018, 11:52 p.m. | #1
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!
Andrey Ignatov April 16, 2018, 11:57 p.m. | #2
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.
Quentin Monnet April 17, 2018, 10:31 a.m. | #3
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

Patch

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)