nfp: bpf: fix check of program max insn count

NFP program allocation length is in bytes and NFP program length
is in instructions, fix the comparison of the two.

Fixes: 9314c442d7 ("nfp: bpf: move translation prepare to offload.c")
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Jiong Wang <jiong.wang@netronome.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
Jakub Kicinski 2018-03-23 20:00:13 -07:00 committed by Alexei Starovoitov
parent 4b6eca9d68
commit e8a4796ee2

View file

@ -74,7 +74,9 @@ nfp_meta_has_prev(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)
static void nfp_prog_push(struct nfp_prog *nfp_prog, u64 insn)
{
if (nfp_prog->__prog_alloc_len == nfp_prog->prog_len) {
if (nfp_prog->__prog_alloc_len / sizeof(u64) == nfp_prog->prog_len) {
pr_warn("instruction limit reached (%u NFP instructions)\n",
nfp_prog->prog_len);
nfp_prog->error = -ENOSPC;
return;
}
@ -2463,6 +2465,8 @@ static int nfp_translate(struct nfp_prog *nfp_prog)
err = cb(nfp_prog, meta);
if (err)
return err;
if (nfp_prog->error)
return nfp_prog->error;
nfp_prog->n_translated++;
}