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

Commit d30d42e0 authored by Martin KaFai Lau's avatar Martin KaFai Lau Committed by Alexei Starovoitov
Browse files

bpf: Change insn_offset to insn_off in bpf_func_info



The later patch will introduce "struct bpf_line_info" which
has member "line_off" and "file_off" referring back to the
string section in btf.  The line_"off" and file_"off"
are more consistent to the naming convention in btf.h that
means "offset" (e.g. name_off in "struct btf_type").

The to-be-added "struct bpf_line_info" also has another
member, "insn_off" which is the same as the "insn_offset"
in "struct bpf_func_info".  Hence, this patch renames "insn_offset"
to "insn_off" for "struct bpf_func_info".

Signed-off-by: default avatarMartin KaFai Lau <kafai@fb.com>
Acked-by: default avatarYonghong Song <yhs@fb.com>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 7337224f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2991,7 +2991,7 @@ struct bpf_flow_keys {
};

struct bpf_func_info {
	__u32	insn_offset;
	__u32	insn_off;
	__u32	type_id;
};

+9 −9
Original line number Diff line number Diff line
@@ -4707,24 +4707,24 @@ static int check_btf_func(struct bpf_prog *prog, struct bpf_verifier_env *env,
			goto free_btf;
		}

		/* check insn_offset */
		/* check insn_off */
		if (i == 0) {
			if (krecord[i].insn_offset) {
			if (krecord[i].insn_off) {
				verbose(env,
					"nonzero insn_offset %u for the first func info record",
					krecord[i].insn_offset);
					"nonzero insn_off %u for the first func info record",
					krecord[i].insn_off);
				ret = -EINVAL;
				goto free_btf;
			}
		} else if (krecord[i].insn_offset <= prev_offset) {
		} else if (krecord[i].insn_off <= prev_offset) {
			verbose(env,
				"same or smaller insn offset (%u) than previous func info record (%u)",
				krecord[i].insn_offset, prev_offset);
				krecord[i].insn_off, prev_offset);
			ret = -EINVAL;
			goto free_btf;
		}

		if (env->subprog_info[i].start != krecord[i].insn_offset) {
		if (env->subprog_info[i].start != krecord[i].insn_off) {
			verbose(env, "func_info BTF section doesn't match subprog layout in BPF program\n");
			ret = -EINVAL;
			goto free_btf;
@@ -4739,7 +4739,7 @@ static int check_btf_func(struct bpf_prog *prog, struct bpf_verifier_env *env,
			goto free_btf;
		}

		prev_offset = krecord[i].insn_offset;
		prev_offset = krecord[i].insn_off;
		urecord += urec_size;
	}

@@ -4762,7 +4762,7 @@ static void adjust_btf_func(struct bpf_verifier_env *env)
		return;

	for (i = 0; i < env->subprog_cnt; i++)
		env->prog->aux->func_info[i].insn_offset = env->subprog_info[i].start;
		env->prog->aux->func_info[i].insn_off = env->subprog_info[i].start;
}

/* check %cur's range satisfies %old's */