|
|
6fc629 |
From 66d9bffa99738bbed50b3d5b2d87990cdb5e4a58 Mon Sep 17 00:00:00 2001
|
|
|
6fc629 |
From: Jerome Marchand <jmarchan@redhat.com>
|
|
|
6fc629 |
Date: Mon, 28 Nov 2022 12:23:59 +0100
|
|
|
6fc629 |
Subject: [PATCH] RHEL: libbpf version fixes
|
|
|
6fc629 |
|
|
|
6fc629 |
Revert "[bcc] stop using deprecated `bpf_load_program_attr`"
|
|
|
6fc629 |
Revert "backport `struct bpf_create_map_attr`"
|
|
|
6fc629 |
Revert "bcc: Replace deprecated libbpf API"
|
|
|
6fc629 |
|
|
|
6fc629 |
Revert "bcc: Replace deprecated libbpf APIs" since the libbpf version
|
|
|
6fc629 |
provided in RHEL 8 doesn't provide the new APIs.
|
|
|
6fc629 |
|
|
|
6fc629 |
Remove BPF_MAP_TYPE_BLOOM_FILTER from bps since the libbpf version in
|
|
|
6fc629 |
RHEL 8, doesn't provide bloom filter map.
|
|
|
6fc629 |
|
|
|
6fc629 |
Rename btf__load_vmlinux_btf into libbpf_find_kernel_btf. The function
|
|
|
6fc629 |
has been renamed upstream for naming consistency, but RHEL 8 libbpf
|
|
|
6fc629 |
still uses the old name.
|
|
|
6fc629 |
|
|
|
6fc629 |
Also use the older btf__get_nr_types() instead of btf__type_cnt() for
|
|
|
6fc629 |
the same reason.
|
|
|
6fc629 |
|
|
|
6fc629 |
Add definition of struct bpf_core_relo.
|
|
|
6fc629 |
---
|
|
|
6fc629 |
introspection/bps.c | 1 -
|
|
|
6fc629 |
libbpf-tools/ksnoop.c | 4 +-
|
|
|
6fc629 |
src/cc/bcc_btf.cc | 73 +++++++++++++++-
|
|
|
6fc629 |
src/cc/bpf_module.cc | 38 ++++----
|
|
|
6fc629 |
src/cc/common.cc | 4 +-
|
|
|
6fc629 |
src/cc/libbpf.c | 196 +++++++++++++++---------------------------
|
|
|
6fc629 |
src/cc/libbpf.h | 28 ++----
|
|
|
6fc629 |
7 files changed, 169 insertions(+), 175 deletions(-)
|
|
|
6fc629 |
|
|
|
6fc629 |
diff --git a/introspection/bps.c b/introspection/bps.c
|
|
|
6fc629 |
index 232b23d4..6ec02e6c 100644
|
|
|
6fc629 |
--- a/introspection/bps.c
|
|
|
6fc629 |
+++ b/introspection/bps.c
|
|
|
6fc629 |
@@ -80,7 +80,6 @@ static const char * const map_type_strings[] = {
|
|
|
6fc629 |
[BPF_MAP_TYPE_RINGBUF] = "ringbuf",
|
|
|
6fc629 |
[BPF_MAP_TYPE_INODE_STORAGE] = "inode_storage",
|
|
|
6fc629 |
[BPF_MAP_TYPE_TASK_STORAGE] = "task_storage",
|
|
|
6fc629 |
- [BPF_MAP_TYPE_BLOOM_FILTER] = "bloom_filter",
|
|
|
6fc629 |
};
|
|
|
6fc629 |
|
|
|
6fc629 |
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
|
|
|
6fc629 |
diff --git a/libbpf-tools/ksnoop.c b/libbpf-tools/ksnoop.c
|
|
|
6fc629 |
index 87fe175c..960e901b 100644
|
|
|
6fc629 |
--- a/libbpf-tools/ksnoop.c
|
|
|
6fc629 |
+++ b/libbpf-tools/ksnoop.c
|
|
|
6fc629 |
@@ -347,7 +347,7 @@ static struct btf *get_btf(const char *name)
|
|
|
6fc629 |
name && strlen(name) > 0 ? name : "vmlinux");
|
|
|
6fc629 |
|
|
|
6fc629 |
if (!vmlinux_btf) {
|
|
|
6fc629 |
- vmlinux_btf = btf__load_vmlinux_btf();
|
|
|
6fc629 |
+ vmlinux_btf = libbpf_find_kernel_btf();
|
|
|
6fc629 |
if (!vmlinux_btf) {
|
|
|
6fc629 |
err = -errno;
|
|
|
6fc629 |
p_err("No BTF, cannot determine type info: %s", strerror(-err));
|
|
|
6fc629 |
@@ -357,7 +357,7 @@ static struct btf *get_btf(const char *name)
|
|
|
6fc629 |
if (!name || strlen(name) == 0)
|
|
|
6fc629 |
return vmlinux_btf;
|
|
|
6fc629 |
|
|
|
6fc629 |
- mod_btf = btf__load_module_btf(name, vmlinux_btf);
|
|
|
6fc629 |
+ mod_btf = libbpf_find_kernel_btf(name, vmlinux_btf);
|
|
|
6fc629 |
if (!mod_btf) {
|
|
|
6fc629 |
err = -errno;
|
|
|
6fc629 |
p_err("No BTF for module '%s': %s", name, strerror(-err));
|
|
|
6fc629 |
diff --git a/src/cc/bcc_btf.cc b/src/cc/bcc_btf.cc
|
|
|
6fc629 |
index be248612..74fc902c 100644
|
|
|
6fc629 |
--- a/src/cc/bcc_btf.cc
|
|
|
6fc629 |
+++ b/src/cc/bcc_btf.cc
|
|
|
6fc629 |
@@ -170,6 +170,77 @@ static int btf_ext_setup_line_info(struct btf_ext *btf_ext)
|
|
|
6fc629 |
return btf_ext_setup_info(btf_ext, ¶m;;
|
|
|
6fc629 |
}
|
|
|
6fc629 |
|
|
|
6fc629 |
+/* bpf_core_relo_kind encodes which aspect of captured field/type/enum value
|
|
|
6fc629 |
+ * has to be adjusted by relocations.
|
|
|
6fc629 |
+ */
|
|
|
6fc629 |
+enum bpf_core_relo_kind {
|
|
|
6fc629 |
+ BPF_FIELD_BYTE_OFFSET = 0, /* field byte offset */
|
|
|
6fc629 |
+ BPF_FIELD_BYTE_SIZE = 1, /* field size in bytes */
|
|
|
6fc629 |
+ BPF_FIELD_EXISTS = 2, /* field existence in target kernel */
|
|
|
6fc629 |
+ BPF_FIELD_SIGNED = 3, /* field signedness (0 - unsigned, 1 - signed) */
|
|
|
6fc629 |
+ BPF_FIELD_LSHIFT_U64 = 4, /* bitfield-specific left bitshift */
|
|
|
6fc629 |
+ BPF_FIELD_RSHIFT_U64 = 5, /* bitfield-specific right bitshift */
|
|
|
6fc629 |
+ BPF_TYPE_ID_LOCAL = 6, /* type ID in local BPF object */
|
|
|
6fc629 |
+ BPF_TYPE_ID_TARGET = 7, /* type ID in target kernel */
|
|
|
6fc629 |
+ BPF_TYPE_EXISTS = 8, /* type existence in target kernel */
|
|
|
6fc629 |
+ BPF_TYPE_SIZE = 9, /* type size in bytes */
|
|
|
6fc629 |
+ BPF_ENUMVAL_EXISTS = 10, /* enum value existence in target kernel */
|
|
|
6fc629 |
+ BPF_ENUMVAL_VALUE = 11, /* enum value integer value */
|
|
|
6fc629 |
+};
|
|
|
6fc629 |
+
|
|
|
6fc629 |
+/* The minimum bpf_core_relo checked by the loader
|
|
|
6fc629 |
+ *
|
|
|
6fc629 |
+ * CO-RE relocation captures the following data:
|
|
|
6fc629 |
+ * - insn_off - instruction offset (in bytes) within a BPF program that needs
|
|
|
6fc629 |
+ * its insn->imm field to be relocated with actual field info;
|
|
|
6fc629 |
+ * - type_id - BTF type ID of the "root" (containing) entity of a relocatable
|
|
|
6fc629 |
+ * type or field;
|
|
|
6fc629 |
+ * - access_str_off - offset into corresponding .BTF string section. String
|
|
|
6fc629 |
+ * interpretation depends on specific relocation kind:
|
|
|
6fc629 |
+ * - for field-based relocations, string encodes an accessed field using
|
|
|
6fc629 |
+ * a sequence of field and array indices, separated by colon (:). It's
|
|
|
6fc629 |
+ * conceptually very close to LLVM's getelementptr ([0]) instruction's
|
|
|
6fc629 |
+ * arguments for identifying offset to a field.
|
|
|
6fc629 |
+ * - for type-based relocations, strings is expected to be just "0";
|
|
|
6fc629 |
+ * - for enum value-based relocations, string contains an index of enum
|
|
|
6fc629 |
+ * value within its enum type;
|
|
|
6fc629 |
+ *
|
|
|
6fc629 |
+ * Example to provide a better feel.
|
|
|
6fc629 |
+ *
|
|
|
6fc629 |
+ * struct sample {
|
|
|
6fc629 |
+ * int a;
|
|
|
6fc629 |
+ * struct {
|
|
|
6fc629 |
+ * int b[10];
|
|
|
6fc629 |
+ * };
|
|
|
6fc629 |
+ * };
|
|
|
6fc629 |
+ *
|
|
|
6fc629 |
+ * struct sample *s = ...;
|
|
|
6fc629 |
+ * int x = &s->a; // encoded as "0:0" (a is field #0)
|
|
|
6fc629 |
+ * int y = &s->b[5]; // encoded as "0:1:0:5" (anon struct is field #1,
|
|
|
6fc629 |
+ * // b is field #0 inside anon struct, accessing elem #5)
|
|
|
6fc629 |
+ * int z = &s[10]->b; // encoded as "10:1" (ptr is used as an array)
|
|
|
6fc629 |
+ *
|
|
|
6fc629 |
+ * type_id for all relocs in this example will capture BTF type id of
|
|
|
6fc629 |
+ * `struct sample`.
|
|
|
6fc629 |
+ *
|
|
|
6fc629 |
+ * Such relocation is emitted when using __builtin_preserve_access_index()
|
|
|
6fc629 |
+ * Clang built-in, passing expression that captures field address, e.g.:
|
|
|
6fc629 |
+ *
|
|
|
6fc629 |
+ * bpf_probe_read(&dst, sizeof(dst),
|
|
|
6fc629 |
+ * __builtin_preserve_access_index(&src->a.b.c));
|
|
|
6fc629 |
+ *
|
|
|
6fc629 |
+ * In this case Clang will emit field relocation recording necessary data to
|
|
|
6fc629 |
+ * be able to find offset of embedded `a.b.c` field within `src` struct.
|
|
|
6fc629 |
+ *
|
|
|
6fc629 |
+ * [0] https://llvm.org/docs/LangRef.html#getelementptr-instruction
|
|
|
6fc629 |
+ */
|
|
|
6fc629 |
+struct bpf_core_relo {
|
|
|
6fc629 |
+ __u32 insn_off;
|
|
|
6fc629 |
+ __u32 type_id;
|
|
|
6fc629 |
+ __u32 access_str_off;
|
|
|
6fc629 |
+ enum bpf_core_relo_kind kind;
|
|
|
6fc629 |
+};
|
|
|
6fc629 |
+
|
|
|
6fc629 |
static int btf_ext_setup_core_relos(struct btf_ext *btf_ext)
|
|
|
6fc629 |
{
|
|
|
6fc629 |
struct btf_ext_sec_setup_param param = {
|
|
|
6fc629 |
@@ -597,7 +668,7 @@ int BTF::load(uint8_t *btf_sec, uintptr_t btf_sec_size,
|
|
|
6fc629 |
return -1;
|
|
|
6fc629 |
}
|
|
|
6fc629 |
|
|
|
6fc629 |
- if (btf__load_into_kernel(btf)) {
|
|
|
6fc629 |
+ if (btf__load(btf)) {
|
|
|
6fc629 |
btf__free(btf);
|
|
|
6fc629 |
warning("Loading .BTF section failed\n");
|
|
|
6fc629 |
return -1;
|
|
|
6fc629 |
diff --git a/src/cc/bpf_module.cc b/src/cc/bpf_module.cc
|
|
|
6fc629 |
index 86f6a228..490fffe8 100644
|
|
|
6fc629 |
--- a/src/cc/bpf_module.cc
|
|
|
6fc629 |
+++ b/src/cc/bpf_module.cc
|
|
|
6fc629 |
@@ -407,7 +407,7 @@ int BPFModule::create_maps(std::map<std::string, std::pair<int, int>> &map_tids,
|
|
|
6fc629 |
}
|
|
|
6fc629 |
|
|
|
6fc629 |
if (pinned_id <= 0) {
|
|
|
6fc629 |
- struct bcc_create_map_attr attr = {};
|
|
|
6fc629 |
+ struct bpf_create_map_attr attr = {};
|
|
|
6fc629 |
attr.map_type = (enum bpf_map_type)map_type;
|
|
|
6fc629 |
attr.name = map_name;
|
|
|
6fc629 |
attr.key_size = key_size;
|
|
|
6fc629 |
@@ -982,22 +982,26 @@ int BPFModule::bcc_func_load(int prog_type, const char *name,
|
|
|
6fc629 |
const char *license, unsigned kern_version,
|
|
|
6fc629 |
int log_level, char *log_buf, unsigned log_buf_size,
|
|
|
6fc629 |
const char *dev_name, unsigned flags, int expected_attach_type) {
|
|
|
6fc629 |
- struct bpf_prog_load_opts opts = {};
|
|
|
6fc629 |
+ struct bpf_load_program_attr attr = {};
|
|
|
6fc629 |
unsigned func_info_cnt, line_info_cnt, finfo_rec_size, linfo_rec_size;
|
|
|
6fc629 |
void *func_info = NULL, *line_info = NULL;
|
|
|
6fc629 |
int ret;
|
|
|
6fc629 |
|
|
|
6fc629 |
+ attr.prog_type = (enum bpf_prog_type)prog_type;
|
|
|
6fc629 |
if (expected_attach_type != -1) {
|
|
|
6fc629 |
- opts.expected_attach_type = (enum bpf_attach_type)expected_attach_type;
|
|
|
6fc629 |
+ attr.expected_attach_type = (enum bpf_attach_type)expected_attach_type;
|
|
|
6fc629 |
}
|
|
|
6fc629 |
- if (prog_type != BPF_PROG_TYPE_TRACING &&
|
|
|
6fc629 |
- prog_type != BPF_PROG_TYPE_EXT) {
|
|
|
6fc629 |
- opts.kern_version = kern_version;
|
|
|
6fc629 |
+ attr.name = name;
|
|
|
6fc629 |
+ attr.insns = insns;
|
|
|
6fc629 |
+ attr.license = license;
|
|
|
6fc629 |
+ if (attr.prog_type != BPF_PROG_TYPE_TRACING &&
|
|
|
6fc629 |
+ attr.prog_type != BPF_PROG_TYPE_EXT) {
|
|
|
6fc629 |
+ attr.kern_version = kern_version;
|
|
|
6fc629 |
}
|
|
|
6fc629 |
- opts.prog_flags = flags;
|
|
|
6fc629 |
- opts.log_level = log_level;
|
|
|
6fc629 |
+ attr.prog_flags = flags;
|
|
|
6fc629 |
+ attr.log_level = log_level;
|
|
|
6fc629 |
if (dev_name)
|
|
|
6fc629 |
- opts.prog_ifindex = if_nametoindex(dev_name);
|
|
|
6fc629 |
+ attr.prog_ifindex = if_nametoindex(dev_name);
|
|
|
6fc629 |
|
|
|
6fc629 |
if (btf_) {
|
|
|
6fc629 |
int btf_fd = btf_->get_fd();
|
|
|
6fc629 |
@@ -1008,17 +1012,17 @@ int BPFModule::bcc_func_load(int prog_type, const char *name,
|
|
|
6fc629 |
&finfo_rec_size, &line_info,
|
|
|
6fc629 |
&line_info_cnt, &linfo_rec_size);
|
|
|
6fc629 |
if (!ret) {
|
|
|
6fc629 |
- opts.prog_btf_fd = btf_fd;
|
|
|
6fc629 |
- opts.func_info = func_info;
|
|
|
6fc629 |
- opts.func_info_cnt = func_info_cnt;
|
|
|
6fc629 |
- opts.func_info_rec_size = finfo_rec_size;
|
|
|
6fc629 |
- opts.line_info = line_info;
|
|
|
6fc629 |
- opts.line_info_cnt = line_info_cnt;
|
|
|
6fc629 |
- opts.line_info_rec_size = linfo_rec_size;
|
|
|
6fc629 |
+ attr.prog_btf_fd = btf_fd;
|
|
|
6fc629 |
+ attr.func_info = func_info;
|
|
|
6fc629 |
+ attr.func_info_cnt = func_info_cnt;
|
|
|
6fc629 |
+ attr.func_info_rec_size = finfo_rec_size;
|
|
|
6fc629 |
+ attr.line_info = line_info;
|
|
|
6fc629 |
+ attr.line_info_cnt = line_info_cnt;
|
|
|
6fc629 |
+ attr.line_info_rec_size = linfo_rec_size;
|
|
|
6fc629 |
}
|
|
|
6fc629 |
}
|
|
|
6fc629 |
|
|
|
6fc629 |
- ret = bcc_prog_load_xattr((enum bpf_prog_type)prog_type, name, license, insns, &opts, prog_len, log_buf, log_buf_size, allow_rlimit_);
|
|
|
6fc629 |
+ ret = bcc_prog_load_xattr(&attr, prog_len, log_buf, log_buf_size, allow_rlimit_);
|
|
|
6fc629 |
if (btf_) {
|
|
|
6fc629 |
free(func_info);
|
|
|
6fc629 |
free(line_info);
|
|
|
6fc629 |
diff --git a/src/cc/common.cc b/src/cc/common.cc
|
|
|
6fc629 |
index 3143adb0..11970275 100644
|
|
|
6fc629 |
--- a/src/cc/common.cc
|
|
|
6fc629 |
+++ b/src/cc/common.cc
|
|
|
6fc629 |
@@ -34,11 +34,11 @@ using std::experimental::optional;
|
|
|
6fc629 |
static optional<int32_t> get_enum_val_from_btf(const char *name) {
|
|
|
6fc629 |
optional<int32_t> val;
|
|
|
6fc629 |
|
|
|
6fc629 |
- auto btf = btf__load_vmlinux_btf();
|
|
|
6fc629 |
+ auto btf = libbpf_find_kernel_btf();
|
|
|
6fc629 |
if (libbpf_get_error(btf))
|
|
|
6fc629 |
return {};
|
|
|
6fc629 |
|
|
|
6fc629 |
- for (size_t i = 1; i < btf__type_cnt(btf); i++) {
|
|
|
6fc629 |
+ for (size_t i = 1; i <= btf__get_nr_types(btf); i++) {
|
|
|
6fc629 |
auto t = btf__type_by_id(btf, i);
|
|
|
6fc629 |
if (btf_kind(t) != BTF_KIND_ENUM)
|
|
|
6fc629 |
continue;
|
|
|
6fc629 |
diff --git a/src/cc/libbpf.c b/src/cc/libbpf.c
|
|
|
6fc629 |
index 0c09f9b3..7042c792 100644
|
|
|
6fc629 |
--- a/src/cc/libbpf.c
|
|
|
6fc629 |
+++ b/src/cc/libbpf.c
|
|
|
6fc629 |
@@ -319,33 +319,14 @@ static uint64_t ptr_to_u64(void *ptr)
|
|
|
6fc629 |
return (uint64_t) (unsigned long) ptr;
|
|
|
6fc629 |
}
|
|
|
6fc629 |
|
|
|
6fc629 |
-static int libbpf_bpf_map_create(struct bcc_create_map_attr *create_attr)
|
|
|
6fc629 |
-{
|
|
|
6fc629 |
- LIBBPF_OPTS(bpf_map_create_opts, p);
|
|
|
6fc629 |
-
|
|
|
6fc629 |
- p.map_flags = create_attr->map_flags;
|
|
|
6fc629 |
- p.numa_node = create_attr->numa_node;
|
|
|
6fc629 |
- p.btf_fd = create_attr->btf_fd;
|
|
|
6fc629 |
- p.btf_key_type_id = create_attr->btf_key_type_id;
|
|
|
6fc629 |
- p.btf_value_type_id = create_attr->btf_value_type_id;
|
|
|
6fc629 |
- p.map_ifindex = create_attr->map_ifindex;
|
|
|
6fc629 |
- if (create_attr->map_type == BPF_MAP_TYPE_STRUCT_OPS)
|
|
|
6fc629 |
- p.btf_vmlinux_value_type_id = create_attr->btf_vmlinux_value_type_id;
|
|
|
6fc629 |
- else
|
|
|
6fc629 |
- p.inner_map_fd = create_attr->inner_map_fd;
|
|
|
6fc629 |
-
|
|
|
6fc629 |
- return bpf_map_create(create_attr->map_type, create_attr->name, create_attr->key_size,
|
|
|
6fc629 |
- create_attr->value_size, create_attr->max_entries, &p);
|
|
|
6fc629 |
-}
|
|
|
6fc629 |
-
|
|
|
6fc629 |
-int bcc_create_map_xattr(struct bcc_create_map_attr *attr, bool allow_rlimit)
|
|
|
6fc629 |
+int bcc_create_map_xattr(struct bpf_create_map_attr *attr, bool allow_rlimit)
|
|
|
6fc629 |
{
|
|
|
6fc629 |
unsigned name_len = attr->name ? strlen(attr->name) : 0;
|
|
|
6fc629 |
char map_name[BPF_OBJ_NAME_LEN] = {};
|
|
|
6fc629 |
|
|
|
6fc629 |
memcpy(map_name, attr->name, min(name_len, BPF_OBJ_NAME_LEN - 1));
|
|
|
6fc629 |
attr->name = map_name;
|
|
|
6fc629 |
- int ret = libbpf_bpf_map_create(attr);
|
|
|
6fc629 |
+ int ret = bpf_create_map_xattr(attr);
|
|
|
6fc629 |
|
|
|
6fc629 |
if (ret < 0 && errno == EPERM) {
|
|
|
6fc629 |
if (!allow_rlimit)
|
|
|
6fc629 |
@@ -357,7 +338,7 @@ int bcc_create_map_xattr(struct bcc_create_map_attr *attr, bool allow_rlimit)
|
|
|
6fc629 |
rl.rlim_max = RLIM_INFINITY;
|
|
|
6fc629 |
rl.rlim_cur = rl.rlim_max;
|
|
|
6fc629 |
if (setrlimit(RLIMIT_MEMLOCK, &rl) == 0)
|
|
|
6fc629 |
- ret = libbpf_bpf_map_create(attr);
|
|
|
6fc629 |
+ ret = bpf_create_map_xattr(attr);
|
|
|
6fc629 |
}
|
|
|
6fc629 |
}
|
|
|
6fc629 |
|
|
|
6fc629 |
@@ -367,12 +348,12 @@ int bcc_create_map_xattr(struct bcc_create_map_attr *attr, bool allow_rlimit)
|
|
|
6fc629 |
attr->btf_fd = 0;
|
|
|
6fc629 |
attr->btf_key_type_id = 0;
|
|
|
6fc629 |
attr->btf_value_type_id = 0;
|
|
|
6fc629 |
- ret = libbpf_bpf_map_create(attr);
|
|
|
6fc629 |
+ ret = bpf_create_map_xattr(attr);
|
|
|
6fc629 |
}
|
|
|
6fc629 |
|
|
|
6fc629 |
if (ret < 0 && name_len && (errno == E2BIG || errno == EINVAL)) {
|
|
|
6fc629 |
map_name[0] = '\0';
|
|
|
6fc629 |
- ret = libbpf_bpf_map_create(attr);
|
|
|
6fc629 |
+ ret = bpf_create_map_xattr(attr);
|
|
|
6fc629 |
}
|
|
|
6fc629 |
|
|
|
6fc629 |
if (ret < 0 && errno == EPERM) {
|
|
|
6fc629 |
@@ -385,7 +366,7 @@ int bcc_create_map_xattr(struct bcc_create_map_attr *attr, bool allow_rlimit)
|
|
|
6fc629 |
rl.rlim_max = RLIM_INFINITY;
|
|
|
6fc629 |
rl.rlim_cur = rl.rlim_max;
|
|
|
6fc629 |
if (setrlimit(RLIMIT_MEMLOCK, &rl) == 0)
|
|
|
6fc629 |
- ret = libbpf_bpf_map_create(attr);
|
|
|
6fc629 |
+ ret = bpf_create_map_xattr(attr);
|
|
|
6fc629 |
}
|
|
|
6fc629 |
}
|
|
|
6fc629 |
return ret;
|
|
|
6fc629 |
@@ -395,7 +376,7 @@ int bcc_create_map(enum bpf_map_type map_type, const char *name,
|
|
|
6fc629 |
int key_size, int value_size,
|
|
|
6fc629 |
int max_entries, int map_flags)
|
|
|
6fc629 |
{
|
|
|
6fc629 |
- struct bcc_create_map_attr attr = {};
|
|
|
6fc629 |
+ struct bpf_create_map_attr attr = {};
|
|
|
6fc629 |
|
|
|
6fc629 |
attr.map_type = map_type;
|
|
|
6fc629 |
attr.name = name;
|
|
|
6fc629 |
@@ -644,70 +625,24 @@ int bpf_prog_get_tag(int fd, unsigned long long *ptag)
|
|
|
6fc629 |
return -2;
|
|
|
6fc629 |
}
|
|
|
6fc629 |
|
|
|
6fc629 |
-static int libbpf_bpf_prog_load(enum bpf_prog_type prog_type,
|
|
|
6fc629 |
- const char *prog_name, const char *license,
|
|
|
6fc629 |
- const struct bpf_insn *insns, size_t insn_cnt,
|
|
|
6fc629 |
- struct bpf_prog_load_opts *opts,
|
|
|
6fc629 |
- char *log_buf, size_t log_buf_sz)
|
|
|
6fc629 |
-{
|
|
|
6fc629 |
-
|
|
|
6fc629 |
- LIBBPF_OPTS(bpf_prog_load_opts, p);
|
|
|
6fc629 |
-
|
|
|
6fc629 |
- if (!opts || !log_buf != !log_buf_sz) {
|
|
|
6fc629 |
- errno = EINVAL;
|
|
|
6fc629 |
- return -EINVAL;
|
|
|
6fc629 |
- }
|
|
|
6fc629 |
-
|
|
|
6fc629 |
- p.expected_attach_type = opts->expected_attach_type;
|
|
|
6fc629 |
- switch (prog_type) {
|
|
|
6fc629 |
- case BPF_PROG_TYPE_STRUCT_OPS:
|
|
|
6fc629 |
- case BPF_PROG_TYPE_LSM:
|
|
|
6fc629 |
- p.attach_btf_id = opts->attach_btf_id;
|
|
|
6fc629 |
- break;
|
|
|
6fc629 |
- case BPF_PROG_TYPE_TRACING:
|
|
|
6fc629 |
- case BPF_PROG_TYPE_EXT:
|
|
|
6fc629 |
- p.attach_btf_id = opts->attach_btf_id;
|
|
|
6fc629 |
- p.attach_prog_fd = opts->attach_prog_fd;
|
|
|
6fc629 |
- break;
|
|
|
6fc629 |
- default:
|
|
|
6fc629 |
- p.prog_ifindex = opts->prog_ifindex;
|
|
|
6fc629 |
- p.kern_version = opts->kern_version;
|
|
|
6fc629 |
- }
|
|
|
6fc629 |
- p.log_level = opts->log_level;
|
|
|
6fc629 |
- p.log_buf = log_buf;
|
|
|
6fc629 |
- p.log_size = log_buf_sz;
|
|
|
6fc629 |
- p.prog_btf_fd = opts->prog_btf_fd;
|
|
|
6fc629 |
- p.func_info_rec_size = opts->func_info_rec_size;
|
|
|
6fc629 |
- p.func_info_cnt = opts->func_info_cnt;
|
|
|
6fc629 |
- p.func_info = opts->func_info;
|
|
|
6fc629 |
- p.line_info_rec_size = opts->line_info_rec_size;
|
|
|
6fc629 |
- p.line_info_cnt = opts->line_info_cnt;
|
|
|
6fc629 |
- p.line_info = opts->line_info;
|
|
|
6fc629 |
- p.prog_flags = opts->prog_flags;
|
|
|
6fc629 |
-
|
|
|
6fc629 |
- return bpf_prog_load(prog_type, prog_name, license,
|
|
|
6fc629 |
- insns, insn_cnt, &p);
|
|
|
6fc629 |
-}
|
|
|
6fc629 |
-
|
|
|
6fc629 |
-int bcc_prog_load_xattr(enum bpf_prog_type prog_type, const char *prog_name,
|
|
|
6fc629 |
- const char *license, const struct bpf_insn *insns,
|
|
|
6fc629 |
- struct bpf_prog_load_opts *opts, int prog_len,
|
|
|
6fc629 |
+int bcc_prog_load_xattr(struct bpf_load_program_attr *attr, int prog_len,
|
|
|
6fc629 |
char *log_buf, unsigned log_buf_size, bool allow_rlimit)
|
|
|
6fc629 |
{
|
|
|
6fc629 |
- unsigned name_len = prog_name ? strlen(prog_name) : 0;
|
|
|
6fc629 |
- char *tmp_log_buf = NULL, *opts_log_buf = NULL;
|
|
|
6fc629 |
- unsigned tmp_log_buf_size = 0, opts_log_buf_size = 0;
|
|
|
6fc629 |
+ unsigned name_len = attr->name ? strlen(attr->name) : 0;
|
|
|
6fc629 |
+ char *tmp_log_buf = NULL, *attr_log_buf = NULL;
|
|
|
6fc629 |
+ unsigned tmp_log_buf_size = 0, attr_log_buf_size = 0;
|
|
|
6fc629 |
int ret = 0, name_offset = 0, expected_attach_type = 0;
|
|
|
6fc629 |
- char new_prog_name[BPF_OBJ_NAME_LEN] = {};
|
|
|
6fc629 |
+ char prog_name[BPF_OBJ_NAME_LEN] = {};
|
|
|
6fc629 |
|
|
|
6fc629 |
unsigned insns_cnt = prog_len / sizeof(struct bpf_insn);
|
|
|
6fc629 |
+ attr->insns_cnt = insns_cnt;
|
|
|
6fc629 |
|
|
|
6fc629 |
- if (opts->log_level > 0) {
|
|
|
6fc629 |
+ if (attr->log_level > 0) {
|
|
|
6fc629 |
if (log_buf_size > 0) {
|
|
|
6fc629 |
// Use user-provided log buffer if available.
|
|
|
6fc629 |
log_buf[0] = 0;
|
|
|
6fc629 |
- opts_log_buf = log_buf;
|
|
|
6fc629 |
- opts_log_buf_size = log_buf_size;
|
|
|
6fc629 |
+ attr_log_buf = log_buf;
|
|
|
6fc629 |
+ attr_log_buf_size = log_buf_size;
|
|
|
6fc629 |
} else {
|
|
|
6fc629 |
// Create and use temporary log buffer if user didn't provide one.
|
|
|
6fc629 |
tmp_log_buf_size = LOG_BUF_SIZE;
|
|
|
6fc629 |
@@ -715,82 +650,82 @@ int bcc_prog_load_xattr(enum bpf_prog_type prog_type, const char *prog_name,
|
|
|
6fc629 |
if (!tmp_log_buf) {
|
|
|
6fc629 |
fprintf(stderr, "bpf: Failed to allocate temporary log buffer: %s\n\n",
|
|
|
6fc629 |
strerror(errno));
|
|
|
6fc629 |
- opts->log_level = 0;
|
|
|
6fc629 |
+ attr->log_level = 0;
|
|
|
6fc629 |
} else {
|
|
|
6fc629 |
tmp_log_buf[0] = 0;
|
|
|
6fc629 |
- opts_log_buf = tmp_log_buf;
|
|
|
6fc629 |
- opts_log_buf_size = tmp_log_buf_size;
|
|
|
6fc629 |
+ attr_log_buf = tmp_log_buf;
|
|
|
6fc629 |
+ attr_log_buf_size = tmp_log_buf_size;
|
|
|
6fc629 |
}
|
|
|
6fc629 |
}
|
|
|
6fc629 |
}
|
|
|
6fc629 |
|
|
|
6fc629 |
-
|
|
|
6fc629 |
if (name_len) {
|
|
|
6fc629 |
- if (strncmp(prog_name, "kprobe__", 8) == 0)
|
|
|
6fc629 |
+ if (strncmp(attr->name, "kprobe__", 8) == 0)
|
|
|
6fc629 |
name_offset = 8;
|
|
|
6fc629 |
- else if (strncmp(prog_name, "kretprobe__", 11) == 0)
|
|
|
6fc629 |
+ else if (strncmp(attr->name, "kretprobe__", 11) == 0)
|
|
|
6fc629 |
name_offset = 11;
|
|
|
6fc629 |
- else if (strncmp(prog_name, "tracepoint__", 12) == 0)
|
|
|
6fc629 |
+ else if (strncmp(attr->name, "tracepoint__", 12) == 0)
|
|
|
6fc629 |
name_offset = 12;
|
|
|
6fc629 |
- else if (strncmp(prog_name, "raw_tracepoint__", 16) == 0)
|
|
|
6fc629 |
+ else if (strncmp(attr->name, "raw_tracepoint__", 16) == 0)
|
|
|
6fc629 |
name_offset = 16;
|
|
|
6fc629 |
- else if (strncmp(prog_name, "kfunc__", 7) == 0) {
|
|
|
6fc629 |
+ else if (strncmp(attr->name, "kfunc__", 7) == 0) {
|
|
|
6fc629 |
name_offset = 7;
|
|
|
6fc629 |
expected_attach_type = BPF_TRACE_FENTRY;
|
|
|
6fc629 |
- } else if (strncmp(prog_name, "kmod_ret__", 10) == 0) {
|
|
|
6fc629 |
+ } else if (strncmp(attr->name, "kmod_ret__", 10) == 0) {
|
|
|
6fc629 |
name_offset = 10;
|
|
|
6fc629 |
expected_attach_type = BPF_MODIFY_RETURN;
|
|
|
6fc629 |
- } else if (strncmp(prog_name, "kretfunc__", 10) == 0) {
|
|
|
6fc629 |
+ } else if (strncmp(attr->name, "kretfunc__", 10) == 0) {
|
|
|
6fc629 |
name_offset = 10;
|
|
|
6fc629 |
expected_attach_type = BPF_TRACE_FEXIT;
|
|
|
6fc629 |
- } else if (strncmp(prog_name, "lsm__", 5) == 0) {
|
|
|
6fc629 |
+ } else if (strncmp(attr->name, "lsm__", 5) == 0) {
|
|
|
6fc629 |
name_offset = 5;
|
|
|
6fc629 |
expected_attach_type = BPF_LSM_MAC;
|
|
|
6fc629 |
- } else if (strncmp(prog_name, "bpf_iter__", 10) == 0) {
|
|
|
6fc629 |
+ } else if (strncmp(attr->name, "bpf_iter__", 10) == 0) {
|
|
|
6fc629 |
name_offset = 10;
|
|
|
6fc629 |
expected_attach_type = BPF_TRACE_ITER;
|
|
|
6fc629 |
}
|
|
|
6fc629 |
|
|
|
6fc629 |
- if (prog_type == BPF_PROG_TYPE_TRACING ||
|
|
|
6fc629 |
- prog_type == BPF_PROG_TYPE_LSM) {
|
|
|
6fc629 |
- ret = libbpf_find_vmlinux_btf_id(prog_name + name_offset,
|
|
|
6fc629 |
+ if (attr->prog_type == BPF_PROG_TYPE_TRACING ||
|
|
|
6fc629 |
+ attr->prog_type == BPF_PROG_TYPE_LSM) {
|
|
|
6fc629 |
+ ret = libbpf_find_vmlinux_btf_id(attr->name + name_offset,
|
|
|
6fc629 |
expected_attach_type);
|
|
|
6fc629 |
if (ret == -EINVAL) {
|
|
|
6fc629 |
fprintf(stderr, "bpf: vmlinux BTF is not found\n");
|
|
|
6fc629 |
return ret;
|
|
|
6fc629 |
} else if (ret < 0) {
|
|
|
6fc629 |
fprintf(stderr, "bpf: %s is not found in vmlinux BTF\n",
|
|
|
6fc629 |
- prog_name + name_offset);
|
|
|
6fc629 |
+ attr->name + name_offset);
|
|
|
6fc629 |
return ret;
|
|
|
6fc629 |
}
|
|
|
6fc629 |
|
|
|
6fc629 |
- opts->attach_btf_id = ret;
|
|
|
6fc629 |
- opts->expected_attach_type = expected_attach_type;
|
|
|
6fc629 |
+ attr->attach_btf_id = ret;
|
|
|
6fc629 |
+ attr->expected_attach_type = expected_attach_type;
|
|
|
6fc629 |
}
|
|
|
6fc629 |
|
|
|
6fc629 |
- memcpy(new_prog_name, prog_name + name_offset,
|
|
|
6fc629 |
+ memcpy(prog_name, attr->name + name_offset,
|
|
|
6fc629 |
min(name_len - name_offset, BPF_OBJ_NAME_LEN - 1));
|
|
|
6fc629 |
+ attr->name = prog_name;
|
|
|
6fc629 |
}
|
|
|
6fc629 |
|
|
|
6fc629 |
- ret = libbpf_bpf_prog_load(prog_type, new_prog_name, license, insns, insns_cnt, opts, opts_log_buf, opts_log_buf_size);
|
|
|
6fc629 |
+ ret = bpf_load_program_xattr(attr, attr_log_buf, attr_log_buf_size);
|
|
|
6fc629 |
|
|
|
6fc629 |
// func_info/line_info may not be supported in old kernels.
|
|
|
6fc629 |
- if (ret < 0 && opts->func_info && errno == EINVAL) {
|
|
|
6fc629 |
- opts->prog_btf_fd = 0;
|
|
|
6fc629 |
- opts->func_info = NULL;
|
|
|
6fc629 |
- opts->func_info_cnt = 0;
|
|
|
6fc629 |
- opts->func_info_rec_size = 0;
|
|
|
6fc629 |
- opts->line_info = NULL;
|
|
|
6fc629 |
- opts->line_info_cnt = 0;
|
|
|
6fc629 |
- opts->line_info_rec_size = 0;
|
|
|
6fc629 |
- ret = libbpf_bpf_prog_load(prog_type, new_prog_name, license, insns, insns_cnt, opts, opts_log_buf, opts_log_buf_size);
|
|
|
6fc629 |
+ if (ret < 0 && attr->func_info && errno == EINVAL) {
|
|
|
6fc629 |
+ attr->prog_btf_fd = 0;
|
|
|
6fc629 |
+ attr->func_info = NULL;
|
|
|
6fc629 |
+ attr->func_info_cnt = 0;
|
|
|
6fc629 |
+ attr->func_info_rec_size = 0;
|
|
|
6fc629 |
+ attr->line_info = NULL;
|
|
|
6fc629 |
+ attr->line_info_cnt = 0;
|
|
|
6fc629 |
+ attr->line_info_rec_size = 0;
|
|
|
6fc629 |
+ ret = bpf_load_program_xattr(attr, attr_log_buf, attr_log_buf_size);
|
|
|
6fc629 |
}
|
|
|
6fc629 |
|
|
|
6fc629 |
// BPF object name is not supported on older Kernels.
|
|
|
6fc629 |
// If we failed due to this, clear the name and try again.
|
|
|
6fc629 |
if (ret < 0 && name_len && (errno == E2BIG || errno == EINVAL)) {
|
|
|
6fc629 |
- new_prog_name[0] = '\0';
|
|
|
6fc629 |
- ret = libbpf_bpf_prog_load(prog_type, new_prog_name, license, insns, insns_cnt, opts, opts_log_buf, opts_log_buf_size);
|
|
|
6fc629 |
+ prog_name[0] = '\0';
|
|
|
6fc629 |
+ ret = bpf_load_program_xattr(attr, attr_log_buf, attr_log_buf_size);
|
|
|
6fc629 |
}
|
|
|
6fc629 |
|
|
|
6fc629 |
if (ret < 0 && errno == EPERM) {
|
|
|
6fc629 |
@@ -809,14 +744,14 @@ int bcc_prog_load_xattr(enum bpf_prog_type prog_type, const char *prog_name,
|
|
|
6fc629 |
rl.rlim_max = RLIM_INFINITY;
|
|
|
6fc629 |
rl.rlim_cur = rl.rlim_max;
|
|
|
6fc629 |
if (setrlimit(RLIMIT_MEMLOCK, &rl) == 0)
|
|
|
6fc629 |
- ret = libbpf_bpf_prog_load(prog_type, new_prog_name, license, insns, insns_cnt, opts, opts_log_buf, opts_log_buf_size);
|
|
|
6fc629 |
+ ret = bpf_load_program_xattr(attr, attr_log_buf, attr_log_buf_size);
|
|
|
6fc629 |
}
|
|
|
6fc629 |
}
|
|
|
6fc629 |
|
|
|
6fc629 |
if (ret < 0 && errno == E2BIG) {
|
|
|
6fc629 |
fprintf(stderr,
|
|
|
6fc629 |
"bpf: %s. Program %s too large (%u insns), at most %d insns\n\n",
|
|
|
6fc629 |
- strerror(errno), new_prog_name, insns_cnt, BPF_MAXINSNS);
|
|
|
6fc629 |
+ strerror(errno), attr->name, insns_cnt, BPF_MAXINSNS);
|
|
|
6fc629 |
return -1;
|
|
|
6fc629 |
}
|
|
|
6fc629 |
|
|
|
6fc629 |
@@ -825,9 +760,9 @@ int bcc_prog_load_xattr(enum bpf_prog_type prog_type, const char *prog_name,
|
|
|
6fc629 |
// User has provided a log buffer.
|
|
|
6fc629 |
if (log_buf_size) {
|
|
|
6fc629 |
// If logging is not already enabled, enable it and do the syscall again.
|
|
|
6fc629 |
- if (opts->log_level == 0) {
|
|
|
6fc629 |
- opts->log_level = 1;
|
|
|
6fc629 |
- ret = libbpf_bpf_prog_load(prog_type, new_prog_name, license, insns, insns_cnt, opts, log_buf, log_buf_size);
|
|
|
6fc629 |
+ if (attr->log_level == 0) {
|
|
|
6fc629 |
+ attr->log_level = 1;
|
|
|
6fc629 |
+ ret = bpf_load_program_xattr(attr, log_buf, log_buf_size);
|
|
|
6fc629 |
}
|
|
|
6fc629 |
// Print the log message and return.
|
|
|
6fc629 |
bpf_print_hints(ret, log_buf);
|
|
|
6fc629 |
@@ -841,8 +776,8 @@ int bcc_prog_load_xattr(enum bpf_prog_type prog_type, const char *prog_name,
|
|
|
6fc629 |
if (tmp_log_buf)
|
|
|
6fc629 |
free(tmp_log_buf);
|
|
|
6fc629 |
tmp_log_buf_size = LOG_BUF_SIZE;
|
|
|
6fc629 |
- if (opts->log_level == 0)
|
|
|
6fc629 |
- opts->log_level = 1;
|
|
|
6fc629 |
+ if (attr->log_level == 0)
|
|
|
6fc629 |
+ attr->log_level = 1;
|
|
|
6fc629 |
for (;;) {
|
|
|
6fc629 |
tmp_log_buf = malloc(tmp_log_buf_size);
|
|
|
6fc629 |
if (!tmp_log_buf) {
|
|
|
6fc629 |
@@ -851,7 +786,7 @@ int bcc_prog_load_xattr(enum bpf_prog_type prog_type, const char *prog_name,
|
|
|
6fc629 |
goto return_result;
|
|
|
6fc629 |
}
|
|
|
6fc629 |
tmp_log_buf[0] = 0;
|
|
|
6fc629 |
- ret = libbpf_bpf_prog_load(prog_type, new_prog_name, license, insns, insns_cnt, opts, tmp_log_buf, tmp_log_buf_size);
|
|
|
6fc629 |
+ ret = bpf_load_program_xattr(attr, tmp_log_buf, tmp_log_buf_size);
|
|
|
6fc629 |
if (ret < 0 && errno == ENOSPC) {
|
|
|
6fc629 |
// Temporary buffer size is not enough. Double it and try again.
|
|
|
6fc629 |
free(tmp_log_buf);
|
|
|
6fc629 |
@@ -865,7 +800,7 @@ int bcc_prog_load_xattr(enum bpf_prog_type prog_type, const char *prog_name,
|
|
|
6fc629 |
|
|
|
6fc629 |
// Check if we should print the log message if log_level is not 0,
|
|
|
6fc629 |
// either specified by user or set due to error.
|
|
|
6fc629 |
- if (opts->log_level > 0) {
|
|
|
6fc629 |
+ if (attr->log_level > 0) {
|
|
|
6fc629 |
// Don't print if user enabled logging and provided log buffer,
|
|
|
6fc629 |
// but there is no error.
|
|
|
6fc629 |
if (log_buf && ret < 0)
|
|
|
6fc629 |
@@ -885,13 +820,16 @@ int bcc_prog_load(enum bpf_prog_type prog_type, const char *name,
|
|
|
6fc629 |
const char *license, unsigned kern_version,
|
|
|
6fc629 |
int log_level, char *log_buf, unsigned log_buf_size)
|
|
|
6fc629 |
{
|
|
|
6fc629 |
- struct bpf_prog_load_opts opts = {};
|
|
|
6fc629 |
-
|
|
|
6fc629 |
+ struct bpf_load_program_attr attr = {};
|
|
|
6fc629 |
|
|
|
6fc629 |
+ attr.prog_type = prog_type;
|
|
|
6fc629 |
+ attr.name = name;
|
|
|
6fc629 |
+ attr.insns = insns;
|
|
|
6fc629 |
+ attr.license = license;
|
|
|
6fc629 |
if (prog_type != BPF_PROG_TYPE_TRACING && prog_type != BPF_PROG_TYPE_EXT)
|
|
|
6fc629 |
- opts.kern_version = kern_version;
|
|
|
6fc629 |
- opts.log_level = log_level;
|
|
|
6fc629 |
- return bcc_prog_load_xattr(prog_type, name, license, insns, &opts, prog_len, log_buf, log_buf_size, true);
|
|
|
6fc629 |
+ attr.kern_version = kern_version;
|
|
|
6fc629 |
+ attr.log_level = log_level;
|
|
|
6fc629 |
+ return bcc_prog_load_xattr(&attr, prog_len, log_buf, log_buf_size, true);
|
|
|
6fc629 |
}
|
|
|
6fc629 |
|
|
|
6fc629 |
int bpf_open_raw_sock(const char *name)
|
|
|
6fc629 |
@@ -1388,7 +1326,7 @@ int kernel_struct_has_field(const char *struct_name, const char *field_name)
|
|
|
6fc629 |
struct btf *btf;
|
|
|
6fc629 |
int i, ret, btf_id;
|
|
|
6fc629 |
|
|
|
6fc629 |
- btf = btf__load_vmlinux_btf();
|
|
|
6fc629 |
+ btf = libbpf_find_kernel_btf();
|
|
|
6fc629 |
ret = libbpf_get_error(btf);
|
|
|
6fc629 |
if (ret)
|
|
|
6fc629 |
return -1;
|
|
|
6fc629 |
@@ -1565,7 +1503,7 @@ int bpf_attach_xdp(const char *dev_name, int progfd, uint32_t flags) {
|
|
|
6fc629 |
return -1;
|
|
|
6fc629 |
}
|
|
|
6fc629 |
|
|
|
6fc629 |
- ret = bpf_xdp_attach(ifindex, progfd, flags, NULL);
|
|
|
6fc629 |
+ ret = bpf_set_link_xdp_fd(ifindex, progfd, flags);
|
|
|
6fc629 |
if (ret) {
|
|
|
6fc629 |
libbpf_strerror(ret, err_buf, sizeof(err_buf));
|
|
|
6fc629 |
fprintf(stderr, "bpf: Attaching prog to %s: %s\n", dev_name, err_buf);
|
|
|
6fc629 |
diff --git a/src/cc/libbpf.h b/src/cc/libbpf.h
|
|
|
6fc629 |
index dd86f0a9..e001d740 100644
|
|
|
6fc629 |
--- a/src/cc/libbpf.h
|
|
|
6fc629 |
+++ b/src/cc/libbpf.h
|
|
|
6fc629 |
@@ -27,25 +27,8 @@
|
|
|
6fc629 |
extern "C" {
|
|
|
6fc629 |
#endif
|
|
|
6fc629 |
|
|
|
6fc629 |
-struct bcc_create_map_attr {
|
|
|
6fc629 |
- const char *name;
|
|
|
6fc629 |
- enum bpf_map_type map_type;
|
|
|
6fc629 |
- __u32 map_flags;
|
|
|
6fc629 |
- __u32 key_size;
|
|
|
6fc629 |
- __u32 value_size;
|
|
|
6fc629 |
- __u32 max_entries;
|
|
|
6fc629 |
- __u32 numa_node;
|
|
|
6fc629 |
- __u32 btf_fd;
|
|
|
6fc629 |
- __u32 btf_key_type_id;
|
|
|
6fc629 |
- __u32 btf_value_type_id;
|
|
|
6fc629 |
- __u32 map_ifindex;
|
|
|
6fc629 |
- union {
|
|
|
6fc629 |
- __u32 inner_map_fd;
|
|
|
6fc629 |
- __u32 btf_vmlinux_value_type_id;
|
|
|
6fc629 |
- };
|
|
|
6fc629 |
-};
|
|
|
6fc629 |
-
|
|
|
6fc629 |
-struct bpf_prog_load_opts;
|
|
|
6fc629 |
+struct bpf_create_map_attr;
|
|
|
6fc629 |
+struct bpf_load_program_attr;
|
|
|
6fc629 |
|
|
|
6fc629 |
enum bpf_probe_attach_type {
|
|
|
6fc629 |
BPF_PROBE_ENTRY,
|
|
|
6fc629 |
@@ -61,7 +44,7 @@ struct bcc_perf_buffer_opts {
|
|
|
6fc629 |
int bcc_create_map(enum bpf_map_type map_type, const char *name,
|
|
|
6fc629 |
int key_size, int value_size, int max_entries,
|
|
|
6fc629 |
int map_flags);
|
|
|
6fc629 |
-int bcc_create_map_xattr(struct bcc_create_map_attr *attr, bool allow_rlimit);
|
|
|
6fc629 |
+int bcc_create_map_xattr(struct bpf_create_map_attr *attr, bool allow_rlimit);
|
|
|
6fc629 |
int bpf_update_elem(int fd, void *key, void *value, unsigned long long flags);
|
|
|
6fc629 |
int bpf_lookup_elem(int fd, void *key, void *value);
|
|
|
6fc629 |
int bpf_delete_elem(int fd, void *key);
|
|
|
6fc629 |
@@ -89,11 +72,10 @@ int bcc_prog_load(enum bpf_prog_type prog_type, const char *name,
|
|
|
6fc629 |
const struct bpf_insn *insns, int prog_len,
|
|
|
6fc629 |
const char *license, unsigned kern_version,
|
|
|
6fc629 |
int log_level, char *log_buf, unsigned log_buf_size);
|
|
|
6fc629 |
-int bcc_prog_load_xattr(enum bpf_prog_type prog_type, const char *prog_name,
|
|
|
6fc629 |
- const char *license, const struct bpf_insn *insns,
|
|
|
6fc629 |
- struct bpf_prog_load_opts *opts,
|
|
|
6fc629 |
+int bcc_prog_load_xattr(struct bpf_load_program_attr *attr,
|
|
|
6fc629 |
int prog_len, char *log_buf,
|
|
|
6fc629 |
unsigned log_buf_size, bool allow_rlimit);
|
|
|
6fc629 |
+
|
|
|
6fc629 |
int bpf_attach_socket(int sockfd, int progfd);
|
|
|
6fc629 |
|
|
|
6fc629 |
/* create RAW socket. If name is not NULL/a non-empty null-terminated string,
|
|
|
6fc629 |
--
|
|
|
6fc629 |
2.38.1
|
|
|
6fc629 |
|