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

v1->v2:
- add new types to bpftool-cgroup man page;
- add new types to bash completion for bpftool;
- don't add types that should not be in bpftool cgroup.

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: Support new prog types and attach types
  libbpf: Support guessing post_bind{4,6} progs
  libbpf: Type functions for raw tracepoints

 tools/bpf/bpftool/Documentation/bpftool-cgroup.rst | 11 +++++++++--
 tools/bpf/bpftool/bash-completion/bpftool          |  6 ++++--
 tools/bpf/bpftool/cgroup.c                         | 15 ++++++++++++---
 tools/bpf/bpftool/prog.c                           |  3 +++
 tools/lib/bpf/libbpf.c                             |  8 ++++++++
 tools/lib/bpf/libbpf.h                             |  2 ++
 6 files changed, 38 insertions(+), 7 deletions(-)

-- 
2.9.5

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

* [PATCH v2 bpf-next 1/3] bpftool: Support new prog types and attach types
  2018-04-17 17:28 [PATCH v2 bpf-next 0/3] Add missing types to bpftool, libbpf Andrey Ignatov
@ 2018-04-17 17:28 ` Andrey Ignatov
  2018-04-17 23:09   ` Jakub Kicinski
  2018-04-17 17:28 ` [PATCH v2 bpf-next 2/3] libbpf: Support guessing post_bind{4,6} progs Andrey Ignatov
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 7+ messages in thread
From: Andrey Ignatov @ 2018-04-17 17:28 UTC (permalink / raw)
  To: ast, daniel; +Cc: Andrey Ignatov, kubakici, quentin.monnet, netdev, kernel-team

Add recently added prog types to `bpftool prog` and attach types to
`bpftool cgroup`.

Update bpftool documentation and bash completion appropriately.

Signed-off-by: Andrey Ignatov <rdna@fb.com>
---
 tools/bpf/bpftool/Documentation/bpftool-cgroup.rst | 11 +++++++++--
 tools/bpf/bpftool/bash-completion/bpftool          |  6 ++++--
 tools/bpf/bpftool/cgroup.c                         | 15 ++++++++++++---
 tools/bpf/bpftool/prog.c                           |  3 +++
 4 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/tools/bpf/bpftool/Documentation/bpftool-cgroup.rst b/tools/bpf/bpftool/Documentation/bpftool-cgroup.rst
index 0e4e923..d004f63 100644
--- a/tools/bpf/bpftool/Documentation/bpftool-cgroup.rst
+++ b/tools/bpf/bpftool/Documentation/bpftool-cgroup.rst
@@ -26,7 +26,8 @@ MAP COMMANDS
 |	**bpftool** **cgroup help**
 |
 |	*PROG* := { **id** *PROG_ID* | **pinned** *FILE* | **tag** *PROG_TAG* }
-|	*ATTACH_TYPE* := { **ingress** | **egress** | **sock_create** | **sock_ops** | **device** }
+|	*ATTACH_TYPE* := { **ingress** | **egress** | **sock_create** | **sock_ops** | **device** |
+|		**bind4** | **bind6** | **post_bind4** | **post_bind6** | **connect4** | **connect6** }
 |	*ATTACH_FLAGS* := { **multi** | **override** }
 
 DESCRIPTION
@@ -63,7 +64,13 @@ DESCRIPTION
 		  **egress** egress path of the inet socket (since 4.10);
 		  **sock_create** opening of an inet socket (since 4.10);
 		  **sock_ops** various socket operations (since 4.12);
-		  **device** device access (since 4.15).
+		  **device** device access (since 4.15);
+		  **bind4** call to bind(2) for an inet4 socket (since 4.17);
+		  **bind6** call to bind(2) for an inet6 socket (since 4.17);
+		  **post_bind4** return from bind(2) for an inet4 socket (since 4.17);
+		  **post_bind6** return from bind(2) for an inet6 socket (since 4.17);
+		  **connect4** call to connect(2) for an inet4 socket (since 4.17);
+		  **connect6** call to connect(2) for an inet6 socket (since 4.17).
 
 	**bpftool cgroup detach** *CGROUP* *ATTACH_TYPE* *PROG*
 		  Detach *PROG* from the cgroup *CGROUP* and attach type
diff --git a/tools/bpf/bpftool/bash-completion/bpftool b/tools/bpf/bpftool/bash-completion/bpftool
index 490811b..c01b2de 100644
--- a/tools/bpf/bpftool/bash-completion/bpftool
+++ b/tools/bpf/bpftool/bash-completion/bpftool
@@ -372,7 +372,8 @@ _bpftool()
                     ;;
                 attach|detach)
                     local ATTACH_TYPES='ingress egress sock_create sock_ops \
-                        device'
+                        device bind4 bind6 post_bind4 post_bind6 connect4 \
+                        connect6'
                     local ATTACH_FLAGS='multi override'
                     local PROG_TYPE='id pinned tag'
                     case $prev in
@@ -380,7 +381,8 @@ _bpftool()
                             _filedir
                             return 0
                             ;;
-                        ingress|egress|sock_create|sock_ops|device)
+                        ingress|egress|sock_create|sock_ops|device|bind4|bind6|\
+                        post_bind4|post_bind6|connect4|connect6)
                             COMPREPLY=( $( compgen -W "$PROG_TYPE" -- \
                                 "$cur" ) )
                             return 0
diff --git a/tools/bpf/bpftool/cgroup.c b/tools/bpf/bpftool/cgroup.c
index cae32a6..1351bd6 100644
--- a/tools/bpf/bpftool/cgroup.c
+++ b/tools/bpf/bpftool/cgroup.c
@@ -16,8 +16,11 @@
 #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 | device | bind4 | bind6 |\n"	       \
+	"                        post_bind4 | post_bind6 | connect4 |\n"       \
+	"                        connect6 }"
 
 static const char * const attach_type_strings[] = {
 	[BPF_CGROUP_INET_INGRESS] = "ingress",
@@ -25,6 +28,12 @@ static const char * const attach_type_strings[] = {
 	[BPF_CGROUP_INET_SOCK_CREATE] = "sock_create",
 	[BPF_CGROUP_SOCK_OPS] = "sock_ops",
 	[BPF_CGROUP_DEVICE] = "device",
+	[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 +291,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 v2 bpf-next 2/3] libbpf: Support guessing post_bind{4,6} progs
  2018-04-17 17:28 [PATCH v2 bpf-next 0/3] Add missing types to bpftool, libbpf Andrey Ignatov
  2018-04-17 17:28 ` [PATCH v2 bpf-next 1/3] bpftool: Support new prog types and attach types Andrey Ignatov
@ 2018-04-17 17:28 ` Andrey Ignatov
  2018-04-17 17:28 ` [PATCH v2 bpf-next 3/3] libbpf: Type functions for raw tracepoints Andrey Ignatov
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Andrey Ignatov @ 2018-04-17 17:28 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 v2 bpf-next 3/3] libbpf: Type functions for raw tracepoints
  2018-04-17 17:28 [PATCH v2 bpf-next 0/3] Add missing types to bpftool, libbpf Andrey Ignatov
  2018-04-17 17:28 ` [PATCH v2 bpf-next 1/3] bpftool: Support new prog types and attach types Andrey Ignatov
  2018-04-17 17:28 ` [PATCH v2 bpf-next 2/3] libbpf: Support guessing post_bind{4,6} progs Andrey Ignatov
@ 2018-04-17 17:28 ` Andrey Ignatov
  2018-04-18  0:58 ` [PATCH v2 bpf-next 0/3] Add missing types to bpftool, libbpf Alexei Starovoitov
  2018-04-18 12:42 ` Daniel Borkmann
  4 siblings, 0 replies; 7+ messages in thread
From: Andrey Ignatov @ 2018-04-17 17:28 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 v2 bpf-next 1/3] bpftool: Support new prog types and attach types
  2018-04-17 17:28 ` [PATCH v2 bpf-next 1/3] bpftool: Support new prog types and attach types Andrey Ignatov
@ 2018-04-17 23:09   ` Jakub Kicinski
  0 siblings, 0 replies; 7+ messages in thread
From: Jakub Kicinski @ 2018-04-17 23:09 UTC (permalink / raw)
  To: Andrey Ignatov; +Cc: ast, daniel, quentin.monnet, netdev, kernel-team

On Tue, 17 Apr 2018 10:28:44 -0700, Andrey Ignatov wrote:
> Add recently added prog types to `bpftool prog` and attach types to
> `bpftool cgroup`.
> 
> Update bpftool documentation and bash completion appropriately.
> 
> Signed-off-by: Andrey Ignatov <rdna@fb.com>

Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>

Thank you!!

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

* Re: [PATCH v2 bpf-next 0/3] Add missing types to bpftool, libbpf
  2018-04-17 17:28 [PATCH v2 bpf-next 0/3] Add missing types to bpftool, libbpf Andrey Ignatov
                   ` (2 preceding siblings ...)
  2018-04-17 17:28 ` [PATCH v2 bpf-next 3/3] libbpf: Type functions for raw tracepoints Andrey Ignatov
@ 2018-04-18  0:58 ` Alexei Starovoitov
  2018-04-18 12:42 ` Daniel Borkmann
  4 siblings, 0 replies; 7+ messages in thread
From: Alexei Starovoitov @ 2018-04-18  0:58 UTC (permalink / raw)
  To: Andrey Ignatov; +Cc: ast, daniel, kubakici, quentin.monnet, netdev, kernel-team

On Tue, Apr 17, 2018 at 10:28:43AM -0700, Andrey Ignatov wrote:
> v1->v2:
> - add new types to bpftool-cgroup man page;
> - add new types to bash completion for bpftool;
> - don't add types that should not be in bpftool cgroup.
> 
> Add support for various BPF prog types and attach types that have been
> added to kernel recently but not to bpftool or libbpf yet.

lgtm. for the set:
Acked-by: Alexei Starovoitov <ast@kernel.org>

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

* Re: [PATCH v2 bpf-next 0/3] Add missing types to bpftool, libbpf
  2018-04-17 17:28 [PATCH v2 bpf-next 0/3] Add missing types to bpftool, libbpf Andrey Ignatov
                   ` (3 preceding siblings ...)
  2018-04-18  0:58 ` [PATCH v2 bpf-next 0/3] Add missing types to bpftool, libbpf Alexei Starovoitov
@ 2018-04-18 12:42 ` Daniel Borkmann
  4 siblings, 0 replies; 7+ messages in thread
From: Daniel Borkmann @ 2018-04-18 12:42 UTC (permalink / raw)
  To: Andrey Ignatov, ast; +Cc: kubakici, quentin.monnet, netdev, kernel-team

On 04/17/2018 07:28 PM, Andrey Ignatov wrote:
> v1->v2:
> - add new types to bpftool-cgroup man page;
> - add new types to bash completion for bpftool;
> - don't add types that should not be in bpftool cgroup.
> 
> 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: Support new prog types and attach types
>   libbpf: Support guessing post_bind{4,6} progs
>   libbpf: Type functions for raw tracepoints

Applied to bpf-next, thanks Andrey!

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

end of thread, other threads:[~2018-04-18 12:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-17 17:28 [PATCH v2 bpf-next 0/3] Add missing types to bpftool, libbpf Andrey Ignatov
2018-04-17 17:28 ` [PATCH v2 bpf-next 1/3] bpftool: Support new prog types and attach types Andrey Ignatov
2018-04-17 23:09   ` Jakub Kicinski
2018-04-17 17:28 ` [PATCH v2 bpf-next 2/3] libbpf: Support guessing post_bind{4,6} progs Andrey Ignatov
2018-04-17 17:28 ` [PATCH v2 bpf-next 3/3] libbpf: Type functions for raw tracepoints Andrey Ignatov
2018-04-18  0:58 ` [PATCH v2 bpf-next 0/3] Add missing types to bpftool, libbpf Alexei Starovoitov
2018-04-18 12:42 ` Daniel Borkmann

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.