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

libbpf-rs: Few changes to recent patches #336

Merged
merged 2 commits into from
Jan 26, 2023
Merged

libbpf-rs: Few changes to recent patches #336

merged 2 commits into from
Jan 26, 2023

Conversation

danielocfb
Copy link
Collaborator

@danielocfb danielocfb commented Jan 26, 2023

This patch changes a few nuisances from recent pull requests:

  • Rename Linker::add() to add_file to follow libbpf naming more
    closely (I still kept Linker::link() (as opposed to finalize)) as it
    seems apt.
  • Fix SEC used in test_skeleton_builder_deterministic. The program
    would no longer load with libbpf 1.0.
  • Use vmlinux.h instead of <linux/bpf.h> for consistency with other
    skeletons.

Signed-off-by: Daniel Müller [email protected]

Copy link
Member

@anakryiko anakryiko left a comment

Choose a reason for hiding this comment

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

so this concern about failed linking step and maybe (in the future) still needing linker instance makes sense. Let's not make .link() take self and keep it as is. On libbpf side, calling bpf_linker__add_file after bpf_linker__finalize will keep returning -EINVAL, so no corruption or anything like that will happen.

Other than that, LGTM.

@danielocfb
Copy link
Collaborator Author

so this concern about failed linking step and maybe (in the future) still needing linker instance makes sense. Let's not make .link() take self and keep it as is. On libbpf side, calling bpf_linker__add_file after bpf_linker__finalize will keep returning -EINVAL, so no corruption or anything like that will happen.

Sounds good. I reverted that part of the change. An alternative would be to include self in the error variant that we return. I did not want to do that as it makes working with the method more cumbersome (because in addition to the instance we also get the actual error, but now we no longer can just propagate errors with ?, for example), but it is what some other consuming Rust APIs do on error (and mostly if they do not have to include an additional error message).

With Rust 1.67 clippy warns about us not inlining some variables in
format strings in some locations. Follow the suggestions mostly, except
where we are dealing with large code blocks that already contain curly
braces.

Signed-off-by: Daniel Müller <[email protected]>
This patch changes a few nuisances from recent pull requests:
- Rename `Linker::add()` to `add_file` to follow libbpf naming more
  closely (I still kept `Linker::link()` (as opposed to finalize)) as it
  seems apt.
- Fix `SEC` used in `test_skeleton_builder_deterministic`. The program
  would no longer load with libbpf 1.0.
- Use `vmlinux.h` instead of `<linux/bpf.h>` for consistency with other
  skeletons.

Signed-off-by: Daniel Müller <[email protected]>
@danielocfb
Copy link
Collaborator Author

Rebased against #334. Will merge once everything is green.

@danielocfb danielocfb merged commit a7045ac into libbpf:master Jan 26, 2023
@danielocfb danielocfb deleted the topic/fixes branch January 26, 2023 19:42
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