• Wang Nan's avatar
    bpf tools: Load eBPF programs in object files into kernel · 55cffde2
    Wang Nan authored
    This patch utilizes previous introduced bpf_load_program to load
    programs in the ELF file into kernel. Result is stored in 'fd' field in
    'struct bpf_program'.
    
    During loading, it allocs a log buffer and free it before return.  Note
    that that buffer is not passed to bpf_load_program() if the first
    loading try is successful. Doesn't use a statically allocated log buffer
    to avoid potention multi-thread problem.
    
    Instructions collected during opening is cleared after loading.
    
    load_program() is created for loading a 'struct bpf_insn' array into
    kernel, bpf_program__load() calls it. By this design we have a function
    loads instructions into kernel. It will be used by further patches,
    which creates different instances from a program and load them into
    kernel.
    Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
    Acked-by: default avatarAlexei Starovoitov <ast@plumgrid.com>
    Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
    Cc: Daniel Borkmann <daniel@iogearbox.net>
    Cc: David Ahern <dsahern@gmail.com>
    Cc: He Kuang <hekuang@huawei.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Kaixu Xia <xiakaixu@huawei.com>
    Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
    Cc: Zefan Li <lizefan@huawei.com>
    Cc: pi3orama@163.com
    Link: http://lkml.kernel.org/r/1435716878-189507-20-git-send-email-wangnan0@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    55cffde2
libbpf.c 19.1 KB