Commit 71c3638f authored by Brenden Blanco's avatar Brenden Blanco

Automatically compute sizeof in bpf_trace_printk

* Addresses issue #61
Signed-off-by: default avatarBrenden Blanco <bblanco@plumgrid.com>
parent 7679a2e0
......@@ -10,8 +10,7 @@ from subprocess import call
prog = """
int hello(void *ctx) {
char fmt[] = "Hello, World!\\n";
bpf_trace_printk(fmt, sizeof(fmt));
bpf_trace_printk("Hello, World!\\n");
return 0;
};
"""
......
......@@ -67,8 +67,10 @@ static int (*bpf_probe_read)(void *dst, u64 size, void *unsafe_ptr) =
(void *) BPF_FUNC_probe_read;
static u64 (*bpf_ktime_get_ns)(void) =
(void *) BPF_FUNC_ktime_get_ns;
static int (*bpf_trace_printk)(const char *fmt, u64 fmt_size, ...) =
static int (*bpf_trace_printk_)(const char *fmt, u64 fmt_size, ...) =
(void *) BPF_FUNC_trace_printk;
#define bpf_trace_printk(_fmt, ...) \
({ char fmt[] = _fmt; bpf_trace_printk_(fmt, sizeof(fmt), ##__VA_ARGS__); })
static u64 (*bpf_clone_redirect)(void *ctx, u64 ifindex, u64 flags) =
(void *) BPF_FUNC_clone_redirect;
static void bpf_tail_call_(u64 map_fd, void *ctx, int index) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment