pwru: Add --output-skb-metadata and --output-xdp-metadata#509
Merged
brb merged 2 commits intocilium:mainfrom Apr 11, 2025
Merged
pwru: Add --output-skb-metadata and --output-xdp-metadata#509brb merged 2 commits intocilium:mainfrom
brb merged 2 commits intocilium:mainfrom
Conversation
565250b to
e97a6da
Compare
Member
|
Yep, this feature makes sense 👍 Mind updating the PR? |
Contributor
Author
I will update the PR later. |
e97a6da to
68154ce
Compare
a64245e to
9a9c914
Compare
Because the `filter_pcap_*` subprogs use its own stack memory, it is unnecessary to reserved 80B stack memory. Therefore, `filter_pcap_*` subprogs can use the whole stack memory. Signed-off-by: Leon Hwang <leon.hwang@linux.dev>
9a9c914 to
1e520b1
Compare
17e40db to
b3c8c05
Compare
b3c8c05 to
8eec248
Compare
It's really useful to output specified metadatas of skb instead of outputing the whole skb btf data. However, it's not easy to `--output-skb-metadata 'skb->mark'` because the metadata is provided by users. Here're the steps to achieve it: 1. Parse the text to C AST. 2. Convert the C AST to bpf insns with `skb` btf type info. 3. Inject the `set_skb_metadata` stub with the generated insns. 4. Output the metadata with the provided field's btf type info. e.g. ```bash $ sudo ./pwru --filter-func 'icmp_rcv' --output-skb-metadata 'skb->hash' --output-skb-metadata 'skb->sw_hash' --output-skb-metadata 'skb->l4_hash' --filter-trace-xdp --output-xdp-metadata 'xdp->rxq->queue_index' host 1.1.1.1 2025/04/07 15:55:11 Attaching xdp progs... 2025/04/07 15:55:11 Attaching kprobes (via kprobe-multi)... 1 / 1 [----------------------------------------------------------------------------------------------------------------------------------------] 100.00% ? p/s 2025/04/07 15:55:11 Attached (ignored 0) 2025/04/07 15:55:11 Listening for events.. 2025/04/07 15:55:11 Failed to retrieve all ifaces from all network namespaces: open /proc/559446/ns/net: no such file or directory. Some iface names might be not shown. SKB CPU PROCESS NETNS MARK/x IFACE PROTO MTU LEN TUPLE FUNC 0xffffa64a81e67a38 6 ~wru/pwru:746016 4026531840 0 ens33:2 0x0000 1500 98 1.1.1.1:0->192.168.241.133:0(icmp) bpf_prog_3b185187f1855c4c_dummy[bpf](xdp) queue_index=0 0xffff991e4b8d5d00 6 ~wru/pwru:746016 4026531840 0 ens33:2 0x0800 65536 64 1.1.1.1:0->192.168.241.133:0(icmp) icmp_rcv hash=0 sw_hash=0 l4_hash=0 ^C2025/04/07 15:55:46 Received signal, exiting program.. 2025/04/07 15:55:46 Detaching kprobes... 1 / 1 [----------------------------------------------------------------------------------------------------------------------------------------] 100.00% ? p/s ``` Signed-off-by: Leon Hwang <leon.hwang@linux.dev>
8eec248 to
fcc6d97
Compare
jschwinger233
approved these changes
Apr 11, 2025
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.
Fixes #502
I'm porting such feature from bpfsnoop's
--output-arg 'skb->hash'.It's really useful to output specified metadatas of skb instead of outputing the whole skb btf data.
However, it's not easy to
--output-skb-metadata 'skb->mark'because the metadata is provided by users.Here're the steps to achieve it:
skbbtf type info.set_skb_metadatastub with the generated insns.e.g.