Re: [PATCH bpf-next 1/8] bpf: refactor BPF_PSEUDO_CALL checking as a helper function
From: Alexei Starovoitov <hidden>
Date: 2021-02-05 06:01:02
On Thu, Feb 04, 2021 at 03:48:27PM -0800, Yonghong Song wrote:
quoted hunk ↗ jump to hunk
There is no functionality change. This refactoring intends to facilitate next patch change with BPF_PSEUDO_FUNC. Signed-off-by: Yonghong Song <redacted> --- kernel/bpf/verifier.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-)diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 5e09632efddb..db294b75d03b 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c@@ -228,6 +228,12 @@ static void bpf_map_key_store(struct bpf_insn_aux_data *aux, u64 state) (poisoned ? BPF_MAP_KEY_POISON : 0ULL); } +static bool bpf_pseudo_call(const struct bpf_insn *insn) +{ + return insn->code == (BPF_JMP | BPF_CALL) && + insn->src_reg == BPF_PSEUDO_CALL; +} + struct bpf_call_arg_meta { struct bpf_map *map_ptr; bool raw_mode;@@ -1486,9 +1492,7 @@ static int check_subprogs(struct bpf_verifier_env *env) /* determine subprog starts. The end is one before the next starts */ for (i = 0; i < insn_cnt; i++) { - if (insn[i].code != (BPF_JMP | BPF_CALL)) - continue; - if (insn[i].src_reg != BPF_PSEUDO_CALL) + if (!bpf_pseudo_call(insn + i))
Nice cleanup! I've applied this patch from the set.