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

MapType probe API #321

Merged
merged 3 commits into from Jul 19, 2021
Merged

MapType probe API #321

merged 3 commits into from Jul 19, 2021

Conversation

rgo3
Copy link
Contributor

@rgo3 rgo3 commented Jun 9, 2021

Currently only supports default bpfMapCreateAttr values, to showcase
basic functionality. Results are cached by a go map. Tests log durations
to see cache performance. Added some open questions and missing error
interface checks to the comments in the file.

Signed-off-by: Robin Gögge r.goegge@outlook.com

probe.go Outdated Show resolved Hide resolved
features/map.go Outdated Show resolved Hide resolved
Copy link
Member

@qmonnet qmonnet left a comment

Choose a reason for hiding this comment

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

I'm not super familiar with the library, but I've worked on bpftool's probes and I've been following the work from Robin (as a GSoC co-mentor), so here are some comments on the PR.

In addition to the comments below, I would suggest to rework the content of the different commits (possibly squashing them all as the result is not that big), there is not point in adding probe.go to remove it in the following commit for example.

I see a test for the feature. I haven't looked at the CI so I don't know if it will integrate well with it. Ideally we need an environment with all features available so we can check we can detect them? And an environment where we know that a given set of features is missing, so we can check that there are not reported as supported? How can we validate the cache is working? It would also be interesting to be able to test with different capabilities for the process (although the policy on how to deal with -EPERM would need to be sorted out first).

features/map.go Outdated Show resolved Hide resolved
features/map.go Outdated Show resolved Hide resolved
features/map.go Outdated Show resolved Hide resolved
features/map.go Outdated Show resolved Hide resolved
features/map.go Outdated Show resolved Hide resolved
features/map.go Outdated Show resolved Hide resolved
features/map.go Outdated Show resolved Hide resolved
features/map.go Outdated Show resolved Hide resolved
features/map.go Outdated Show resolved Hide resolved
features/map.go Outdated Show resolved Hide resolved
@rgo3
Copy link
Contributor Author

rgo3 commented Jul 4, 2021

Thanks for the review @qmonnet.

I always planned on squashing the commits at the end to have a nice single commit for this work, Timo and I just agreed I should add smaller commits for now documenting my progress and making the review easier while its a draft.

I'll start addressing the comments on Monday morning.

I see a test for the feature. I haven't looked at the CI so I don't know if it will integrate well with it. Ideally we need an environment with all features available so we can check we can detect them? And an environment where we know that a given set of features is missing, so we can check that there are not reported as supported?

For now the test was just a way for me to check if my probes are working. Generally I had similar thoughts, I was also wondering if this feature API, or at least the testing of it needs a minimum version for featuers like we have with the FeatureTest abstraction e.g.

MinimumVersion Version

How can we validate the cache is working?

In the earlier commits I had took some time stamps in the tests to validate it, but generally isn't it ok to assume that a Go map works?

@rgo3 rgo3 force-pushed the probemaps-poc branch 2 times, most recently from 619445c to 8a73ce5 Compare July 12, 2021 16:34
Copy link
Member

@qmonnet qmonnet left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks for addressing all the feedback. Nice work!

features/map_test.go Outdated Show resolved Hide resolved
features/map_test.go Outdated Show resolved Hide resolved
features/map_test.go Outdated Show resolved Hide resolved
features/map.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@ti-mo ti-mo left a comment

Choose a reason for hiding this comment

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

This is getting in great shape! The error translation needs to be finished up now that we've worked through the design decisions, and with a negative test case this is good to go. 🚢

features/map_test.go Outdated Show resolved Hide resolved
features/map_test.go Outdated Show resolved Hide resolved
types.go Outdated Show resolved Hide resolved
features/map_test.go Outdated Show resolved Hide resolved
features/map.go Outdated Show resolved Hide resolved
features/map.go Outdated Show resolved Hide resolved
features/map.go Outdated Show resolved Hide resolved
features/map_test.go Outdated Show resolved Hide resolved
features/map_test.go Outdated Show resolved Hide resolved
features/map_test.go Outdated Show resolved Hide resolved
@ti-mo ti-mo marked this pull request as ready for review July 14, 2021 10:34
@ti-mo ti-mo changed the title draft: add ProbeMapType functionality MapType probe API Jul 14, 2021
@rgo3 rgo3 force-pushed the probemaps-poc branch 2 times, most recently from 50f9da2 to ef58877 Compare July 16, 2021 09:59
Copy link
Collaborator

@ti-mo ti-mo left a comment

Choose a reason for hiding this comment

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

Excellent! Just a few nits left!

features/map.go Outdated Show resolved Hide resolved
features/map.go Show resolved Hide resolved
features/map.go Outdated Show resolved Hide resolved
internal/unix/types_other.go Outdated Show resolved Hide resolved
types.go Outdated Show resolved Hide resolved
types.go Outdated Show resolved Hide resolved
features/map_test.go Outdated Show resolved Hide resolved
features/map_test.go Outdated Show resolved Hide resolved
features/map_test.go Outdated Show resolved Hide resolved
With this commit we add a new subpackage `features`. `features`
provides an API for calling processes to probe the kernel for available
BPF features. The first public API function added with this commit is
`HaveMapType(mt ebpf.MapType) error`, which allows to probe for
available BPF map types. The results of an API call are stored in an
internal cache, resulting in a probe being run at most once even if
called repeatedly.

Signed-off-by: Robin Gögge <r.goegge@outlook.com>
- Removed naked error comparison to ErrNotSupported (although valid)
- Converted error handling logic to switch statement so only a single case may fire.
  Before, it was possible to hit multiple cases if the error from BPFMapCreate
  contained multiple wrapped errors.
- Skipped wrapping of EPERM to avoid ending up with 'unexpected error during feature probe:
  operation not permitted'. Permission errors are not unexpected.

Signed-off-by: Timo Beckers <timo@isovalent.com>
Signed-off-by: Timo Beckers <timo@isovalent.com>
@ti-mo ti-mo merged commit e892d39 into cilium:master Jul 19, 2021
@rgo3 rgo3 mentioned this pull request Feb 9, 2022
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.

None yet

5 participants