Skip to content
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

examples: add example for CO-RE kernel struct (tcp_sock) #602

Merged
merged 1 commit into from Mar 30, 2022

Conversation

gmichelo
Copy link
Contributor

@gmichelo gmichelo commented Mar 19, 2022

This commit adds a new fentry example to showcase how __attribute__((preserve_access_index))
can be used to read fields from kernel structs without the entire struct
definition. This leverage the CO-RE relocatable feature.

examples/README.md Show resolved Hide resolved
examples/tcprtt/main.go Outdated Show resolved Hide resolved
examples/tcprtt/tcprtt.c Outdated Show resolved Hide resolved
@gmichelo gmichelo changed the title examples: add bpf_core_read.h header and example using CO-RE helpers examples: add example for CO-RE kernel struct (tcp_sock) Mar 22, 2022
examples/tcprtt/main.go Outdated Show resolved Hide resolved
@ti-mo
Copy link
Collaborator

ti-mo commented Mar 30, 2022

Awesome, thank you! Excellent comments and documentation. I'll try to feature it more prominently as a CO-RE example.

I've made a few small changes to the build system (running clang-format in CI) and moved some headers around. Will apply a fix before merging.

This commit adds a new `fentry` program to showcase how `preserve_access_index`
can be used to read fields from kernel structs without knowing the entire
struct definition. That is, CO-RE takes care of finding the offset of
the field the caller is looking for within the struct in the host kernel.
@ti-mo ti-mo merged commit 60ffd2f into cilium:master Mar 30, 2022
@ti-mo ti-mo mentioned this pull request Mar 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants