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

program: set name from object info for pinned file #932

Merged
merged 1 commit into from
Feb 20, 2023
Merged

program: set name from object info for pinned file #932

merged 1 commit into from
Feb 20, 2023

Conversation

aibor
Copy link
Contributor

@aibor aibor commented Feb 9, 2023

When loading a program from a pinned file, the program name is set from the file name instead from the object info.

This commit adds a test that expects the program name to be set from the object info and changes the procedure to set the name from the object info, which is present already and used to set the program type.

Signed-off-by: Tobias Böhm code@aibor.de

prog.go Outdated
@@ -783,7 +782,7 @@ func LoadPinnedProgram(fileName string, opts *LoadPinOptions) (*Program, error)
return nil, fmt.Errorf("info for %s: %w", fileName, err)
}

return &Program{"", fd, filepath.Base(fileName), fileName, info.Type}, nil
return &Program{"", fd, info.Name, fileName, info.Type}, nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this would leave > 4.11 && < 4.15 without a name. Maybe keep filepath.Base if !haveProgName()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. I changed my patch to check for the necessary feature and fall back to the file base name, just as before.

When loading a program from a pinned file, the program name is set from
the file name instead from the object info.

This commit changes the procedure of setting the program name from the
object info in case the feature is supported. It also adds tests for
both support cases.

Signed-off-by: Tobias Böhm <code@aibor.de>
@aibor aibor requested a review from lmb February 17, 2023 15:57
@lmb lmb merged commit a2fe5d4 into cilium:master Feb 20, 2023
@lmb
Copy link
Collaborator

lmb commented Feb 20, 2023

Thanks :)

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.

2 participants