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