]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
nfp: bpf: fix check of program max insn count
authorJakub Kicinski <jakub.kicinski@netronome.com>
Sat, 24 Mar 2018 03:00:13 +0000 (20:00 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Sat, 24 Mar 2018 17:41:24 +0000 (10:41 -0700)
NFP program allocation length is in bytes and NFP program length
is in instructions, fix the comparison of the two.

Fixes: 9314c442d7dd ("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>
drivers/net/ethernet/netronome/nfp/bpf/jit.c

index 56451edf01c2c689ee8199aa765f59e4ffa21d8e..ecd7c33baf3c9c1d014bc460d0d9c9048c08e548 100644 (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++;
        }