Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9a18eedb authored by Jakub Kicinski's avatar Jakub Kicinski Committed by Daniel Borkmann
Browse files

bpf: offload: don't use prog->aux->offload as boolean



We currently use aux->offload to indicate that program is bound
to a specific device.  This forces us to keep the offload structure
around even after the device is gone.  Add a bool member to
struct bpf_prog_aux to indicate if offload was requested.

Suggested-by: default avatarAlexei Starovoitov <ast@kernel.org>
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: default avatarQuentin Monnet <quentin.monnet@netronome.com>
Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
parent e0d3974a
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -201,6 +201,7 @@ struct bpf_prog_aux {
	u32 stack_depth;
	u32 id;
	u32 func_cnt;
	bool offload_requested;
	struct bpf_prog **func;
	void *jit_data; /* JIT specific data. arch dependent */
	struct latch_tree_node ksym_tnode;
@@ -529,7 +530,7 @@ int bpf_prog_offload_init(struct bpf_prog *prog, union bpf_attr *attr);

static inline bool bpf_prog_is_dev_bound(struct bpf_prog_aux *aux)
{
	return aux->offload;
	return aux->offload_requested;
}
#else
static inline int bpf_prog_offload_init(struct bpf_prog *prog,
+3 −1
Original line number Diff line number Diff line
@@ -1157,6 +1157,8 @@ static int bpf_prog_load(union bpf_attr *attr)
	if (!prog)
		return -ENOMEM;

	prog->aux->offload_requested = !!attr->prog_ifindex;

	err = security_bpf_prog_alloc(prog->aux);
	if (err)
		goto free_prog_nouncharge;
@@ -1178,7 +1180,7 @@ static int bpf_prog_load(union bpf_attr *attr)
	atomic_set(&prog->aux->refcnt, 1);
	prog->gpl_compatible = is_gpl ? 1 : 0;

	if (attr->prog_ifindex) {
	if (bpf_prog_is_dev_bound(prog->aux)) {
		err = bpf_prog_offload_init(prog, attr);
		if (err)
			goto free_prog;