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

Support Parsing of BTF Maps #140

Merged
merged 1 commit into from
Jul 19, 2022
Merged

Conversation

dave-tucker
Copy link
Member

@dave-tucker dave-tucker commented Dec 10, 2021

This PR allows for BTF maps in the .maps ELF section to be parsed.
It reads the necessary information from the BTF section of the ELF file.
It provides the BTF IDs to the bpf_map_create call.

This allows for bpftool to pretty print maps! For example:

$ sudo bpftool map dump id 224 
[{
        "key": 0,
        "value": {
            "rx_packets": 0
        }
    },{
        "key": 1,
        "value": {
            "rx_packets": 0
        }
    },{
        "key": 2,
        "value": {
            "rx_packets": 148
        }
    },{
        "key": 3,
        "value": {
            "rx_packets": 0
        }
    },{
        "key": 4,
        "value": {
            "rx_packets": 0
        }
    }
]

@dave-tucker dave-tucker force-pushed the btf-maps branch 2 times, most recently from 165bc5b to 72fc069 Compare December 10, 2021 23:48
@dave-tucker dave-tucker marked this pull request as ready for review December 10, 2021 23:48
@dave-tucker dave-tucker force-pushed the btf-maps branch 3 times, most recently from 17a8c4e to 5ffbdfc Compare December 12, 2021 11:34
@dave-tucker dave-tucker changed the title Support Parsing of BTF Maps [DO NOT MERGE] Support Parsing of BTF Maps Dec 12, 2021
@dave-tucker dave-tucker added feature A PR that implements a new feature or enhancement aya This is about aya (userspace) labels Jan 10, 2022
@dave-tucker dave-tucker changed the title [DO NOT MERGE] Support Parsing of BTF Maps Support Parsing of BTF Maps Jan 12, 2022
@dave-tucker dave-tucker marked this pull request as draft January 18, 2022 23:02
@dave-tucker
Copy link
Member Author

Parsing works fine, but relocations do not. marking as draft until this is resolved.

@netlify
Copy link

netlify bot commented Jun 30, 2022

Deploy Preview for aya-rs ready!

Name Link
🔨 Latest commit f976229
🔍 Latest deploy log https://app.netlify.com/sites/aya-rs/deploys/62d6fb123feb950008f6fb5e
😎 Deploy Preview https://deploy-preview-140--aya-rs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@dave-tucker dave-tucker added this to the 0.11.1 milestone Jun 30, 2022
@dave-tucker dave-tucker marked this pull request as draft June 30, 2022 19:10
@dave-tucker dave-tucker marked this pull request as ready for review June 30, 2022 20:00
@dave-tucker dave-tucker force-pushed the btf-maps branch 4 times, most recently from 1df5342 to 859dacf Compare July 1, 2022 21:15
@dave-tucker dave-tucker force-pushed the btf-maps branch 2 times, most recently from 1f3d0bc to 23968cd Compare July 3, 2022 17:33
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.

This looks really great - thanks so much for working on it!

Almost there, just a couple of nits.

aya/src/obj/btf/btf.rs Outdated Show resolved Hide resolved
aya/src/obj/mod.rs Show resolved Hide resolved
aya/src/obj/mod.rs Show resolved Hide resolved
This commit allows for BTF maps in the .maps ELF section to be parsed.
It reads the necessary information from the BTF section of the ELF file.
While the btf_ids of Keys and Values types are stored, they are not (yet)
used.

When creating a BTF map, we pass the btf_key_type_id and
btf_value_type_id.

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) feature A PR that implements a new feature or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants