Skip to contentSkip to conversation

bpf_debug output

DISCUSSION Ethy H. Brito 2 participants 3 messages Jul 14, 2021 – Jul 15, 2021

lore
Share & tools
lore
#0 lore raw

Hi!

I am working on some minor modifications in xdp-cpumap-tc to accommodate NAT at WAN side. But the things are not working as expected.

How can bpf_debug be used to help debugging?

I read that its output ends-up in /sys/kernel/debug/tracing/trace_pipe. But how can it be read?
I tried "cat trace_pipe" but this produced no output whatsoever.

Any hints will be appreciated.

Thanx

Regards

Ethy

#1 lore raw

Hi Ethy,

Correct. The output is available via file /sys/kernel/debug/tracing/trace_pipe. There are other helper programs that can also read it, like bpftool prog tracelog or tc exec bpf dbg.

But you need to pay attention, what you're trying to print, since bpf_printk() supports much fewer formats than usual printk(). I.e. only %d %i %u %x %ld %li %lu %lx %lld %lli %llu %llx %p %s conversion specifiers are allowed. If an unsupported specifier is spotted, the string is silently dropped and never appears in trace log.

Here you can find some examples:
https://github.com/xdp-project/xdp-tutorial/tree/master/tracing03-xdp-debug-print

Best regards,
Ivan Koveshnikov

Quoted 20 lines · Ethy H. Brito

Hi!

I am working on some minor modifications in xdp-cpumap-tc to accommodate NAT at WAN side. But the things are not working as expected.

How can bpf_debug be used to help debugging?

I read that its output ends-up in /sys/kernel/debug/tracing/trace_pipe. But how can it be read?
I tried "cat trace_pipe" but this produced no output whatsoever.

Any hints will be appreciated.

Thanx

Regards

Ethy

#2 lore raw
Quoted 1 line · On Wed, 14 Jul 2021 22:06:48 +0500 Ivan Koveshnikov <[email protected]>…

Hi Ethy,

Hi Ivan (and others behind the bushes)

Quoted 6 lines

Correct. The output is available via file /sys/kernel/debug/tracing/trace_pipe. There are other helper programs that can also read it, like bpftool prog tracelog or tc exec bpf dbg.

Quoted 6 lines

But you need to pay attention, what you're trying to print, since bpf_printk() supports much fewer formats than usual printk(). I.e. only %d %i %u %x %ld %li %lu %lx %lld %lli %llu %llx %p %s conversion specifiers are allowed. If an unsupported specifier is spotted, the string is silently dropped and never appears in trace log.

Very useful info.
I couldn't see my logs just because of this: unsupported format. Now it is OK.

Quoted 3 lines

Here you can find some examples:
https://github.com/xdp-project/xdp-tutorial/tree/master/tracing03-xdp-debug-print

Thanx

Regards

Ethy

Quoted 26 lines

Best regards,
Ivan Koveshnikov

Quoted 20 lines · Ethy H. Brito

Hi!

I am working on some minor modifications in xdp-cpumap-tc to accommodate NAT at WAN side. But the things are not working as expected.

How can bpf_debug be used to help debugging?

I read that its output ends-up in /sys/kernel/debug/tracing/trace_pipe. But how can it be read?
I tried "cat trace_pipe" but this produced no output whatsoever.

Any hints will be appreciated.

Thanx

Regards

Ethy

Signature · 6 lines
Ethy H. Brito         /"\
InterNexo Ltda.       \ /  CAMPANHA DA FITA ASCII - CONTRA MAIL HTML
+55 (12) 3797-6860     X   ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL
S.J.Campos - Brasil   / \ 
 
PGP key: http://www.inexo.com.br/~ethy/0xC3F222A0.asc