Skip to content

Commit e42e759

Browse files
committed
Revert "check the existing of bpf helper by kernel symbols"
This reverts commit dff0e09.
1 parent f31e733 commit e42e759

8 files changed

Lines changed: 5 additions & 43 deletions

File tree

shared/bpf/skb_macro.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@
4141
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
4242
#endif
4343

44-
/* redefine all the CO-RE usage in COMPAT mode */
4544
#ifdef COMPAT_MODE
45+
#define bpf_core_helper_exist(name) false
46+
4647
#undef bpf_core_type_exists
4748
#define bpf_core_type_exists(type) false
4849

@@ -54,6 +55,9 @@
5455

5556
#undef bpf_core_field_offset
5657
#define bpf_core_field_offset(type, field) offsetof(type, field)
58+
#else
59+
#define bpf_core_helper_exist(name) \
60+
bpf_core_enum_value_exists(enum bpf_func_id, BPF_FUNC_##name)
5761
#endif
5862

5963
#endif

shared/bpf/skb_parse.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ struct {
4141
__uint(max_entries, 1);
4242
} m_config SEC(".maps");
4343

44-
const volatile bool bpf_syms_exist[BPF_SYM_MAX];
45-
#define bpf_core_helper_exist(name) bpf_syms_exist[BPF_SYM_bpf_##name##_proto]
46-
4744
#define CONFIG() ({ \
4845
int _key = 0; \
4946
void * _v = bpf_map_lookup_elem(&m_config, &_key); \

shared/bpf/skb_shared.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,4 @@ typedef struct {
176176
#endif
177177
typedef __u64 stack_trace_t[PERF_MAX_STACK_DEPTH];
178178

179-
#define BPF_SYM_MAPPER(FN) \
180-
FN(bpf_jiffies64_proto) \
181-
FN(bpf_get_func_ret_proto)
182-
183-
#define FN(name) BPF_SYM_##name,
184-
enum {
185-
BPF_SYM_MAPPER(FN)
186-
BPF_SYM_MAX,
187-
};
188-
#undef FN
189-
190179
#endif

shared/bpf_utils.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
#include <sys_utils.h>
1414
#include <bpf/btf.h>
15-
#include <parse_sym.h>
1615

1716
#include "bpf_utils.h"
1817

@@ -140,30 +139,9 @@ int btf_get_arg_count(char *name)
140139
if (!t)
141140
return -ENOENT;
142141

143-
/* find kfunction proto of this function */
144142
t = btf__type_by_id(local_btf, t->type);
145143
if (!t)
146144
return -ENOENT;
147145

148146
return btf_vlen(t);
149147
}
150-
151-
/* This is the way we check the exist of kernel function/symbol, before
152-
* the araise of "bpf_core_function_exist()"
153-
*/
154-
#define DEF_BPF_SYM(name) #name,
155-
static const char *bpf_ksyms[] = {
156-
BPF_SYM_MAPPER(DEF_BPF_SYM)
157-
};
158-
#undef DEF_BPF_SYM
159-
160-
void bpf_syms_init(bool *data)
161-
{
162-
const char *sym;
163-
int i;
164-
165-
for (i = 0; i < BPF_SYM_MAX; i++) {
166-
sym = bpf_ksyms[i];
167-
data[i] = sym_get_type(sym) != SYM_NOT_EXIST;
168-
}
169-
}

shared/bpf_utils.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,5 @@ static inline int perf_output(int fd, perf_buffer_sample_fn fn)
6565
int compat_bpf_attach_kprobe(int fd, char *name, bool ret);
6666
const struct btf_type *btf_get_type(char *name);
6767
int btf_get_arg_count(char *name);
68-
void bpf_syms_init(bool *data);
6968

7069
#endif

src/trace.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -646,9 +646,6 @@ int trace_prepare()
646646
return err;
647647
}
648648

649-
/* This function is called after BPF is open and not loaded to the kernel
650-
* yet.
651-
*/
652649
int trace_pre_load()
653650
{
654651
char kret_name[128], regex[128], *func;

src/trace_probe.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ static int probe_trace_load()
8888

8989
/* set the max entries of perf event map to current cpu count */
9090
bpf_map__set_max_entries(skel->maps.m_event, get_nprocs_conf());
91-
bpf_syms_init(skel->rodata->bpf_syms_exist);
9291

9392
trace_ctx.obj = skel->obj;
9493
if (trace_pre_load() || kprobe__load(skel)) {

src/trace_tracing.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ static int tracing_trace_load()
152152

153153
/* set the max entries of perf event map to current cpu count */
154154
bpf_map__set_max_entries(skel->maps.m_event, get_nprocs_conf());
155-
bpf_syms_init(skel->rodata->bpf_syms_exist);
156155

157156
trace_ctx.obj = skel->obj;
158157
tracing_load_rules();

0 commit comments

Comments
 (0)