diff options
author | Quentin Monnet <quentin.monnet@netronome.com> | 2018-01-23 11:22:55 -0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-01-23 20:24:31 -0500 |
commit | 9045bdc8ed4e4e2c713d8d38bda9aa506b4bd8c5 (patch) | |
tree | 93d80e1de32bdc2ab90e193d79bf8d2ccdcf1bf6 /drivers/net/netdevsim/bpf.c | |
parent | 7c5db7e7292f7f3244f895e7fa301dcff647e07e (diff) | |
download | blackbird-obmc-linux-9045bdc8ed4e4e2c713d8d38bda9aa506b4bd8c5.tar.gz blackbird-obmc-linux-9045bdc8ed4e4e2c713d8d38bda9aa506b4bd8c5.zip |
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>
Diffstat (limited to 'drivers/net/netdevsim/bpf.c')
-rw-r--r-- | drivers/net/netdevsim/bpf.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/net/netdevsim/bpf.c b/drivers/net/netdevsim/bpf.c index 940c63eeebf9..8166f121bbcc 100644 --- a/drivers/net/netdevsim/bpf.c +++ b/drivers/net/netdevsim/bpf.c @@ -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; } |