Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Alan Jowett <[email protected]>
  • Loading branch information
Alan Jowett committed Nov 7, 2024
1 parent 7f0b1bb commit 03c3d74
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
21 changes: 18 additions & 3 deletions src/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,37 @@
#include "crab/cfg.hpp"

struct ebpf_verifier_options_t {
// Options that control how the control flow graph is built.
prepare_cfg_options cfg_opts;

// True to assume prior failed assertions are true and continue verification.
bool assume_assertions = false;
bool print_invariants = false;
bool print_failures = false;

// False to use actual map fd's, true to use mock fd's.
bool mock_map_fds = true;

// True to do additional checks for some things that would fail at runtime.
bool strict = false;

bool print_line_info = false;
// True to allow division by zero and assume BPF ISA defined semantics.
bool allow_division_by_zero = true;

// Setup the entry constraints for a BPF program.
bool setup_constraints = true;

// True if the ELF file is built on a big endian system.
bool big_endian = false;

// Print the invariants for each basic block.
bool print_invariants = false;

// Print failures that occur during verification.
bool print_failures = false;

// When printing the control flow graph, print the line number of each instruction.
bool print_line_info = false;

// Print the BTF types in JSON format.
bool dump_btf_types_json = false;
};

Expand Down
2 changes: 1 addition & 1 deletion src/crab/cfg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ struct prepare_cfg_options {
bool must_have_exit = true;
};

cfg_t prepare_cfg(const InstructionSeq& prog, const program_info& info, const prepare_cfg_options& options = {});
cfg_t prepare_cfg(const InstructionSeq& prog, const program_info& info, const prepare_cfg_options& options);

void explicate_assertions(cfg_t& cfg, const program_info& info);
std::vector<Assert> get_assertions(Instruction ins, const program_info& info, const std::optional<label_t>& label);
Expand Down
4 changes: 2 additions & 2 deletions src/test/ebpf_yaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ static InstructionSeq raw_cfg_to_instruction_seq(const vector<std::tuple<string,
}

static ebpf_verifier_options_t raw_options_to_options(const std::set<string>& raw_options) {
ebpf_verifier_options_t options;
ebpf_verifier_options_t options{};

// Use ~simplify for YAML tests unless otherwise specified.
options.cfg_opts.simplify = false;
Expand Down Expand Up @@ -355,7 +355,7 @@ ConformanceTestResult run_conformance_test_case(const std::vector<std::byte>& me

auto& prog = std::get<InstructionSeq>(prog_or_error);

ebpf_verifier_options_t options;
ebpf_verifier_options_t options{};
if (debug) {
print(prog, std::cout, {});
options.print_failures = true;
Expand Down
2 changes: 1 addition & 1 deletion src/test/ebpf_yaml.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

struct TestCase {
std::string name;
ebpf_verifier_options_t options;
ebpf_verifier_options_t options{};
string_invariant assumed_pre_invariant;
InstructionSeq instruction_seq;
string_invariant expected_post_invariant;
Expand Down
4 changes: 2 additions & 2 deletions src/test/test_verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,15 +598,15 @@ TEST_CASE("multithreading", "[verify][multithreading]") {
auto prog_or_error1 = unmarshal(raw_prog1);
auto prog1 = std::get_if<InstructionSeq>(&prog_or_error1);
REQUIRE(prog1 != nullptr);
const cfg_t cfg1 = prepare_cfg(*prog1, raw_prog1.info);
const cfg_t cfg1 = prepare_cfg(*prog1, raw_prog1.info, {});

auto raw_progs2 = read_elf("ebpf-samples/bpf_cilium_test/bpf_netdev.o", "2/2", {}, &g_ebpf_platform_linux);
REQUIRE(raw_progs2.size() == 1);
raw_program raw_prog2 = raw_progs2.back();
auto prog_or_error2 = unmarshal(raw_prog2);
auto prog2 = std::get_if<InstructionSeq>(&prog_or_error2);
REQUIRE(prog2 != nullptr);
const cfg_t cfg2 = prepare_cfg(*prog2, raw_prog2.info);
const cfg_t cfg2 = prepare_cfg(*prog2, raw_prog2.info, {});

bool res1, res2;
std::thread a(test_analyze_thread, &cfg1, &raw_prog1.info, &res1);
Expand Down

0 comments on commit 03c3d74

Please sign in to comment.