bpf: Add jited_len to struct bpf_prog
authorMartin KaFai Lau <kafai@fb.com>
Mon, 5 Jun 2017 19:15:51 +0000 (12:15 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 6 Jun 2017 19:41:24 +0000 (15:41 -0400)
Add jited_len to struct bpf_prog.  It will be
useful for the struct bpf_prog_info which will
be added in the later patch.

Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Acked-by: Alexei Starovoitov <ast@fb.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
arch/arm64/net/bpf_jit_comp.c
arch/powerpc/net/bpf_jit_comp64.c
arch/s390/net/bpf_jit_comp.c
arch/sparc/net/bpf_jit_comp_64.c
arch/x86/net/bpf_jit_comp.c
include/linux/filter.h

index b1d38eeb24f6f6423ea91c33aa8c55fd1fe9e98e..4f95873d71426b1b7131d795aff75323908c2219 100644 (file)
@@ -900,6 +900,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
        bpf_jit_binary_lock_ro(header);
        prog->bpf_func = (void *)ctx.image;
        prog->jited = 1;
+       prog->jited_len = image_size;
 
 out_off:
        kfree(ctx.offset);
index a01366584a4b7efb157bbbce480a0c425e705519..861c5af1c9c4bdd85dba552b2e41a9587162e3a7 100644 (file)
@@ -1052,6 +1052,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *fp)
 
        fp->bpf_func = (void *)image;
        fp->jited = 1;
+       fp->jited_len = alloclen;
 
        bpf_flush_icache(bpf_hdr, (u8 *)bpf_hdr + (bpf_hdr->pages * PAGE_SIZE));
 
index 42ad3832586ce4cb480710e0b5acb8ae9af431f2..01c6fbc3e85b62fdec83bacea0f76a88126bfe84 100644 (file)
@@ -1329,6 +1329,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *fp)
        bpf_jit_binary_lock_ro(header);
        fp->bpf_func = (void *) jit.prg_buf;
        fp->jited = 1;
+       fp->jited_len = jit.size;
 free_addrs:
        kfree(jit.addrs);
 out:
index 098874a81f6e31cc5e758a682cf459a4c0fb7bb8..8799ae9a8788f6fd8628c35974ec172d6aab61cc 100644 (file)
@@ -1560,6 +1560,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
 
        prog->bpf_func = (void *)ctx.image;
        prog->jited = 1;
+       prog->jited_len = image_size;
 
 out_off:
        kfree(ctx.offset);
index 617eac9c4511a69c307a40856a0a11190b2d2a74..e1324f280e06eb86c9aa9c2249cdba6b6c036c4b 100644 (file)
@@ -1167,6 +1167,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
                bpf_jit_binary_lock_ro(header);
                prog->bpf_func = (void *)image;
                prog->jited = 1;
+               prog->jited_len = proglen;
        } else {
                prog = orig_prog;
        }
index a20ba40fcb73f901dd643581579629f4e2430d46..1e2dddf21f3b0de0e930ed95d4cca560ab7c44e2 100644 (file)
@@ -432,6 +432,7 @@ struct bpf_prog {
        kmemcheck_bitfield_end(meta);
        enum bpf_prog_type      type;           /* Type of BPF program */
        u32                     len;            /* Number of filter blocks */
+       u32                     jited_len;      /* Size of jited insns in bytes */
        u8                      tag[BPF_TAG_SIZE];
        struct bpf_prog_aux     *aux;           /* Auxiliary fields */
        struct sock_fprog_kern  *orig_prog;     /* Original BPF program */