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

aya: Support multiple maps in map sections #181

Merged
merged 1 commit into from Apr 30, 2022

Conversation

dave-tucker
Copy link
Member

This commit uses the symbol table to discover all maps inside an ELF
section. We then divide the data in to equal sized chunks and parse them
using parse_map_def

Signed-off-by: Dave Tucker dave@dtucker.co.uk

@dave-tucker dave-tucker force-pushed the multimap branch 2 times, most recently from 5bf1668 to 8536ec8 Compare January 19, 2022 00:48
@dave-tucker dave-tucker added aya This is about aya (userspace) fix A PR that is a small change or fixes a bug labels Jan 19, 2022
@alessandrod
Copy link
Collaborator

I'll review this soon but first - have you tried it with stripped binaries?

@dave-tucker
Copy link
Member Author

I haven't, but I can do

dave-tucker added a commit to dave-tucker/aya that referenced this pull request Apr 27, 2022
This forces all maps to the maps section so we remain compatible with
libbpf. This requires aya-rs#181 to avoid breaking userspace.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
aya/src/obj/mod.rs Outdated Show resolved Hide resolved
aya/src/obj/mod.rs Outdated Show resolved Hide resolved
aya/src/obj/mod.rs Outdated Show resolved Hide resolved
aya/src/obj/mod.rs Outdated Show resolved Hide resolved
aya/src/obj/mod.rs Show resolved Hide resolved
aya/src/obj/mod.rs Outdated Show resolved Hide resolved
aya/src/obj/mod.rs Outdated Show resolved Hide resolved
@dave-tucker dave-tucker force-pushed the multimap branch 5 times, most recently from 5cbcd5e to b34d0a1 Compare April 28, 2022 20:51
@dave-tucker
Copy link
Member Author

@alessandrod ready for another look. This time around I decided to read into the section data from the address/size in the symbols table, so we can support definitions that are different lengths. The only drawback is that we don't verify all of the section data has been consumed...

Copy link
Collaborator

@alessandrod alessandrod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couple of nits and fix tests pls

aya/src/obj/mod.rs Outdated Show resolved Hide resolved
aya/src/obj/mod.rs Outdated Show resolved Hide resolved
aya/src/obj/mod.rs Outdated Show resolved Hide resolved
This commit uses the symbol table to discover all maps inside an ELF
section. Instead of doing what libbpf does - divide the section data
in to equal sized chunks - we read in to section data using the
symbol address and offset, thus allowing us to support definitions
of varying lengths.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
@dave-tucker
Copy link
Member Author

@alessandrod nits addressed... and while I was editing the test I threw in some padding between the last bpf_map_defs just to check that the parsing logic would work as expected.

@alessandrod alessandrod merged commit 5472ac0 into aya-rs:main Apr 30, 2022
dave-tucker added a commit to dave-tucker/aya that referenced this pull request May 3, 2022
This forces all maps to the maps section so we remain compatible with
libbpf. This requires aya-rs#181 to avoid breaking userspace.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
fasterthanlime pushed a commit to fasterthanlime/aya that referenced this pull request May 20, 2022
This forces all maps to the maps section so we remain compatible with
libbpf. This requires aya-rs#181 to avoid breaking userspace.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aya This is about aya (userspace) fix A PR that is a small change or fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants