From: Alexei Starovoitov <ast@fb•com>
To: <davem@davemloft•net>
Cc: <daniel@iogearbox•net>, <torvalds@linux-foundation•org>,
<peterz@infradead•org>, <rostedt@goodmis•org>,
<netdev@vger•kernel.org>, <kernel-team@fb•com>,
<linux-api@vger•kernel.org>
Subject: [PATCH v6 bpf-next 09/11] libbpf: add bpf_raw_tracepoint_open helper
Date: Mon, 26 Mar 2018 19:47:04 -0700 [thread overview]
Message-ID: <20180327024706.2064725-10-ast@fb.com> (raw)
In-Reply-To: <20180327024706.2064725-1-ast@fb.com>
From: Alexei Starovoitov <ast@kernel•org>
add bpf_raw_tracepoint_open(const char *name, int prog_fd) api to libbpf
Signed-off-by: Alexei Starovoitov <ast@kernel•org>
---
tools/include/uapi/linux/bpf.h | 11 +++++++++++
tools/lib/bpf/bpf.c | 11 +++++++++++
tools/lib/bpf/bpf.h | 1 +
3 files changed, 23 insertions(+)
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index d245c41213ac..58060bec999d 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -94,6 +94,7 @@ enum bpf_cmd {
BPF_MAP_GET_FD_BY_ID,
BPF_OBJ_GET_INFO_BY_FD,
BPF_PROG_QUERY,
+ BPF_RAW_TRACEPOINT_OPEN,
};
enum bpf_map_type {
@@ -134,6 +135,7 @@ enum bpf_prog_type {
BPF_PROG_TYPE_SK_SKB,
BPF_PROG_TYPE_CGROUP_DEVICE,
BPF_PROG_TYPE_SK_MSG,
+ BPF_PROG_TYPE_RAW_TRACEPOINT,
};
enum bpf_attach_type {
@@ -344,6 +346,11 @@ union bpf_attr {
__aligned_u64 prog_ids;
__u32 prog_cnt;
} query;
+
+ struct {
+ __u64 name;
+ __u32 prog_fd;
+ } raw_tracepoint;
} __attribute__((aligned(8)));
/* BPF helper function descriptions:
@@ -1151,4 +1158,8 @@ struct bpf_cgroup_dev_ctx {
__u32 minor;
};
+struct bpf_raw_tracepoint_args {
+ __u64 args[0];
+};
+
#endif /* _UAPI__LINUX_BPF_H__ */
diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
index 592a58a2b681..e0500055f1a6 100644
--- a/tools/lib/bpf/bpf.c
+++ b/tools/lib/bpf/bpf.c
@@ -428,6 +428,17 @@ int bpf_obj_get_info_by_fd(int prog_fd, void *info, __u32 *info_len)
return err;
}
+int bpf_raw_tracepoint_open(const char *name, int prog_fd)
+{
+ union bpf_attr attr;
+
+ bzero(&attr, sizeof(attr));
+ attr.raw_tracepoint.name = ptr_to_u64(name);
+ attr.raw_tracepoint.prog_fd = prog_fd;
+
+ return sys_bpf(BPF_RAW_TRACEPOINT_OPEN, &attr, sizeof(attr));
+}
+
int bpf_set_link_xdp_fd(int ifindex, int fd, __u32 flags)
{
struct sockaddr_nl sa;
diff --git a/tools/lib/bpf/bpf.h b/tools/lib/bpf/bpf.h
index 8d18fb73d7fb..ee59342c6f42 100644
--- a/tools/lib/bpf/bpf.h
+++ b/tools/lib/bpf/bpf.h
@@ -79,4 +79,5 @@ int bpf_map_get_fd_by_id(__u32 id);
int bpf_obj_get_info_by_fd(int prog_fd, void *info, __u32 *info_len);
int bpf_prog_query(int target_fd, enum bpf_attach_type type, __u32 query_flags,
__u32 *attach_flags, __u32 *prog_ids, __u32 *prog_cnt);
+int bpf_raw_tracepoint_open(const char *name, int prog_fd);
#endif
--
2.9.5
next prev parent reply other threads:[~2018-03-27 2:47 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-27 2:46 [PATCH v6 bpf-next 00/11] bpf, tracing: introduce bpf raw tracepoints Alexei Starovoitov
2018-03-27 2:46 ` [PATCH v6 bpf-next 01/11] treewide: remove large struct-pass-by-value from tracepoint arguments Alexei Starovoitov
2018-03-27 2:46 ` [PATCH v6 bpf-next 02/11] net/mediatek: disambiguate mt76 vs mt7601u trace events Alexei Starovoitov
2018-03-27 2:46 ` [PATCH v6 bpf-next 03/11] net/mac802154: disambiguate mac80215 vs mac802154 " Alexei Starovoitov
2018-03-27 2:46 ` [PATCH v6 bpf-next 04/11] net/wireless/iwlwifi: fix iwlwifi_dev_ucode_error tracepoint Alexei Starovoitov
2018-03-27 2:47 ` [PATCH v6 bpf-next 05/11] macro: introduce COUNT_ARGS() macro Alexei Starovoitov
2018-03-27 2:47 ` [PATCH v6 bpf-next 06/11] tracepoint: compute num_args at build time Alexei Starovoitov
2018-03-27 15:15 ` Steven Rostedt
2018-03-27 2:47 ` [PATCH v6 bpf-next 07/11] tracepoint: introduce kernel_tracepoint_find_by_name Alexei Starovoitov
2018-03-27 14:07 ` Steven Rostedt
2018-03-27 14:18 ` Mathieu Desnoyers
2018-03-27 14:42 ` Steven Rostedt
2018-03-27 15:53 ` Alexei Starovoitov
2018-03-27 16:09 ` Mathieu Desnoyers
2018-03-27 16:36 ` Daniel Borkmann
2018-03-27 2:47 ` [PATCH v6 bpf-next 08/11] bpf: introduce BPF_RAW_TRACEPOINT Alexei Starovoitov
2018-03-27 17:02 ` Steven Rostedt
2018-03-27 17:11 ` Steven Rostedt
2018-03-27 18:58 ` Steven Rostedt
2018-03-27 21:04 ` Steven Rostedt
2018-03-27 22:48 ` Alexei Starovoitov
2018-03-27 23:13 ` Mathieu Desnoyers
2018-03-28 0:00 ` Alexei Starovoitov
2018-03-28 0:44 ` Mathieu Desnoyers
2018-03-28 0:51 ` Alexei Starovoitov
2018-03-28 14:06 ` Steven Rostedt
2018-03-27 18:45 ` Alexei Starovoitov
2018-03-27 19:00 ` Steven Rostedt
2018-03-27 19:07 ` Steven Rostedt
2018-03-27 19:10 ` Steven Rostedt
2018-03-27 19:10 ` Mathieu Desnoyers
2018-03-27 2:47 ` Alexei Starovoitov [this message]
2018-03-27 2:47 ` [PATCH v6 bpf-next 10/11] samples/bpf: raw tracepoint test Alexei Starovoitov
2018-03-27 2:47 ` [PATCH v6 bpf-next 11/11] selftests/bpf: test for bpf_get_stackid() from raw tracepoints Alexei Starovoitov
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=20180327024706.2064725-10-ast@fb.com \
--to=ast@fb$(echo .)com \
--cc=daniel@iogearbox$(echo .)net \
--cc=davem@davemloft$(echo .)net \
--cc=kernel-team@fb$(echo .)com \
--cc=linux-api@vger$(echo .)kernel.org \
--cc=netdev@vger$(echo .)kernel.org \
--cc=peterz@infradead$(echo .)org \
--cc=rostedt@goodmis$(echo .)org \
--cc=torvalds@linux-foundation$(echo .)org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox