diff --git a/shared/bpf/skb_utils.h b/shared/bpf/skb_utils.h index ad2e0bb..b3b27ce 100644 --- a/shared/bpf/skb_utils.h +++ b/shared/bpf/skb_utils.h @@ -24,6 +24,21 @@ struct { __uint(max_entries, 64); } m_event SEC(".maps"); +struct { + __uint(type, BPF_MAP_TYPE_ARRAY); + __uint(key_size, sizeof(int)); + __uint(value_size, sizeof(bpf_args_t)); + __uint(max_entries, 1); +} m_config SEC(".maps"); + +#define CONFIG() ({ \ + int _key = 0; \ + void * _v = bpf_map_lookup_elem(&m_config, &_key); \ + if (!_v) \ + return 0; /* this can't happen */ \ + (bpf_args_t*)_v; \ +}) + #define EVENT_OUTPUT(ctx, data) \ bpf_perf_event_output(ctx, &m_event, BPF_F_CURRENT_CPU, \ &(data), sizeof(data)) @@ -50,25 +65,8 @@ struct { #endif #ifdef COMPAT_MODE -struct { - __uint(type, BPF_MAP_TYPE_ARRAY); - __uint(key_size, sizeof(int)); - __uint(value_size, sizeof(bpf_args_t)); - __uint(max_entries, 1); -} m_config SEC(".maps"); - -#define CONFIG() ({ \ - int _key = 0; \ - void * _v = bpf_map_lookup_elem(&m_config, &_key); \ - if (!_v) \ - return 0; /* this can't happen */ \ - (bpf_args_t*)_v; \ -}) - #define try_inline __attribute__((always_inline)) #else -bpf_args_t _bpf_args; -#define CONFIG() &_bpf_args #define try_inline inline #endif diff --git a/shared/bpf_utils.h b/shared/bpf_utils.h index 5cfcff9..052e8c3 100644 --- a/shared/bpf_utils.h +++ b/shared/bpf_utils.h @@ -18,7 +18,6 @@ typedef struct { extern long int syscall (long int __sysno, ...); -#ifdef COMPAT_MODE #define bpf_set_config(skel, sec, value) do { \ int fd = bpf_map__fd(skel->maps.m_config); \ u8 buf[CONFIG_MAP_SIZE] = {}; \ @@ -50,10 +49,6 @@ extern long int syscall (long int __sysno, ...); args->name = value; \ bpf_map_update_elem(fd, &key, args, 0); \ } while (0) -#else -#define bpf_set_config(skel, sec, value) skel->sec->_bpf_args = value -#define bpf_set_config_field(skel, sec, name, value) skel->sec->_bpf_args.name = value -#endif void perf_output_cond(int fd, perf_buffer_sample_fn cb, perf_buffer_lost_fn lost, diff --git a/src/trace_probe.c b/src/trace_probe.c index c43094f..5b8301f 100644 --- a/src/trace_probe.c +++ b/src/trace_probe.c @@ -101,7 +101,7 @@ static int probe_trace_load(trace_t *trace) skel = (void *) name##__open(); \ if (skel && !name##__load((void *)skel)) \ goto load_success; \ - pr_debug("failed to load skel: " #name "\n") + pr_warn("failed to load skel: " #name "\n") static struct kprobe *skel; static int probe_trace_open()