-
Notifications
You must be signed in to change notification settings - Fork 652
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
elf_reader: emit UnspecifiedProgram
s into CollectionSpec
#529
Conversation
UnspecifiedProgram
s into CollectionSpec
@@ -286,7 +286,11 @@ func NewCollectionWithOptions(spec *CollectionSpec, opts CollectionOptions) (*Co | |||
} | |||
} | |||
|
|||
for progName := range spec.Programs { | |||
for progName, prog := range spec.Programs { | |||
if prog.Type == UnspecifiedProgram { |
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 feel like this would be the expected behaviour, and should keep things backwards-compatible. Instead of filtering UnspecifiedProgram
s out of the CollectionSpec
, filter them out on their way into the kernel.
Any other ideas to accomplish this?
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.
Hmm. What happens if a prog array points at an UnspecifiedProgram?
Seems OK on the surface.
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.
Probably worth documenting this.
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 lazy-loader doesn't take this code path afaik, but the kernel should complain about an invalid program. Good point, will investigate.
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.
FWIW I think returning an error when a programarray references unspecifiedprogram is OK.
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've added an explicit UnspecifiedProgram
check to (collectionLoader).loadProgram()
since there's not much point in trying to let the kernel load these progs. An explicit check also prevents possible dependent maps etc. from getting lazy-loaded, so some work is saved overall.
I've tested putting btf_map_init.c
's tail_main()
into .text, and it turns out this check isn't tripped currently, since loadProgram()
operates on cs.Programs
, which .text is not allowed to emit programs into. Maybe in a future patch it will, or into a cs.Functions
field, etc. but in the meantime I think it doesn't hurt to have the check there.
@@ -286,7 +286,11 @@ func NewCollectionWithOptions(spec *CollectionSpec, opts CollectionOptions) (*Co | |||
} | |||
} | |||
|
|||
for progName := range spec.Programs { | |||
for progName, prog := range spec.Programs { | |||
if prog.Type == UnspecifiedProgram { |
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.
Hmm. What happens if a prog array points at an UnspecifiedProgram?
Seems OK on the surface.
eBPF programs emitted to sections with unknown prefixes were previously withheld from CollectionSpec.Programs. Add a ProgramSpec.SectionName field to allow the caller to determine (Attach)Type manually, and include all programs that were explicitly assigned to an ELF section. Signed-off-by: Timo Beckers <timo@isovalent.com>
c839981
to
b5b96a6
Compare
eBPF programs emitted to sections with unknown prefixes were previously withheld from CollectionSpec.Programs. Add a ProgramSpec.SectionName field to allow the caller to determine (Attach)Type manually, and include all programs that were explicitly assigned to an ELF section.