mirror of
https://github.com/torvalds/linux.git
synced 2026-04-26 18:42:25 -04:00
selftests/bpf: check bpf verifier log buffer usage works for HW offload
Make netdevsim print a message to the BPF verifier log buffer when a
program is offloaded.
Then use this message in hardware offload selftests to make sure that
using this buffer actually prints the message to the console for
eBPF hardware offload.
The message is appended after the last instruction is processed with the
verifying function from netdevsim. Output looks like the following:
$ tc filter add dev foo ingress bpf obj sample_ret0.o \
sec .text verbose skip_sw
Prog section '.text' loaded (5)!
- Type: 3
- Instructions: 2 (0 over limit)
- License:
Verifier analysis:
0: (b7) r0 = 0
1: (95) exit
[netdevsim] Hello from netdevsim!
processed 2 insns, stack depth 0
"verbose" flag is required to see it in the console since netdevsim does
not throw an error after printing the message.
Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
7c5db7e729
commit
9045bdc8ed
@@ -23,6 +23,9 @@
|
||||
|
||||
#include "netdevsim.h"
|
||||
|
||||
#define pr_vlog(env, fmt, ...) \
|
||||
bpf_verifier_log_write(env, "[netdevsim] " fmt, ##__VA_ARGS__)
|
||||
|
||||
struct nsim_bpf_bound_prog {
|
||||
struct netdevsim *ns;
|
||||
struct bpf_prog *prog;
|
||||
@@ -77,6 +80,9 @@ nsim_bpf_verify_insn(struct bpf_verifier_env *env, int insn_idx, int prev_insn)
|
||||
if (state->ns->bpf_bind_verifier_delay && !insn_idx)
|
||||
msleep(state->ns->bpf_bind_verifier_delay);
|
||||
|
||||
if (insn_idx == env->prog->len - 1)
|
||||
pr_vlog(env, "Hello from netdevsim!\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user