pwru icon indicating copy to clipboard operation
pwru copied to clipboard

`cb[]` (array of values) is not printed correctly when dumping the full skb

Open qmonnet opened this issue 2 years ago • 4 comments

When running pwru with --output-skb, we dump the full content of the socket buffer. However, the value for cb (char cb[48]) seems incorrect. I saw only the first value from the array (corresponding the first char), the following ones were not displayed.

I think cb is the only array in the skb, but this would probably related to the way we handle arrays in general.

context

qmonnet avatar Dec 08 '23 12:12 qmonnet

Considering that Cilium heavily relies on skb->cb, I can't tolerate this issue any longer!

Do you think it's a good idea to fetch and output skb->cb when --output-meta is set? Or we add a new flag --output-skb-cb? Any suggestion?

The best solution looks like https://github.com/cilium/pwru/issues/11, but it requires huge engineering...

jschwinger233 avatar Jan 22 '24 10:01 jschwinger233

Not sure what #11 mean, do you mean finding a way to specify what fields from the skb we want to print? An alternative to that would be to output the SKB metadata (possibly the other info, too) in JSON and filter with jq?

Do you think it's a good idea to fetch and output `skb->cb` when --output-meta is set? Or we add a new flag `--output-skb-cb`? Any suggestion?

I personally wouldn't mind printing the skb->cb by default. We'd need to fix bpf_snprintf_btf() to retrieve the content correctly though, if I understand correctly?

qmonnet avatar Jan 22 '24 10:01 qmonnet

We'd need to fix bpf_snprintf_btf() to retrieve the content correctly though, if I understand correctly?

True, although it would be long way to go.

jschwinger233 avatar Jan 22 '24 10:01 jschwinger233

Maybe as a temp solution we could add skb->cb[] to --output-meta's output if --filter-trace-tc is set? The latter is expected for tracing BPF progs.

brb avatar Feb 14 '24 14:02 brb