提交 a40a2632 编写于 作者: Q Quentin Monnet 提交者: Alexei Starovoitov

bpf: pass prog instead of env to bpf_prog_offload_verifier_prep()

Function bpf_prog_offload_verifier_prep(), called from the kernel BPF
verifier to run a driver-specific callback for preparing for the
verification step for offloaded programs, takes a pointer to a struct
bpf_verifier_env object. However, no driver callback needs the whole
structure at this time: the two drivers supporting this, nfp and
netdevsim, only need a pointer to the struct bpf_prog instance held by
env.

Update the callback accordingly, on kernel side and in these two
drivers.
Signed-off-by: NQuentin Monnet <quentin.monnet@netronome.com>
Reviewed-by: NJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
上级 eb911947
...@@ -183,10 +183,9 @@ static void nfp_prog_free(struct nfp_prog *nfp_prog) ...@@ -183,10 +183,9 @@ static void nfp_prog_free(struct nfp_prog *nfp_prog)
} }
static int static int
nfp_bpf_verifier_prep(struct net_device *netdev, struct bpf_verifier_env *env) nfp_bpf_verifier_prep(struct net_device *netdev, struct bpf_prog *prog)
{ {
struct nfp_net *nn = netdev_priv(netdev); struct nfp_net *nn = netdev_priv(netdev);
struct bpf_prog *prog = env->prog;
struct nfp_app *app = nn->app; struct nfp_app *app = nn->app;
struct nfp_prog *nfp_prog; struct nfp_prog *nfp_prog;
int ret; int ret;
......
...@@ -259,14 +259,14 @@ static int nsim_bpf_create_prog(struct netdevsim *ns, struct bpf_prog *prog) ...@@ -259,14 +259,14 @@ static int nsim_bpf_create_prog(struct netdevsim *ns, struct bpf_prog *prog)
} }
static int static int
nsim_bpf_verifier_prep(struct net_device *dev, struct bpf_verifier_env *env) nsim_bpf_verifier_prep(struct net_device *dev, struct bpf_prog *prog)
{ {
struct netdevsim *ns = netdev_priv(dev); struct netdevsim *ns = netdev_priv(dev);
if (!ns->bpf_bind_accept) if (!ns->bpf_bind_accept)
return -EOPNOTSUPP; return -EOPNOTSUPP;
return nsim_bpf_create_prog(ns, env->prog); return nsim_bpf_create_prog(ns, prog);
} }
static int nsim_bpf_translate(struct net_device *dev, struct bpf_prog *prog) static int nsim_bpf_translate(struct net_device *dev, struct bpf_prog *prog)
......
...@@ -268,7 +268,7 @@ struct bpf_prog_offload_ops { ...@@ -268,7 +268,7 @@ struct bpf_prog_offload_ops {
int (*insn_hook)(struct bpf_verifier_env *env, int (*insn_hook)(struct bpf_verifier_env *env,
int insn_idx, int prev_insn_idx); int insn_idx, int prev_insn_idx);
int (*finalize)(struct bpf_verifier_env *env); int (*finalize)(struct bpf_verifier_env *env);
int (*prepare)(struct net_device *netdev, struct bpf_verifier_env *env); int (*prepare)(struct net_device *netdev, struct bpf_prog *prog);
int (*translate)(struct net_device *netdev, struct bpf_prog *prog); int (*translate)(struct net_device *netdev, struct bpf_prog *prog);
void (*destroy)(struct bpf_prog *prog); void (*destroy)(struct bpf_prog *prog);
}; };
......
...@@ -245,7 +245,7 @@ static inline struct bpf_reg_state *cur_regs(struct bpf_verifier_env *env) ...@@ -245,7 +245,7 @@ static inline struct bpf_reg_state *cur_regs(struct bpf_verifier_env *env)
return cur_func(env)->regs; return cur_func(env)->regs;
} }
int bpf_prog_offload_verifier_prep(struct bpf_verifier_env *env); int bpf_prog_offload_verifier_prep(struct bpf_prog *prog);
int bpf_prog_offload_verify_insn(struct bpf_verifier_env *env, int bpf_prog_offload_verify_insn(struct bpf_verifier_env *env,
int insn_idx, int prev_insn_idx); int insn_idx, int prev_insn_idx);
int bpf_prog_offload_finalize(struct bpf_verifier_env *env); int bpf_prog_offload_finalize(struct bpf_verifier_env *env);
......
...@@ -123,15 +123,15 @@ int bpf_prog_offload_init(struct bpf_prog *prog, union bpf_attr *attr) ...@@ -123,15 +123,15 @@ int bpf_prog_offload_init(struct bpf_prog *prog, union bpf_attr *attr)
return err; return err;
} }
int bpf_prog_offload_verifier_prep(struct bpf_verifier_env *env) int bpf_prog_offload_verifier_prep(struct bpf_prog *prog)
{ {
struct bpf_prog_offload *offload; struct bpf_prog_offload *offload;
int ret = -ENODEV; int ret = -ENODEV;
down_read(&bpf_devs_lock); down_read(&bpf_devs_lock);
offload = env->prog->aux->offload; offload = prog->aux->offload;
if (offload) if (offload)
ret = offload->offdev->ops->prepare(offload->netdev, env); ret = offload->offdev->ops->prepare(offload->netdev, prog);
offload->dev_state = !ret; offload->dev_state = !ret;
up_read(&bpf_devs_lock); up_read(&bpf_devs_lock);
......
...@@ -6368,7 +6368,7 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr) ...@@ -6368,7 +6368,7 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr)
goto skip_full_check; goto skip_full_check;
if (bpf_prog_is_dev_bound(env->prog->aux)) { if (bpf_prog_is_dev_bound(env->prog->aux)) {
ret = bpf_prog_offload_verifier_prep(env); ret = bpf_prog_offload_verifier_prep(env->prog);
if (ret) if (ret)
goto skip_full_check; goto skip_full_check;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
新手
引导
客服 返回
顶部