Skip to content

Commit

Permalink
chore: Don't use bpf_core_enum_value_exists for detecting bpf_loop
Browse files Browse the repository at this point in the history
We already have a more reliable `FEATURE_BPF_LOOP` check for that.
  • Loading branch information
vadorovsky committed May 28, 2024
1 parent 7a0226f commit cdeebb3
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions crates/bpf-builder/include/loop.bpf.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,7 @@
// function seems to cause issues.
#ifdef FEATURE_BPF_LOOP
#define LOOP(max_iterations, max_unroll, callback_fn, ctx) \
if (bpf_core_enum_value_exists(enum bpf_func_id, BPF_FUNC_loop)) { \
bpf_loop(max_iterations, callback_fn, ctx, 0); \
} else { \
_Pragma("unroll") for (int i = 0; i < max_unroll; i++) { \
if (callback_fn(i, ctx) == LOOP_STOP) \
break; \
} \
}
bpf_loop(max_iterations, callback_fn, ctx, 0);
#else
// On kernel <= 5.13 taking the address of a function results in a verifier
// error, even if inside a dead-code elimination branch.
Expand Down

0 comments on commit cdeebb3

Please sign in to comment.