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

Put bpf2bpf caller in a named section #714

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dthaler
Copy link
Contributor

@dthaler dthaler commented Oct 2, 2024

Libbpf logic is that if there are multiple programs then any programs in the .text section are subprograms to be skipped when enumerating programs.

So update the sample to follow the convention that the non-subprogram is in a section other than ".text". This also enables testing the verifier's ability to load programs that call subprograms in another section.) is that if there are multiple programs then any programs in the .text section are subprograms to be skipped when enumerating programs.

So the sample was updated to follow the convention that the non-subprogram is in a section other than ".text", allowing testing the ability to load programs that call subprograms in another section. This PR updates the test accordingly and fixes a bug hit that prevented bpf2bpf calls across sections.

This PR needs vbpf/ebpf-samples#47 to be merged first.

Summary by CodeRabbit

  • New Features

    • Updated handling of function relocations for improved processing of eBPF program calls.
    • Added new test cases for eBPF program verification, including multithreading scenarios.
  • Bug Fixes

    • Simplified conditions for queuing function relocations, enhancing functionality.
  • Tests

    • Modified existing test cases to align with updated eBPF verification requirements.

Libbpf logic is that if there are multiple programs then any programs in the .text section
are subprograms to be skipped when enumerating programs.

So the sample was updated to follow the convention that the non-subprogram is in a section
other than ".text", allowing testing the ability to load programs that call subprograms in
another section.  This PR updates the test accordingly and fixes a bug
hit that prevented bpf2bpf calls across sections.

Signed-off-by: Dave Thaler <[email protected]>
Copy link

coderabbitai bot commented Oct 2, 2024

Walkthrough

The pull request includes updates to the eBPF samples subproject by changing the commit reference from 498d2f7ae80d8dcd0cc47defd4104c0901d1afa8 to aca16e72f39a1017a0782442081aaa379b58595b. Additionally, modifications were made to the ELF parsing logic in src/asm_files.cpp, simplifying the function relocation conditions. In src/test/test_verify.cpp, new test cases were added, and existing ones modified to reflect changes in eBPF program verification, including a shift in the expected section name for a program.

Changes

File Change Summary
ebpf-samples Updated subproject commit reference from 498d2f7ae80d8dcd0cc47defd4104c0901d1afa8 to aca16e72f39a1017a0782442081aaa379b58595b.
src/asm_files.cpp Simplified handling of function relocations in ELF parsing logic by removing the symbol section match requirement.
src/test/test_verify.cpp Added new test cases and modified existing ones; updated TEST_PROGRAM macro to change section name from ".text" to "test" for "func" in "bpf2bpf.o".

Possibly related PRs

  • Support bpf2bpf calls from ELF files #693: This PR modifies the src/asm_files.cpp file, enhancing the handling of function relocations, which is directly related to the changes in the main PR that also involves updates to the subproject commit reference affecting ELF file processing.
  • Cleanup asm_files.cpp #694: This PR includes updates to the src/asm_files.cpp file, specifically refining function signatures and improving code clarity, which may relate to the overall structure and handling of ELF files in the main PR.
  • Use gsl::narrow in asm files #710: This PR focuses on enhancing type safety in src/asm_files.cpp, which is relevant to the changes in the main PR that involve updates to the handling of ELF files and function relocations.

🐇 In the land of code, where the bunnies play,
We hop through the changes, come join the fray!
With functions relocated and tests all anew,
Our eBPF programs are ready for you!
So leap with delight, let the updates unfold,
In the world of eBPF, our stories are told! 🐰✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range comments (1)
src/asm_files.cpp (1)

Line range hint 422-426: Consider the implications of removing the symbol section match in function relocation

By simplifying the condition to queue function relocations without checking if the symbol's section matches the current section, function calls to symbols in different sections will now be queued for relocation. Ensure that the relocation logic and subsequent handling correctly process cross-section function calls to prevent potential issues.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 00683a5 and f46ee71.

📒 Files selected for processing (3)
  • ebpf-samples (1 hunks)
  • src/asm_files.cpp (1 hunks)
  • src/test/test_verify.cpp (1 hunks)
🔇 Additional comments (2)
ebpf-samples (1)

1-1: LGTM! Verify submodule commit hash.

The submodule reference has been updated as expected. This change is crucial for implementing the modifications described in the PR objectives, specifically moving non-subprograms to sections other than ".text".

Please ensure that this new commit hash (aca16e72f39a1017a0782442081aaa379b58595b) corresponds to the merged state of the dependent PR (vbpf/ebpf-samples#47).

To verify the commit hash and its relationship to the dependent PR, you can run the following script:

This script will help verify that the submodule is at the correct commit and provide information to manually check its relationship to the dependent PR.

src/test/test_verify.cpp (1)

504-504: Update to test case for bpf2bpf calls across sections

The test case has been modified to use the "test" section instead of ".text" for the "func" program in "bpf2bpf.o". This change aligns with the PR objectives, which mention moving the non-subprogram to a section other than ".text" to facilitate testing the verifier's capability to load programs that invoke subprograms located in different sections.

To ensure this change is consistent with the rest of the codebase, let's verify if there are any other occurrences of "bpf2bpf.o" that might need similar updates:

✅ Verification successful

Verification Complete: All Relevant Test Cases Addressed

The update to use the "test" section for the func program in bpf2bpf.o is consistent with the test suite. The existing test cases appropriately differentiate between successful and failing verification scenarios by using distinct sections.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other occurrences of "bpf2bpf.o" in the codebase
rg "bpf2bpf\.o"

Length of output: 273

@coveralls
Copy link

Coverage Status

coverage: 90.328% (-0.07%) from 90.394%
when pulling f46ee71 on dthaler:bpf2bpf-sections
into 00683a5 on vbpf:main.

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