Make max packet size a runtime parameter#1073
Conversation
Add max_packet_size field to ebpf_verifier_options_t (default 65535) with a 1 GiB upper limit. Replace compile-time MAX_PACKET_SIZE and PTR_MAX constants with inline accessors that read from thread_local_options. Add --max-packet-size CLI argument. Fixes #738. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Elazar Gershuni <elazarg@gmail.com>
WalkthroughThis change makes the maximum packet size verifiable limit configurable rather than hardcoded to 65535 bytes, enabling verification in domains where packets exceed this size. Configuration is managed via a new CLI option and enforced through validation in the options object. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/crab/ebpf_domain.cpp`:
- Around line 352-353: The packet-size upper bound is currently exclusive,
making max_packet_size() effectively off-by-one; change the constraint in
inv.add_value_constraint(variable_registry->packet_size() < max_packet_size())
to use <= so packet_size() <= max_packet_size(), and apply the same inclusive
fix to the analogous data_end cap in src/crab/ebpf_transformer.cpp (replace the
strict < comparison against the max-packet-size bound with <=); ensure you
update the constraints that reference max_packet_size() and any helpers that
enforce the packet/data_end bound so the limit is inclusive.
In `@src/crab/ebpf_domain.hpp`:
- Around line 24-25: Add an explicit precondition for ptr_max() next to the
accessors: state in a short comment and/or assert that
thread_local_options.max_packet_size has been validated so that ptr_max() is
non-negative and that ptr_max() + max_packet_size() <=
std::numeric_limits<int32_t>::max(); e.g., annotate the inline int64_t ptr_max()
noexcept { ... } with a one-line soundness comment and an assertion (or
static/runtime check) that thread_local_options.max_packet_size is within the
expected bounds so callers can rely on ptr_max() >= 0 and no overflow when
adding max_packet_size().
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 4ead8822-18f6-4f34-a92a-f25fd715a761
📒 Files selected for processing (6)
src/config.hppsrc/crab/ebpf_checker.cppsrc/crab/ebpf_domain.cppsrc/crab/ebpf_domain.hppsrc/crab/ebpf_transformer.cppsrc/main.cpp
Summary
--max-packet-sizeCLI option (default 65535) backed by a field inebpf_verifier_options_t, with a 1 GiB upper limitMAX_PACKET_SIZEandPTR_MAXconstants with inline accessors that read fromthread_local_options, so they track the configured max packet sizeFixes #738.
Test plan
./bin/prevail --helpshows the new--max-packet-sizeoption🤖 Generated with Claude Code
Summary by CodeRabbit
--max-packet-sizecommand-line option to configure maximum packet size constraints (default: 65535 bytes). Enables users to customize verification limits within the range [1, 1073741824], with built-in validation for safe and valid configurations.