Skip to contentSkip to conversation

bpf: Get the program type by resolve_prog_type() directly

PATCH In review Wenli Xie 2 participants 2 messages Nov 13, 2023 BPF

lore
Share & tools
lore

Wenli Xie

author
#0 lore raw

PATCH 1/1 bpf: Get the program type by resolve_prog_type() directly

From: Wenli Xie <[email protected]>

The bpf program type can be get by resolve_prog_type() directly.

---
 kernel/bpf/btf.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
kernel/bpf/btf.c +1 -3
index 15d71d2986d3..b8ac96906bc5 100644
@@ -6963,7 +6963,7 @@ int btf_prepare_func_args(struct bpf_verifier_env *env, int subprog,
 {
 	struct bpf_verifier_log *log = &env->log;
 	struct bpf_prog *prog = env->prog;
-	enum bpf_prog_type prog_type = prog->type;
+	enum bpf_prog_type prog_type = resolve_prog_type(env->prog);
 	struct btf *btf = prog->aux->btf;
 	const struct btf_param *args;
 	const struct btf_type *t, *ref_t;
@@ -7001,8 +7001,6 @@ int btf_prepare_func_args(struct bpf_verifier_env *env, int subprog,
 		bpf_log(log, "Verifier bug in function %s()\n", tname);
 		return -EFAULT;
 	}
-	if (prog_type == BPF_PROG_TYPE_EXT)
-		prog_type = prog->aux->dst_prog->type;
 
 	t = btf_type_by_id(btf, t->type);
 	if (!t || !btf_type_is_func_proto(t)) {
Signature · 1 line
2.34.1
#1 lore raw
Quoted 3 lines · Wenli Xie

From: Wenli Xie <[email protected]>

The bpf program type can be get by resolve_prog_type() directly.

Can we have more details in the change log about why using resolve_prog_type is better?

Please also take a look at Documentation/bpf/bpf_devel_QA.rst on how to target the right tree ([PATCH bpf-next]).