Skip to content

Commit

Permalink
samples: bpf: Remove bpf_debug macro in favor of bpf_printk
Browse files Browse the repository at this point in the history
ibumad example was implementing the bpf_debug macro which is exactly the
same as the bpf_printk macro available in bpf_helpers.h. This change
makes use of bpf_printk instead of bpf_debug.

Signed-off-by: Michal Rostecki <[email protected]>
Acked-by: Andrii Nakryiko <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Signed-off-by: Alexei Starovoitov <[email protected]>
  • Loading branch information
vadorovsky authored and Alexei Starovoitov committed Jun 25, 2019
1 parent 7d30a7f commit 7ae9f28
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions samples/bpf/ibumad_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,9 @@ struct bpf_map_def SEC("maps") write_count = {
};

#undef DEBUG
#ifdef DEBUG
#define bpf_debug(fmt, ...) \
({ \
char ____fmt[] = fmt; \
bpf_trace_printk(____fmt, sizeof(____fmt), \
##__VA_ARGS__); \
})
#else
#define bpf_debug(fmt, ...)
#ifndef DEBUG
#undef bpf_printk
#define bpf_printk(fmt, ...)
#endif

/* Taken from the current format defined in
Expand Down Expand Up @@ -86,7 +80,7 @@ int on_ib_umad_read_recv(struct ib_umad_rw_args *ctx)
u64 zero = 0, *val;
u8 class = ctx->mgmt_class;

bpf_debug("ib_umad read recv : class 0x%x\n", class);
bpf_printk("ib_umad read recv : class 0x%x\n", class);

val = bpf_map_lookup_elem(&read_count, &class);
if (!val) {
Expand All @@ -106,7 +100,7 @@ int on_ib_umad_read_send(struct ib_umad_rw_args *ctx)
u64 zero = 0, *val;
u8 class = ctx->mgmt_class;

bpf_debug("ib_umad read send : class 0x%x\n", class);
bpf_printk("ib_umad read send : class 0x%x\n", class);

val = bpf_map_lookup_elem(&read_count, &class);
if (!val) {
Expand All @@ -126,7 +120,7 @@ int on_ib_umad_write(struct ib_umad_rw_args *ctx)
u64 zero = 0, *val;
u8 class = ctx->mgmt_class;

bpf_debug("ib_umad write : class 0x%x\n", class);
bpf_printk("ib_umad write : class 0x%x\n", class);

val = bpf_map_lookup_elem(&write_count, &class);
if (!val) {
Expand Down

0 comments on commit 7ae9f28

Please sign in to comment.