-
Notifications
You must be signed in to change notification settings - Fork 286
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
Add Unsupported Map type #520
Conversation
✅ Deploy Preview for aya-rs-docs ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site settings. |
50deb73
to
56498fe
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.
Hey @astoycos thanks for the PR!
I do think we need this BUT I also think that we need to protect users from footguns.
Therefore could we add a new option to BpfLoader
called allow_unsupported_maps()
that will enable this?
Then in the normal load()
path we'd be able to iter the maps list and return a nice error to users if we encounter unsupported maps (and allow_unsupported_maps is not set). For example:
The map ${map name} is of type ${map_type} which is currently unsupported in Aya
Yep I agree, let me work on adding this! |
49fa4cf
to
05b7744
Compare
Ok I think this should do it @dave-tucker. The way I had to re-write the Also are there existing tests for these bpfLoader impl functions? I couldn't find any. |
05b7744
to
8bfe557
Compare
82fb951
to
b03cf2c
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.
LGTM
@alessandrod for the API changes:
And the functional change, which is:
|
b03cf2c
to
20d0236
Compare
/assign @alessandrod |
Shoot that won't work and I still can't assign folks here :( |
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.
Thanks and sorry it took so long to review
aya/src/bpf.rs
Outdated
&& maps | ||
.iter() | ||
.filter(|(_, x)| matches!(x, Map::Unsupported(_))) | ||
.count() |
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.
This should use any
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.
So I ended up changing this logic a bit in order to support MapError::Unsupported { map_type: u32 }
More specifically we only search our maps if allow_unsupported_maps is set and use try_for_each
to decide if the map is unsupported and build the error to return.
Just sent you an invite |
Just because aya doesn't support working with some map types doesn't mean we should't allow them to be loaded. Add a new `Unsupported` map type to facilitate this, Next add a user configurable option `allow_unsupported_maps()` which can be called against the `bpfLoader`. Additionally add a nice warning log message when a program is being loaded by Aya and contains an unsupported map type. Signed-off-by: Andrew Stoycos <astoycos@redhat.com>
Move BpfError::UnsupportedMap into MapError and add a map_type field to the error. Update the `allow_unsupported_maps` function comment. Update the logic to check if any unsupported maps are being used. More specifically only search a program's maps if `allow_unsupported_maps` is set and then use the iter function `try_for_each` with a match statement which allows us to return the inner map type if it's unsupported. Signed-off-by: Andrew Stoycos <astoycos@redhat.com>
20d0236
to
17930a8
Compare
Just because aya doesn't support working with some map types doesn't mean we should't allow them to be loaded.
Add a new
Unsupported
map type to facilitate this, also add a debug log to let the user know we just loaded and unsupported map type.