Skip to content

Commit 3354289

Browse files
authored
Merge pull request #13 from OpenCloudOS/future
clean up code by remove 'bss' map
2 parents 6676753 + 8305990 commit 3354289

3 files changed

Lines changed: 16 additions & 23 deletions

File tree

shared/bpf/skb_utils.h

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,21 @@ struct {
2424
__uint(max_entries, 64);
2525
} m_event SEC(".maps");
2626

27+
struct {
28+
__uint(type, BPF_MAP_TYPE_ARRAY);
29+
__uint(key_size, sizeof(int));
30+
__uint(value_size, sizeof(bpf_args_t));
31+
__uint(max_entries, 1);
32+
} m_config SEC(".maps");
33+
34+
#define CONFIG() ({ \
35+
int _key = 0; \
36+
void * _v = bpf_map_lookup_elem(&m_config, &_key); \
37+
if (!_v) \
38+
return 0; /* this can't happen */ \
39+
(bpf_args_t*)_v; \
40+
})
41+
2742
#define EVENT_OUTPUT(ctx, data) \
2843
bpf_perf_event_output(ctx, &m_event, BPF_F_CURRENT_CPU, \
2944
&(data), sizeof(data))
@@ -50,25 +65,8 @@ struct {
5065
#endif
5166

5267
#ifdef COMPAT_MODE
53-
struct {
54-
__uint(type, BPF_MAP_TYPE_ARRAY);
55-
__uint(key_size, sizeof(int));
56-
__uint(value_size, sizeof(bpf_args_t));
57-
__uint(max_entries, 1);
58-
} m_config SEC(".maps");
59-
60-
#define CONFIG() ({ \
61-
int _key = 0; \
62-
void * _v = bpf_map_lookup_elem(&m_config, &_key); \
63-
if (!_v) \
64-
return 0; /* this can't happen */ \
65-
(bpf_args_t*)_v; \
66-
})
67-
6868
#define try_inline __attribute__((always_inline))
6969
#else
70-
bpf_args_t _bpf_args;
71-
#define CONFIG() &_bpf_args
7270
#define try_inline inline
7371
#endif
7472

shared/bpf_utils.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ typedef struct {
1818

1919
extern long int syscall (long int __sysno, ...);
2020

21-
#ifdef COMPAT_MODE
2221
#define bpf_set_config(skel, sec, value) do { \
2322
int fd = bpf_map__fd(skel->maps.m_config); \
2423
u8 buf[CONFIG_MAP_SIZE] = {}; \
@@ -50,10 +49,6 @@ extern long int syscall (long int __sysno, ...);
5049
args->name = value; \
5150
bpf_map_update_elem(fd, &key, args, 0); \
5251
} while (0)
53-
#else
54-
#define bpf_set_config(skel, sec, value) skel->sec->_bpf_args = value
55-
#define bpf_set_config_field(skel, sec, name, value) skel->sec->_bpf_args.name = value
56-
#endif
5752

5853
void
5954
perf_output_cond(int fd, perf_buffer_sample_fn cb, perf_buffer_lost_fn lost,

src/trace_probe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static int probe_trace_load(trace_t *trace)
101101
skel = (void *) name##__open(); \
102102
if (skel && !name##__load((void *)skel)) \
103103
goto load_success; \
104-
pr_debug("failed to load skel: " #name "\n")
104+
pr_warn("failed to load skel: " #name "\n")
105105

106106
static struct kprobe *skel;
107107
static int probe_trace_open()

0 commit comments

Comments
 (0)