Projectname large_stringclasses 15
values | Filepath large_stringlengths 4 106 ⌀ | Function large_stringlengths 11 3.45k | Label list |
|---|---|---|---|
Linux Kernel | tools/lib/bpf/gen_loader.c |
static void move_stack2blob(struct bpf_gen *gen, int off, int size,
int stack_off) {
emit(gen, BPF_LDX_MEM(insn_bytes_to_bpf_size(size), BPF_REG_0, BPF_REG_10,
stack_off));
emit2(gen, BPF_LD_IMM64_RAW_FULL(BPF_REG_1, BPF_PSEUDO_MAP_IDX_VALUE, 0, 0, 0,
... | [
0,
0
] |
Linux Kernel | tools/lib/bpf/gen_loader.c |
static void move_stack2ctx(struct bpf_gen *gen, int ctx_off, int size,
int stack_off) {
emit(gen, BPF_LDX_MEM(insn_bytes_to_bpf_size(size), BPF_REG_0, BPF_REG_10,
stack_off));
emit(gen, BPF_STX_MEM(insn_bytes_to_bpf_size(size), BPF_REG_6, BPF_REG_0,
... | [
0,
0
] |
Linux Kernel | tools/lib/bpf/gen_loader.c |
static bool is_simm16(__s64 value) { return value == (__s64)(__s16)value; } | [
0,
0
] |
Linux Kernel | tools/lib/bpf/gen_loader.c | static void emit_debug(struct bpf_gen *gen, int reg1, int reg2, const char *fmt,
va_list args) {
char buf[1024];
int addr, len, ret;
if (!gen->log_level)
return;
ret = vsnprintf(buf, sizeof(buf), fmt, args);
if (ret < 1024 - 7 && reg1 >= 0 && reg2 < 0)
strcat(buf, " r=%d");
... | [
1,
0
] |
Linux Kernel | tools/lib/bpf/gen_loader.c |
static void debug_regs(struct bpf_gen *gen, int reg1, int reg2, const char *fmt,
...) {
va_list args;
va_start(args, fmt);
emit_debug(gen, reg1, reg2, fmt, args);
va_end(args);
} | [
0,
0
] |
Linux Kernel | tools/lib/bpf/gen_loader.c | static void __emit_sys_close(struct bpf_gen *gen) {
emit(gen, BPF_JMP_IMM(BPF_JSLE, BPF_REG_1, 0,
2 + (gen->log_level ? 6 : 0)));
emit(gen, BPF_MOV64_REG(BPF_REG_9, BPF_REG_1));
emit(gen, BPF_EMIT_CALL(BPF_FUNC_sys_close));
debug_regs(gen, BPF_REG_9, BPF_REG_0, "close(%%d) = %%d");
} | [
0,
0
] |
Linux Kernel | tools/lib/bpf/gen_loader.c |
static void emit_sys_close_stack(struct bpf_gen *gen, int stack_off) {
emit(gen, BPF_LDX_MEM(BPF_W, BPF_REG_1, BPF_REG_10, stack_off));
__emit_sys_close(gen);
} | [
0,
0
] |
Linux Kernel | tools/lib/bpf/gen_loader.c |
void bpf_gen__free(struct bpf_gen *gen) {
if (!gen)
return;
free(gen->data_start);
free(gen->insn_start);
free(gen);
} | [
1,
0
] |
Linux Kernel | tools/lib/bpf/gen_loader.c |
void bpf_gen__record_attach_target(struct bpf_gen *gen, const char *attach_name,
enum bpf_attach_type type) {
const char *prefix;
int kind, ret;
btf_get_kernel_prefix_kind(type, &prefix, &kind);
gen->attach_kind = kind;
ret = snprintf(gen->attach_target, sizeof(gen->attach... | [
1,
0
] |
Linux Kernel | tools/lib/bpf/gen_loader.c | static void emit_find_attach_target(struct bpf_gen *gen) {
int name, len = strlen(gen->attach_target) + 1;
pr_debug("gen: find_attach_tgt %s %d\n", gen->attach_target,
gen->attach_kind);
name = add_data(gen, gen->attach_target, len);
emit2(gen, BPF_LD_IMM64_RAW_FULL(BPF_REG_1, BPF_PSEUDO_MAP_IDX_VA... | [
1,
0
] |
Linux Kernel | tools/lib/bpf/gen_loader.c | static struct ksym_desc *get_ksym_desc(struct bpf_gen *gen,
struct ksym_relo_desc *relo) {
struct ksym_desc *kdesc;
int i;
for (i = 0; i < gen->nr_ksyms; i++) {
if (!strcmp(gen->ksyms[i].name, relo->name)) {
gen->ksyms[i].ref++;
return &gen->ksyms[i];
}
... | [
1,
0
] |
Linux Kernel | tools/lib/bpf/gen_loader.c | static void emit_relo_ksym_typeless(struct bpf_gen *gen,
struct ksym_relo_desc *relo, int insn) {
struct ksym_desc *kdesc;
kdesc = get_ksym_desc(gen, relo);
if (!kdesc)
return;
if (kdesc->ref > 1) {
move_blob2blob(gen, insn + offsetof(struct bpf_insn, imm), 4,
... | [
1,
0
] |
Linux Kernel | tools/lib/bpf/gen_loader.c | static __u32 src_reg_mask(void) {
#if defined(__LITTLE_ENDIAN_BITFIELD)
return 0x0f;
#elif defined(__BIG_ENDIAN_BITFIELD)
return 0xf0; /* dst_reg,src_reg,... */
#else
#error "Unsupported bit endianness, cannot proceed"
#endif
} | [
0,
0
] |
Linux Kernel | tools/lib/bpf/hashmap.c |
static void hashmap_add_entry(struct hashmap_entry **pprev,
struct hashmap_entry *entry) {
entry->next = *pprev;
*pprev = entry;
} | [
0,
0
] |
Linux Kernel | tools/lib/bpf/hashmap.c |
static void hashmap_del_entry(struct hashmap_entry **pprev,
struct hashmap_entry *entry) {
*pprev = entry->next;
entry->next = NULL;
} | [
0,
0
] |
Linux Kernel | tools/lib/bpf/hashmap.c |
bool hashmap_find(const struct hashmap *map, long key, long *value) {
struct hashmap_entry *entry;
size_t h;
h = hash_bits(map->hash_fn(key, map->ctx), map->cap_bits);
if (!hashmap_find_entry(map, key, h, NULL, &entry))
return false;
if (value)
*value = entry->value;
return true;
} | [
0,
0
] |
Linux Kernel | tools/lib/bpf/hashmap.c |
bool hashmap_delete(struct hashmap *map, long key, long *old_key,
long *old_value) {
struct hashmap_entry **pprev, *entry;
size_t h;
h = hash_bits(map->hash_fn(key, map->ctx), map->cap_bits);
if (!hashmap_find_entry(map, key, h, &pprev, &entry))
return false;
if (old_key)
*old_k... | [
1,
0
] |
Linux Kernel | tools/lib/bpf/hashmap.h | static inline size_t hash_bits(size_t h, int bits) {
if (bits == 0)
return 0;
#if (__SIZEOF_SIZE_T__ == __SIZEOF_LONG_LONG__)
/* LP64 case */
return (h * 11400714819323198485llu) >> (__SIZEOF_LONG_LONG__ * 8 - bits);
#elif (__SIZEOF_SIZE_T__ <= __SIZEOF_LONG__)
return (h * 2654435769lu) >> (__SIZEOF_LONG_... | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
static inline __u64 ptr_to_u64(const void *ptr) {
return (__u64)(unsigned long)ptr;
} | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
static void bpf_object__elf_finish(struct bpf_object *obj) {
if (!obj->efile.elf)
return;
elf_end(obj->efile.elf);
obj->efile.elf = NULL;
obj->efile.symbols = NULL;
obj->efile.st_ops_data = NULL;
zfree(&obj->efile.secs);
obj->efile.sec_cnt = 0;
zclose(obj->efile.fd);
obj->efile.obj_buf = NULL;
... | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c | static int bpf_object__init_license(struct bpf_object *obj, void *data,
size_t size) {
if (!data) {
pr_warn("invalid license section in %s\n", obj->path);
return -LIBBPF_ERRNO__FORMAT;
}
libbpf_strlcpy(obj->license, data, min(size + 1, sizeof(obj->license)));
pr_debu... | [
1,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c | static int set_kcfg_value_tri(struct extern_desc *ext, void *ext_val,
char value) {
switch (ext->kcfg.type) {
case KCFG_BOOL:
if (value == 'm') {
pr_warn("extern (kcfg) '%s': value '%c' implies tristate or char type\n",
ext->name, value);
return -EINVAL;
... | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
static int parse_u64(const char *value, __u64 *res) {
char *value_end;
int err;
errno = 0;
*res = strtoull(value, &value_end, 0);
if (errno) {
err = -errno;
pr_warn("failed to parse '%s' as integer: %d\n", value, err);
return err;
}
if (*value_end) {
pr_warn("failed to parse '%s' as inte... | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
static int set_kcfg_value_num(struct extern_desc *ext, void *ext_val,
__u64 value) {
if (ext->kcfg.type != KCFG_INT && ext->kcfg.type != KCFG_CHAR &&
ext->kcfg.type != KCFG_BOOL) {
pr_warn("extern (kcfg) '%s': value '%llu' implies integer, char, or "
"boolean type\... | [
1,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
static int bpf_object__read_kconfig_mem(struct bpf_object *obj,
const char *config, void *data) {
char buf[PATH_MAX];
int err = 0;
FILE *file;
file = fmemopen((void *)config, strlen(config), "r");
if (!file) {
err = -errno;
pr_warn("failed to open in-memory Kc... | [
1,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
const char *btf_kind_str(const struct btf_type *t) {
return __btf_kind_str(btf_kind(t));
} | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c | static bool get_map_field_int(const char *map_name, const struct btf *btf,
const struct btf_member *m, __u32 *res) {
const struct btf_type *t = skip_mods_and_typedefs(btf, m->type, NULL);
const char *name = btf__name_by_offset(btf, m->name_off);
const struct btf_array *arr_info;
co... | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
static int pathname_concat(char *buf, size_t buf_sz, const char *path,
const char *name) {
int len;
len = snprintf(buf, buf_sz, "%s/%s", path, name);
if (len < 0)
return -EINVAL;
if (len >= buf_sz)
return -ENAMETOOLONG;
return 0;
} | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
static bool section_have_execinstr(struct bpf_object *obj, int idx) {
Elf64_Shdr *sh;
sh = elf_sec_hdr(obj, elf_sec_by_idx(obj, idx));
if (!sh)
return false;
return sh->sh_flags & SHF_EXECINSTR;
} | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
static bool btf_needs_sanitization(struct bpf_object *obj) {
bool has_func_global = kernel_supports(obj, FEAT_BTF_GLOBAL_FUNC);
bool has_datasec = kernel_supports(obj, FEAT_BTF_DATASEC);
bool has_float = kernel_supports(obj, FEAT_BTF_FLOAT);
bool has_func = kernel_supports(obj, FEAT_BTF_FUNC);
bool has_decl_... | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c | static int bpf_object_fixup_btf(struct bpf_object *obj) {
int i, n, err = 0;
if (!obj->btf)
return 0;
n = btf__type_cnt(obj->btf);
for (i = 1; i < n; i++) {
struct btf_type *t = btf_type_by_id(obj->btf, i);
if (btf_is_datasec(t)) {
err = btf_fixup_datasec(obj, obj->btf, t);
if (err)
... | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
static const char *elf_sym_str(const struct bpf_object *obj, size_t off) {
const char *name;
name = elf_strptr(obj->efile.elf, obj->efile.strtabidx, off);
if (!name) {
pr_warn(
"elf: failed to get section name string at offset %zu from %s: %s\n",
off, obj->path, elf_errmsg(-1));
return N... | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
static Elf_Scn *elf_sec_by_name(const struct bpf_object *obj,
const char *name) {
Elf_Scn *scn = NULL;
Elf *elf = obj->efile.elf;
const char *sec_name;
while ((scn = elf_nextscn(elf, scn)) != NULL) {
sec_name = elf_sec_name(obj, scn);
if (!sec_name)
return NULL;
... | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
static Elf64_Shdr *elf_sec_hdr(const struct bpf_object *obj, Elf_Scn *scn) {
Elf64_Shdr *shdr;
if (!scn)
return NULL;
shdr = elf64_getshdr(scn);
if (!shdr) {
pr_warn("elf: failed to get section(%zu) header from %s: %s\n",
elf_ndxscn(scn), obj->path, elf_errmsg(-1));
return NULL;
}
... | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
static Elf64_Rel *elf_rel_by_idx(Elf_Data *data, size_t idx) {
if (idx >= data->d_size / sizeof(Elf64_Rel))
return NULL;
return (Elf64_Rel *)data->d_buf + idx;
} | [
1,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c | static bool sym_is_subprog(const Elf64_Sym *sym, int text_shndx) {
int bind = ELF64_ST_BIND(sym->st_info);
int type = ELF64_ST_TYPE(sym->st_info);
if (sym->st_shndx != text_shndx)
return false;
/* local function */
if (bind == STB_LOCAL && type == STT_SECTION)
return true;
/* global function */
... | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
static enum libbpf_map_type
bpf_object__section_to_libbpf_map_type(const struct bpf_object *obj,
int shndx) {
if (shndx == obj->efile.symbols_shndx)
return LIBBPF_MAP_KCONFIG;
switch (obj->efile.secs[shndx].sec_type) {
case SEC_BSS:
return LIBBPF_MAP_BSS;
case SE... | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
int bpf_map__set_autocreate(struct bpf_map *map, bool autocreate) {
if (map->obj->loaded)
return libbpf_err(-EBUSY);
map->autocreate = autocreate;
return 0;
} | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
__u32 bpf_map__max_entries(const struct bpf_map *map) {
return map->def.max_entries;
} | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
static int probe_kern_global_data(void) {
char *cp, errmsg[STRERR_BUFSIZE];
struct bpf_insn insns[] = {
BPF_LD_MAP_VALUE(BPF_REG_1, 0, 16),
BPF_ST_MEM(BPF_DW, BPF_REG_1, 0, 42),
BPF_MOV64_IMM(BPF_REG_0, 0),
BPF_EXIT_INSN(),
};
int ret, map, insn_cnt = ARRAY_SIZE(insns);
map = bpf_map... | [
1,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c | static int probe_kern_btf_func(void) {
static const char strs[] = "\0int\0x\0a";
__u32 types[] = {
/* int */
BTF_TYPE_INT_ENC(1, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
/* FUNC_PROTO */ /* [2] */
BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_FUNC_PROTO, 0, 1), 0),
B... | [
1,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c | static int probe_kern_btf_float(void) {
static const char strs[] = "\0float";
__u32 types[] = {
BTF_TYPE_FLOAT_ENC(1, 4),
};
return probe_fd(
libbpf__load_raw_btf((char *)types, sizeof(types), strs, sizeof(strs)));
} | [
1,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c | static int probe_kern_btf_decl_tag(void) {
static const char strs[] = "\0tag";
__u32 types[] = {
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
/* VAR x */ /* [2] */
BTF_TYPE_ENC(1, BTF_INFO_ENC(BTF_KIND_VAR, 0, 0), 1),
BTF_VAR_STATIC,
/* a... | [
1,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
static int probe_kern_array_mmap(void) {
LIBBPF_OPTS(bpf_map_create_opts, opts, .map_flags = BPF_F_MMAPABLE);
int fd;
fd = bpf_map_create(BPF_MAP_TYPE_ARRAY, "libbpf_mmap", sizeof(int),
sizeof(int), 1, &opts);
return probe_fd(fd);
} | [
1,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
static int probe_prog_bind_map(void) {
char *cp, errmsg[STRERR_BUFSIZE];
struct bpf_insn insns[] = {
BPF_MOV64_IMM(BPF_REG_0, 0),
BPF_EXIT_INSN(),
};
int ret, map, prog, insn_cnt = ARRAY_SIZE(insns);
map = bpf_map_create(BPF_MAP_TYPE_ARRAY, "libbpf_det_bind", sizeof(int), 32,
... | [
1,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
static int probe_kern_btf_enum64(void) {
static const char strs[] = "\0enum64";
__u32 types[] = {
BTF_TYPE_ENC(1, BTF_INFO_ENC(BTF_KIND_ENUM64, 0, 0), 8),
};
return probe_fd(
libbpf__load_raw_btf((char *)types, sizeof(types), strs, sizeof(strs)));
} | [
1,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
static bool map_is_reuse_compat(const struct bpf_map *map, int map_fd) {
struct bpf_map_info map_info;
char msg[STRERR_BUFSIZE];
__u32 map_info_len = sizeof(map_info);
int err;
memset(&map_info, 0, map_info_len);
err = bpf_obj_get_info_by_fd(map_fd, &map_info, &map_info_len);
if (err && errno == EINVAL)... | [
1,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
static int bpf_object__reuse_map(struct bpf_map *map) {
char *cp, errmsg[STRERR_BUFSIZE];
int err, pin_fd;
pin_fd = bpf_obj_get(map->pin_path);
if (pin_fd < 0) {
err = -errno;
if (err == -ENOENT) {
pr_debug("found no pinned map to reuse at '%s'\n", map->pin_path);
return 0;
}
cp =... | [
1,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c | static int bpf_object__populate_internal_map(struct bpf_object *obj,
struct bpf_map *map) {
enum libbpf_map_type map_type = map->libbpf_type;
char *cp, errmsg[STRERR_BUFSIZE];
int err, zero = 0;
if (obj->gen_loader) {
bpf_gen__map_update_elem(obj->gen_loader, ma... | [
1,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
static int init_map_in_map_slots(struct bpf_object *obj, struct bpf_map *map) {
const struct bpf_map *targ_map;
unsigned int i;
int fd, err = 0;
for (i = 0; i < map->init_slots_sz; i++) {
if (!map->init_slots[i])
continue;
targ_map = map->init_slots[i];
fd = bpf_map__fd(targ_map);
if (... | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
static int bpf_object_init_prog_arrays(struct bpf_object *obj) {
struct bpf_map *map;
int i, err;
for (i = 0; i < obj->nr_maps; i++) {
map = &obj->maps[i];
if (!map->init_slots_sz || map->def.type != BPF_MAP_TYPE_PROG_ARRAY)
continue;
err = init_prog_array_slots(obj, map);
if (err < 0) {... | [
1,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
int bpf_core_add_cands(struct bpf_core_cand *local_cand,
size_t local_essent_len, const struct btf *targ_btf,
const char *targ_btf_name, int targ_start_id,
struct bpf_core_cand_list *cands) {
struct bpf_core_cand *new_cands, *cand;
const struct b... | [
1,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
static int record_relo_core(struct bpf_program *prog,
const struct bpf_core_relo *core_relo,
int insn_idx) {
struct reloc_desc *relos, *relo;
relos =
libbpf_reallocarray(prog->reloc_desc, prog->nr_reloc + 1, sizeof(*relos));
if (!relos)
return -E... | [
1,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
static const struct bpf_core_relo *find_relo_core(struct bpf_program *prog,
int insn_idx) {
struct reloc_desc *relo;
int i;
for (i = 0; i < prog->nr_reloc; i++) {
relo = &prog->reloc_desc[i];
if (relo->type != RELO_CORE || relo->insn_idx != insn_idx)
... | [
1,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c | static void poison_map_ldimm64(struct bpf_program *prog, int relo_idx,
int insn_idx, struct bpf_insn *insn, int map_idx,
const struct bpf_map *map) {
int i;
pr_debug("prog '%s': relo #%d: poisoning insn #%d that loads map #%d '%s'\n",
prog->n... | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c | static void bpf_object__free_relocs(struct bpf_object *obj) {
struct bpf_program *prog;
int i;
for (i = 0; i < obj->nr_programs; i++) {
prog = &obj->programs[i];
zfree(&prog->reloc_desc);
prog->nr_reloc = 0;
}
} | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c | static int cmp_relocs(const void *_a, const void *_b) {
const struct reloc_desc *a = _a;
const struct reloc_desc *b = _b;
if (a->insn_idx != b->insn_idx)
return a->insn_idx < b->insn_idx ? -1 : 1;
if (a->type != b->type)
return a->type < b->type ? -1 : 1;
return 0;
} | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c | static int bpf_object__sanitize_prog(struct bpf_object *obj,
struct bpf_program *prog) {
struct bpf_insn *insn = prog->insns;
enum bpf_func_id func_id;
int i;
if (obj->gen_loader)
return 0;
for (i = 0; i < prog->insns_cnt; i++, insn++) {
if (!insn_is_helper_call(... | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c | static void fixup_log_failed_core_relo(struct bpf_program *prog, char *buf,
size_t buf_sz, size_t log_sz,
char *line1, char *line2, char *line3) {
const struct bpf_core_relo *relo;
struct bpf_core_spec spec;
char patch[512], spec_buf[2... | [
1,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c | static int bpf_object_init_progs(struct bpf_object *obj,
const struct bpf_object_open_opts *opts) {
struct bpf_program *prog;
int err;
bpf_object__for_each_program(prog, obj) {
prog->sec_def = find_sec_def(prog->sec_name);
if (!prog->sec_def) {
pr_debug("prog '%s':... | [
1,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
static int bpf_object__sanitize_maps(struct bpf_object *obj) {
struct bpf_map *m;
bpf_object__for_each_map(m, obj) {
if (!bpf_map__is_internal(m))
continue;
if (!kernel_supports(obj, FEAT_ARRAY_MMAP))
m->def.map_flags ^= BPF_F_MMAPABLE;
}
return 0;
} | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
static int kallsyms_cb(unsigned long long sym_addr, char sym_type,
const char *sym_name, void *ctx) {
struct bpf_object *obj = ctx;
const struct btf_type *t;
struct extern_desc *ext;
ext = find_extern_by_name(obj, sym_name);
if (!ext || ext->type != EXT_KSYM)
return 0;
t = btf_... | [
1,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
static int bpf_object__read_kallsyms_file(struct bpf_object *obj) {
return libbpf_kallsyms_parse(kallsyms_cb, obj);
} | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
static int check_path(const char *path) {
char *cp, errmsg[STRERR_BUFSIZE];
struct statfs st_fs;
char *dname, *dir;
int err = 0;
if (path == NULL)
return -EINVAL;
dname = strdup(path);
if (dname == NULL)
return -ENOMEM;
dir = dirname(dname);
if (statfs(dir, &st_fs)) {
cp = libbpf_strer... | [
1,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
int bpf_map__unpin(struct bpf_map *map, const char *path) {
int err;
if (map == NULL) {
pr_warn("invalid map pointer\n");
return libbpf_err(-EINVAL);
}
if (map->pin_path) {
if (path && strcmp(path, map->pin_path)) {
pr_warn("map '%s' already has pin path '%s' different from '%s'\n",
... | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
bool bpf_map__is_pinned(const struct bpf_map *map) { return map->pinned; } | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
int bpf_object__pin_maps(struct bpf_object *obj, const char *path) {
struct bpf_map *map;
int err;
if (!obj)
return libbpf_err(-ENOENT);
if (!obj->loaded) {
pr_warn("object not yet loaded; load it first\n");
return libbpf_err(-ENOENT);
}
bpf_object__for_each_map(map, obj) {
char *pin_pat... | [
1,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
int bpf_object__unpin_maps(struct bpf_object *obj, const char *path) {
struct bpf_map *map;
int err;
if (!obj)
return libbpf_err(-ENOENT);
bpf_object__for_each_map(map, obj) {
char *pin_path = NULL;
char buf[PATH_MAX];
if (path) {
err = pathname_concat(buf, sizeof(buf), path, bpf_map__... | [
1,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
int bpf_object__pin(struct bpf_object *obj, const char *path) {
int err;
err = bpf_object__pin_maps(obj, path);
if (err)
return libbpf_err(err);
err = bpf_object__pin_programs(obj, path);
if (err) {
bpf_object__unpin_maps(obj, path);
return libbpf_err(err);
}
return 0;
} | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
struct btf *bpf_object__btf(const struct bpf_object *obj) {
return obj ? obj->btf : NULL;
} | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
int bpf_object__btf_fd(const struct bpf_object *obj) {
return obj->btf ? btf__fd(obj->btf) : -1;
} | [
1,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c | static struct bpf_program *__bpf_program__iter(const struct bpf_program *p,
const struct bpf_object *obj,
bool forward) {
size_t nr_programs = obj->nr_programs;
ssize_t idx;
if (!nr_programs)
return NULL;
if (!p)... | [
1,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
struct bpf_program *bpf_object__next_program(const struct bpf_object *obj,
struct bpf_program *prev) {
struct bpf_program *prog = prev;
do {
prog = __bpf_program__iter(prog, obj, true);
} while (prog && prog_is_subprog(obj, prog));
return prog;
} | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
const char *bpf_program__name(const struct bpf_program *prog) {
return prog->name;
} | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
const struct bpf_insn *bpf_program__insns(const struct bpf_program *prog) {
return prog->insns;
} | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
int bpf_program__set_type(struct bpf_program *prog, enum bpf_prog_type type) {
if (prog->obj->loaded)
return libbpf_err(-EBUSY);
prog->type = type;
return 0;
} | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
int bpf_program__set_flags(struct bpf_program *prog, __u32 flags) {
if (prog->obj->loaded)
return libbpf_err(-EBUSY);
prog->prog_flags = flags;
return 0;
} | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c | int libbpf_unregister_prog_handler(int handler_id) {
struct bpf_sec_def *sec_defs;
int i;
if (handler_id <= 0)
return libbpf_err(-EINVAL);
if (has_custom_fallback_def && custom_fallback_def.handler_id == handler_id) {
memset(&custom_fallback_def, 0, sizeof(custom_fallback_def));
has_custom_fallbac... | [
1,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
static const struct bpf_sec_def *find_sec_def(const char *sec_name) {
const struct bpf_sec_def *sec_def;
int i, n;
n = custom_sec_def_cnt;
for (i = 0; i < n; i++) {
sec_def = &custom_sec_defs[i];
if (sec_def_matches(sec_def, sec_name))
return sec_def;
}
n = ARRAY_SIZE(section_defs);
for (... | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c | static int find_kernel_btf_id(struct bpf_object *obj, const char *attach_name,
enum bpf_attach_type attach_type, int *btf_obj_fd,
int *btf_type_id) {
int ret, i;
ret = find_attach_btf_id(obj->btf_vmlinux, attach_name, attach_type);
if (ret > 0) {
*b... | [
1,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
int bpf_map__fd(const struct bpf_map *map) {
return map ? map->fd : libbpf_err(-EINVAL);
} | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c | static bool map_uses_real_name(const struct bpf_map *map) {
if (map->libbpf_type == LIBBPF_MAP_DATA &&
strcmp(map->real_name, DATA_SEC) != 0)
return true;
if (map->libbpf_type == LIBBPF_MAP_RODATA &&
strcmp(map->real_name, RODATA_SEC) != 0)
return true;
return false;
} | [
1,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
const char *bpf_map__name(const struct bpf_map *map) {
if (!map)
return NULL;
if (map_uses_real_name(map))
return map->real_name;
return map->name;
} | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
__u32 bpf_map__value_size(const struct bpf_map *map) {
return map->def.value_size;
} | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
__u32 bpf_map__btf_value_type_id(const struct bpf_map *map) {
return map ? map->btf_value_type_id : 0;
} | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
bool bpf_map__is_internal(const struct bpf_map *map) {
return map->libbpf_type != LIBBPF_MAP_UNSPEC;
} | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
struct bpf_map *bpf_object__next_map(const struct bpf_object *obj,
const struct bpf_map *prev) {
if (prev == NULL)
return obj->maps;
return __bpf_map__iter(prev, obj, 1);
} | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
int bpf_object__find_map_fd_by_name(const struct bpf_object *obj,
const char *name) {
return bpf_map__fd(bpf_object__find_map_by_name(obj, name));
} | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
static int validate_map_op(const struct bpf_map *map, size_t key_sz,
size_t value_sz, bool check_value_sz) {
if (map->fd <= 0)
return -ENOENT;
if (map->def.key_size != key_sz) {
pr_warn("map '%s': unexpected key size %zu provided, expected %u\n",
map->name, key_sz, m... | [
1,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c | int bpf_map__delete_elem(const struct bpf_map *map, const void *key,
size_t key_sz, __u64 flags) {
int err;
err = validate_map_op(map, key_sz, 0, false);
if (err)
return libbpf_err(err);
return bpf_map_delete_elem_flags(map->fd, key, flags);
} | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
static bool use_debugfs(void) {
static int has_debugfs = -1;
if (has_debugfs < 0)
has_debugfs = faccessat(AT_FDCWD, DEBUGFS, F_OK, AT_EACCESS) == 0;
return has_debugfs == 1;
} | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
static int add_kprobe_event_legacy(const char *probe_name, bool retprobe,
const char *kfunc_name, size_t offset) {
return append_to_file(
tracefs_kprobe_events(), "%c:%s/%s %s+0x%zx", retprobe ? 'r' : 'p',
retprobe ? "kretprobes" : "kprobes", probe_name, kfunc_name, off... | [
1,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
static int remove_kprobe_event_legacy(const char *probe_name, bool retprobe) {
return append_to_file(tracefs_kprobe_events(), "-:%s/%s",
retprobe ? "kretprobes" : "kprobes", probe_name);
} | [
1,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
static int determine_kprobe_perf_type_legacy(const char *probe_name,
bool retprobe) {
char file[256];
snprintf(file, sizeof(file), "%s/events/%s/%s/id", tracefs_path(),
retprobe ? "kretprobes" : "kprobes", probe_name);
return parse_uint_from_file(file, "%... | [
1,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
struct bpf_link *bpf_program__attach_kprobe(const struct bpf_program *prog,
bool retprobe,
const char *func_name) {
DECLARE_LIBBPF_OPTS(bpf_kprobe_opts, opts, .retprobe = retprobe, );
return bpf_program__attach_kprobe_opts(pro... | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c | static bool glob_match(const char *str, const char *pat) {
while (*str && *pat && *pat != '*') {
if (*pat == '?') {
str++;
pat++;
continue;
}
if (*str != *pat)
return false;
str++;
pat++;
}
/* Check wild card */
if (*pat == '*') {
while (*pat == '*')
pat++;
... | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c | static int attach_ksyscall(const struct bpf_program *prog, long cookie,
struct bpf_link **link) {
LIBBPF_OPTS(bpf_ksyscall_opts, opts);
const char *syscall_name;
*link = NULL;
if (strcmp(prog->sec_name, "ksyscall") == 0 ||
strcmp(prog->sec_name, "kretsyscall") == 0)
return... | [
1,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c | static void gen_uprobe_legacy_event_name(char *buf, size_t buf_sz,
const char *binary_path,
uint64_t offset) {
int i;
snprintf(buf, buf_sz, "libbpf_%u_%s_0x%zx", getpid(), binary_path,
(size_t)offset);
for (i = 0; buf[i... | [
0,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
static inline int remove_uprobe_event_legacy(const char *probe_name,
bool retprobe) {
return append_to_file(tracefs_uprobe_events(), "-:%s/%s",
retprobe ? "uretprobes" : "uprobes", probe_name);
} | [
1,
0
] |
Linux Kernel | tools/lib/bpf/libbpf.c |
static int determine_uprobe_perf_type_legacy(const char *probe_name,
bool retprobe) {
char file[512];
snprintf(file, sizeof(file), "%s/events/%s/%s/id", tracefs_path(),
retprobe ? "uretprobes" : "uprobes", probe_name);
return parse_uint_from_file(file, "%... | [
1,
0
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.