Commit 7bda4b40 authored by John Fastabend's avatar John Fastabend Committed by David S. Miller

bpf: extend bpf_trace_printk to support %i

Currently, bpf_trace_printk does not support common formatting
symbol '%i' however vsprintf does and is what eventually gets
called by bpf helper. If users are used to '%i' and currently
make use of it, then bpf_trace_printk will just return with
error without dumping anything to the trace pipe, so just add
support for '%i' to the helper.
Signed-off-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
Acked-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9780c0ab
...@@ -122,8 +122,8 @@ static const struct bpf_func_proto *bpf_get_probe_write_proto(void) ...@@ -122,8 +122,8 @@ static const struct bpf_func_proto *bpf_get_probe_write_proto(void)
} }
/* /*
* limited trace_printk() * Only limited trace_printk() conversion specifiers allowed:
* only %d %u %x %ld %lu %lx %lld %llu %llx %p %s conversion specifiers allowed * %d %i %u %x %ld %li %lu %lx %lld %lli %llu %llx %p %s
*/ */
BPF_CALL_5(bpf_trace_printk, char *, fmt, u32, fmt_size, u64, arg1, BPF_CALL_5(bpf_trace_printk, char *, fmt, u32, fmt_size, u64, arg1,
u64, arg2, u64, arg3) u64, arg2, u64, arg3)
...@@ -198,7 +198,8 @@ BPF_CALL_5(bpf_trace_printk, char *, fmt, u32, fmt_size, u64, arg1, ...@@ -198,7 +198,8 @@ BPF_CALL_5(bpf_trace_printk, char *, fmt, u32, fmt_size, u64, arg1,
i++; i++;
} }
if (fmt[i] != 'd' && fmt[i] != 'u' && fmt[i] != 'x') if (fmt[i] != 'i' && fmt[i] != 'd' &&
fmt[i] != 'u' && fmt[i] != 'x')
return -EINVAL; return -EINVAL;
fmt_cnt++; fmt_cnt++;
} }
......
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