Skip to content

Propogate ebpf_verifier_options_t to thread_local_options#856

Merged
elazarg merged 2 commits into
vbpf:mainfrom
Alan-Jowett:issue855
Apr 2, 2025
Merged

Propogate ebpf_verifier_options_t to thread_local_options#856
elazarg merged 2 commits into
vbpf:mainfrom
Alan-Jowett:issue855

Conversation

@Alan-Jowett
Copy link
Copy Markdown
Contributor

@Alan-Jowett Alan-Jowett commented Apr 1, 2025

Resolves: #855

When invoked from check.exe, the verifier was running inconsistent values for ebpf_verifier_options_t, specifically the check_for_termination check option. Program::from_sequence was running with check_for_termination = true and analyze was running with check_for_termination = false. The result is that check.exe would never correctly handle the termination check case.

The fix is to set thread_local_options in Program::from_sequence so that it is consistently used throughout the verifer.

Summary by CodeRabbit

  • Refactor
    • Improved internal configuration management to enhance consistency and streamline how core options are processed.
  • Tests
    • Updated test cases to align with the revised configuration handling, ensuring robust and reliable validation.

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 1, 2025

Walkthrough

The changes refactor the options parameter passed to the Program::from_sequence method throughout the codebase. The method signature has been updated to accept an ebpf_verifier_options_t instead of the previous prepare_cfg_options. Consequently, the way options are accessed has been modified, including assigning the new options to a thread-local variable. Similar updates have been made in several call sites and macro definitions affecting checks and tests.

Changes

File(s) Change Summary
src/asm_cfg.cpp, src/program.hpp Updated the signature of Program::from_sequence by changing the parameter type from prepare_cfg_options to ebpf_verifier_options_t, updated options access (.cfg_opts → direct use), and added an assignment to thread_local_options.
src/main/check.cpp, src/test/ebpf_yaml.cpp, src/test/test_verify.cpp Modified invocations of Program::from_sequence to pass the full ebpf_verifier_options_t instead of the cfg_opts subset; updated macro usage and test cases accordingly.

Assessment against linked issues

Objective (Linked Issues) Addressed Explanation
The thread_local_options variable is never populated (#855)

Possibly related PRs


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 632c125 and 894ab61.

📒 Files selected for processing (5)
  • src/asm_cfg.cpp (1 hunks)
  • src/main/check.cpp (2 hunks)
  • src/program.hpp (1 hunks)
  • src/test/ebpf_yaml.cpp (2 hunks)
  • src/test/test_verify.cpp (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
src/test/ebpf_yaml.cpp (1)
Learnt from: dthaler
PR: vbpf/ebpf-verifier#721
File: src/ebpf_yaml.cpp:327-329
Timestamp: 2025-04-01T19:48:21.027Z
Learning: In `src/ebpf_yaml.cpp`, avoid suggesting changes to error handling code in the `run_conformance_test_case` function if the code is not modified in the current PR.
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: build_windows (Debug, tests)
  • GitHub Check: build_windows (Release, tests)
  • GitHub Check: build_windows (Debug, library)
  • GitHub Check: build_windows (Release, library)
  • GitHub Check: build_ubuntu (Debug, tests)
  • GitHub Check: build_ubuntu (Release, tests)
  • GitHub Check: build_ubuntu (Debug)
  • GitHub Check: build_ubuntu (Release)
  • GitHub Check: Analyze (cpp)
🔇 Additional comments (11)
src/main/check.cpp (2)

242-242: Updated parameter to pass entire options structure

Changed from passing only ebpf_verifier_options.cfg_opts to passing the complete ebpf_verifier_options structure, aligning with the method signature change in Program::from_sequence.


280-280: Updated parameter to pass entire options structure

Changed from passing only ebpf_verifier_options.cfg_opts to passing the complete ebpf_verifier_options structure, aligning with the method signature change in Program::from_sequence.

src/test/ebpf_yaml.cpp (2)

248-248: Updated parameter to pass entire options structure

Changed from passing only test_case.options.cfg_opts to passing the complete test_case.options structure, consistent with the method signature change in Program::from_sequence.


367-367: Updated parameter to pass entire options structure

Changed from passing only options.cfg_opts to passing the complete options structure, consistent with the method signature change in Program::from_sequence.

src/program.hpp (1)

56-56: Updated method signature to accept the complete options structure

Changed the parameter type from const prepare_cfg_options& options to const ebpf_verifier_options_t& options. This change enables the method to access all options instead of just the configuration subset, ensuring consistent behavior with the analyze function.

src/test/test_verify.cpp (2)

44-44: Updated parameter to pass entire options structure

Changed from passing only thread_local_options.cfg_opts to passing the complete thread_local_options structure, consistent with the method signature change in Program::from_sequence.


51-65: Updated parameter and reformatted macro

Changed from passing only thread_local_options.cfg_opts to passing the complete thread_local_options structure, consistent with the method signature change in Program::from_sequence. The macro was also reformatted, but with no functional changes beyond the parameter update.

src/asm_cfg.cpp (4)

292-293: Method signature updated to use ebpf_verifier_options_t

The function now accepts the full verifier options struct instead of just the cfg options, which ensures consistency in options handling across the codebase.


295-295: Thread-local options assignment added

This is the key change that addresses the inconsistency issue mentioned in the PR objectives. The verifier options are now stored in thread_local_options, ensuring options like check_for_termination are consistent across the verification process.


298-298: Updated options access pattern

Access pattern updated to match the new parameter type structure. This maintains the same functionality while using the new options structure.


303-303: Consistent check_for_termination option access

This change addresses the specific issue mentioned in the PR objectives where the check_for_termination option was inconsistently applied. The options are now accessed from the same source throughout the verification process.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

@coveralls
Copy link
Copy Markdown

coveralls commented Apr 1, 2025

Coverage Status

coverage: 88.177%. remained the same
when pulling ab247f4 on Alan-Jowett:issue855
into c70f415 on vbpf:main.

@elazarg elazarg merged commit f489bb4 into vbpf:main Apr 2, 2025
@Alan-Jowett Alan-Jowett deleted the issue855 branch February 10, 2026 17:06
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.

The thread_local_options variable is never populated

3 participants