-
Notifications
You must be signed in to change notification settings - Fork 172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stop tracking skb in the end of its lifetime #241
Conversation
The outstanding issue is, I can't come up with a good flag name. In the 3rd commit, I added a flag But I don't think |
aab3737
to
debe343
Compare
Previous injection assumes the next instruction to `printk()` is "goto <label_return>", which isn't guaranteed by clang. Technically, previous injection adds a ret insn to implement "exit immediately if not matched": asm.Return().WithSymbol("return") which forces us to remove the duplicated assumed "goto <label_return>" after `printk()`. This commit improves the way to inject ebpf pcap filter without such assumption by setting proper values to registers to avoid adding ret insn. Signed-off-by: Zhichuan Liang <gray.liang@isovalent.com>
debe343
to
963b12b
Compare
main.go
Outdated
if flags.FilterTrackSkb { | ||
skbLifetimeEndAt := []string{"kfree_skbmem"} | ||
if !flags.FilterTrackSkbAcrossNamespaces { | ||
skbLifetimeEndAt = append(skbLifetimeEndAt, "eth_type_trans") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know how to do it flexibly without hard coding eth_type_trans
and kfree_skbmem
- -
Tough one 😅 What's about |
Marking As for Below is a typical pwru output for an egress traffic inside a netns:
I don't know how to stop tracking an egress skb. |
Maybe only handle Below is pwru output for an egress skb on bare metal:
As we see, there is a The disadvantage of stopping tracking only at A quick fix for that is to filter the events in userspace: we double check the skb's netns before printing them from golang process. Edit: nothing needs to be fixed.
|
SGTM! |
963b12b
to
560314b
Compare
`kfree_skbmem` marks the end of an skb's lifetime, so we stop tracking it at that time when `--filter-track-skb` is enabled. Signed-off-by: Zhichuan Liang <gray.liang@isovalent.com>
560314b
to
f96c270
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
--filter-track-skb
has a problem of mismatching skbs with same pointer address. This PR tries to fix it by stopping tracking after an skb ends its lifetime.In general, an skb has 3 possible endings:
All the three endings hit
kfree_skbmem
eventually, so we delete tracked skb pointer address from bpf map at that time.Fixes: #194
Signed-off-by: Zhichuan Liang gray.liang@isovalent.com