Collect and output skb->cb when --filter-trace-tc#461
Merged
brb merged 1 commit intocilium:mainfrom Dec 5, 2024
Merged
Conversation
b687056 to
51ddf26
Compare
Asphaltt
suggested changes
Dec 5, 2024
Contributor
Asphaltt
left a comment
There was a problem hiding this comment.
LGTM, I’ve left two comments for further discussion.
bpf/kprobe_pwru.c
Outdated
| } | ||
|
|
||
| if (cfg->output_cb) { | ||
| bpf_probe_read_kernel(&event->meta.cb, sizeof(event->meta.cb), (void *)&skb->cb[8]); |
Contributor
There was a problem hiding this comment.
It's hard to understand skb->cb[8] here. It's better to convert skb->cb as struct qdisc_skb_cb *, and then read data from cb->data like:
struct qdisc_skb_cb *cb = (typeof(cb))(void *) skb->cb;
bpf_probe_read_kernel(&event->meta.cb, sizeof(event->meta.cb), (void *) &cb->data);
bpf/kprobe_pwru.c
Outdated
| u32 mtu; | ||
| u16 protocol; | ||
| u16 pad; | ||
| u8 cb[20]; |
Contributor
There was a problem hiding this comment.
It's OK to define as u32 cb[5] like cb in struct __sk_buff, I think.
According to kernel verifier implementation[1], __sk_buff->cb will be mapped to ((struct qdisc_skb_cb*)&sk_buff->cb)->data, let's collect 20 bytes from there and output cb as u32[5] when --filter-trace-tc is turned on. [1] https://elixir.bootlin.com/linux/v6.8/source/net/core/filter.c#L9593 Signed-off-by: gray <[email protected]>
51ddf26 to
bddbc54
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
According to kernel verifier implementation[1], __sk_buff->cb will be mapped to ((struct qdisc_skb_cb*)&sk_buff->cb)->data, let's collect 20 bytes from there and output cb as u32[5] when --filter-trace-tc is turned on.
[1] https://elixir.bootlin.com/linux/v6.8/source/net/core/filter.c#L9593
Fixes: #295