Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 15 additions & 17 deletions shared/bpf/skb_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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

Expand Down
5 changes: 0 additions & 5 deletions shared/bpf_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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] = {}; \
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/trace_probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down