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

map: add map_extra, memlock, frozen to MapInfo #1570

Merged
merged 1 commit into from
Oct 1, 2024

Conversation

ti-mo
Copy link
Collaborator

@ti-mo ti-mo commented Oct 1, 2024

  • Added MapInfo.MapExtra(), .Memlock() and .Frozen() methods.
  • Moved all unexported fields to a separate section within MapInfo.
  • Changed a few tests to use quicktest instead of manual if statements.

This change required a small refactor to how fdinfo is used, since memlock and frozen are only available there. fdinfo is now always consulted regardless of the success of ObjInfo, and any empty fields are supplemented by data from fdinfo.

Removed errMissingFields since its meaning sort of overlapped with ErrNotSupported. It was only used for getting ProgramInfo, which currently looks for just 2 fields. If we want to pull more fields from fdinfo, this no longer works for the majority of older kernels, since they'll always be missing some fields that were introduced later.

Going forward, rely on ErrNotSupported to tell us if no fields were found in fdinfo, which would indicate there's no map info present because we're trying to query the wrong kind of fd (e.g. a program, link or regular file).

- Added MapInfo.MapExtra(), .Memlock() and .Frozen() methods.
- Moved all unexported fields to a separate section within MapInfo.
- Changed a few tests to use quicktest instead of manual if statements.

This change required a small refactor to how fdinfo is used, since memlock and
frozen are only available there. fdinfo is now always consulted regardless of
the success of ObjInfo, and any empty fields are supplemented by data from fdinfo.

Removed errMissingFields since its meaning sort of overlapped with ErrNotSupported.
It was only used for getting ProgramInfo, which currently looks for just 2 fields.
If we want to pull more fields from fdinfo, this no longer works for the majority
of older kernels, since they'll always be missing some fields that were introduced
later.

Going forward, rely on ErrNotSupported to tell us if no fields were found in fdinfo,
which would indicate there's no map info present because we're trying to query the
wrong kind of fd (e.g. a program, link or regular file).

Signed-off-by: Timo Beckers <timo@isovalent.com>
@mtardy
Copy link
Member

mtardy commented Oct 1, 2024

Interesting, that would have been useful, because I implemented my own way to read memlock. I could argue and wanted to push that this should be returned from the syscall instead of needing to parse fdinfo but not sure it would merge upstream.

@ti-mo
Copy link
Collaborator Author

ti-mo commented Oct 1, 2024

I could argue and wanted to push that this should be returned from the syscall instead of needing to parse fdinfo but not sure it would merge upstream.

I'm not aware of the current attitude around uapi changes, but it seems like things haven't been added to map_/prog_info in quite a few releases now. And if we manage to get this changed now, the fdinfo user space code is in place and can't be removed for backwards-compat reasons. Personally, I'd direct my energy elsewhere. 😄

@ti-mo ti-mo merged commit 21be595 into cilium:main Oct 1, 2024
17 checks passed
@ti-mo ti-mo deleted the tb/extend-mapinfo branch October 1, 2024 20:04
@mtardy
Copy link
Member

mtardy commented Oct 9, 2024

This is really cool by the way, it could simplify things on the Tetragon side, see cilium/tetragon@3f7f1f6, I had to extend the map info with memlock. Thanks to this, it might be possible to drop this code in the future. :)

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.

3 participants