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