-
Notifications
You must be signed in to change notification settings - Fork 648
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
map, program: fall back to /proc for getting an ABI #27
Conversation
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 was just starting to think I may work on this, you beat me to it.
Looks good overall, a few minor nits below.
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 tried this out along with PR #29 and it seemed to work well. Thanks for picking this up.
I made some changes based on our discussion in the linked issues, can you take another look? |
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 think it would still be good for there to be documentation somewhere for a brief comparison between MapABI
and MapSpec
.
abi.go
Outdated
return nil, err | ||
} | ||
|
||
if abi.Type == ArrayOfMaps || abi.Type == HashOfMaps { |
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.
The second commit message states:
The upside is that loading pinned nested maps is now feasible.
But this looks like it is not currently enabled. Not sure if this is intentional or you intended to follow up on this later. (Looks intentional since the public functions still document this restriction)
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.
Dang, this is because I only tested NewMapFromFD, which of course doesn't go via the /proc fallback on my machine.
Code loading eBPF from an ELF file invariably ends up checking that the correct maps and programs are present, and sometimes checking the type or size of them. The various *ABI types attempt to make this simple to achieve, by providing the Check and CheckSpec functions. However, they suffer from multiple problems: first, CheckSpec only checks for the presence of a program or map, even if type, etc. are specified in the CollectionABI. This makes sense because CollectionABI.Check does verify this later on, but it's very unintuitive for the user. Second, using the *ABI means that checking whether a map / program exist is divorced from actually using or modifying them. The user has to repeat map and program names all over the place. Finally, the Check functions assume that the zero value of an ABI member means "I don't care about this value". This breaks for Map flags, since the zero value is valid and indeed very common. Remove the CollectionABI and the Check functions for now, until we find a better way to reduce the repetition required when dealing with collections. This enables us to remove the zero value behaviour from *ABI.
The various ABI types are confusing to users, since they are very similar to the Spec types. Clarify that they are meant to represent the information we can get from the kernel if we are handed a file descriptor or path to a pinned map or program. This means that for now we have to remove *InnerMap, since there is no reliable way to get this information. The upside is that loading pinned nested maps is now feasible. We can also add MapABI.Flags, since we are not bound by Check() functions as before. Fixes #31 Fixes #30
Fall back to reading /proc/self/*/fdinfo if BPF_OBJ_GET_INFO_BY_FD is not available on the current kernel. This should give us compatibility to at least 4.9. Fixes #5
I made #33 for the continuing Spec / ABI confusion. |
Fall back to reading /proc/self/*/fdinfo if BPF_OBJ_GET_INFO_BY_FD is
not available on the current kernel. This should give us compatibility
to at least 4.9.
Fixes #5