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

Fix ProgramInfo.MapIDs for programs without maps on old kernels #905

Merged
merged 2 commits into from
Jan 23, 2023

Conversation

lmb
Copy link
Collaborator

@lmb lmb commented Jan 17, 2023

Fixes #535.

@lmb lmb force-pushed the prog-info-map-ids branch 3 times, most recently from 3c49107 to 8916621 Compare January 17, 2023 18:17
Currently, the (*ProgramInfo).MapIDs()'s bool return value is
determined by pi.ids != nil, pi.ids being allocated when
NrMapIds > 0. The NrMapIds field will always be zero on older
kernels that don't yet support it, so it's currently impossible
to tell if the prog actually references 0 maps, or whether
the kernel is too old to populate the field.

Fix this by adding a feature test.

Signed-off-by: Lorenz Bauer <oss@lmb.io>
Using the IsKernelLessThan helper means that kernel version comparisons
are checked against CI_MAX_KERNEL_VERSION. It's also less to type and
will give better output on failure.

Signed-off-by: Lorenz Bauer <oss@lmb.io>
err = sys.ObjInfo(prog, &sys.ProgInfo{
// NB: Don't need to allocate MapIds since the program isn't using
// any maps.
NrMapIds: 1,
Copy link
Collaborator

@ti-mo ti-mo Jan 23, 2023

Choose a reason for hiding this comment

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

Clever! Could also check NrMapIds == 0 here to skip the two err checks below. (or simply err == nil)

@lmb lmb merged commit 41d586f into cilium:master Jan 23, 2023
@lmb lmb deleted the prog-info-map-ids branch January 23, 2023 15:47
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.

ProgramInfo's MapIDs() bool returns false negatives
2 participants