Re: [RFC PATCH v3 09/37] bpf tools: Open eBPF object file and do basic validation

2015-05-25 Thread Arnaldo Carvalho de Melo
Em Tue, May 26, 2015 at 08:05:28AM +0800, Wangnan (F) escreveu: > On 2015/5/25 21:30, Arnaldo Carvalho de Melo wrote: > >Well, there are many styles to pick, the fact that perf uses __ to > >separate class name from class method doesn't mean that you should as > >well, as you may find it

Re: [RFC PATCH v3 09/37] bpf tools: Open eBPF object file and do basic validation

2015-05-25 Thread Wangnan (F)
On 2015/5/25 21:30, Arnaldo Carvalho de Melo wrote: Em Fri, May 22, 2015 at 06:00:58PM -0700, Alexei Starovoitov escreveu: On 5/22/15 10:23 AM, Jiri Olsa wrote: +struct bpf_object *bpf_open_object(const char *path) another suggestion for the namespace.. Arnaldo forces us ;-) to use the

Re: [RFC PATCH v3 09/37] bpf tools: Open eBPF object file and do basic validation

2015-05-25 Thread Arnaldo Carvalho de Melo
Em Fri, May 22, 2015 at 06:00:58PM -0700, Alexei Starovoitov escreveu: > On 5/22/15 10:23 AM, Jiri Olsa wrote: > >>+struct bpf_object *bpf_open_object(const char *path) > >another suggestion for the namespace.. Arnaldo forces us ;-) > >to use the object name first plus '__(method name)' for >

Re: [RFC PATCH v3 09/37] bpf tools: Open eBPF object file and do basic validation

2015-05-25 Thread Arnaldo Carvalho de Melo
Em Fri, May 22, 2015 at 06:00:58PM -0700, Alexei Starovoitov escreveu: On 5/22/15 10:23 AM, Jiri Olsa wrote: +struct bpf_object *bpf_open_object(const char *path) another suggestion for the namespace.. Arnaldo forces us ;-) to use the object name first plus '__(method name)' for interface

Re: [RFC PATCH v3 09/37] bpf tools: Open eBPF object file and do basic validation

2015-05-25 Thread Wangnan (F)
On 2015/5/25 21:30, Arnaldo Carvalho de Melo wrote: Em Fri, May 22, 2015 at 06:00:58PM -0700, Alexei Starovoitov escreveu: On 5/22/15 10:23 AM, Jiri Olsa wrote: +struct bpf_object *bpf_open_object(const char *path) another suggestion for the namespace.. Arnaldo forces us ;-) to use the

Re: [RFC PATCH v3 09/37] bpf tools: Open eBPF object file and do basic validation

2015-05-25 Thread Arnaldo Carvalho de Melo
Em Tue, May 26, 2015 at 08:05:28AM +0800, Wangnan (F) escreveu: On 2015/5/25 21:30, Arnaldo Carvalho de Melo wrote: Well, there are many styles to pick, the fact that perf uses __ to separate class name from class method doesn't mean that you should as well, as you may find it inconvenient or

Re: [RFC PATCH v3 09/37] bpf tools: Open eBPF object file and do basic validation

2015-05-22 Thread Alexei Starovoitov
On 5/22/15 10:23 AM, Jiri Olsa wrote: + +struct bpf_object *bpf_open_object(const char *path) +{ another suggestion for the namespace.. Arnaldo forces us ;-) to use the object name first plus '__(method name)' for interface functions so that would be: bpf_object__open bpf_object__close

Re: [RFC PATCH v3 09/37] bpf tools: Open eBPF object file and do basic validation

2015-05-22 Thread Jiri Olsa
On Sun, May 17, 2015 at 10:56:34AM +, Wang Nan wrote: SNIP > + obj->path); > + err = -EINVAL; > + goto errout; > + } > + ep = >elf.ehdr; > + > + if ((ep->e_type != ET_REL) || (ep->e_machine != 0)) { > +

Re: [RFC PATCH v3 09/37] bpf tools: Open eBPF object file and do basic validation

2015-05-22 Thread Jiri Olsa
On Sun, May 17, 2015 at 10:56:34AM +, Wang Nan wrote: SNIP > + > +void bpf_close_object(struct bpf_object *obj) > +{ > + if (!obj) > + return; > + > + bpf_obj_clear_elf(obj); > + > + if (obj->path) > + free(obj->path); you're safe calling free with NULL,

Re: [RFC PATCH v3 09/37] bpf tools: Open eBPF object file and do basic validation

2015-05-22 Thread Alexei Starovoitov
On 5/22/15 10:23 AM, Jiri Olsa wrote: + +struct bpf_object *bpf_open_object(const char *path) +{ another suggestion for the namespace.. Arnaldo forces us ;-) to use the object name first plus '__(method name)' for interface functions so that would be: bpf_object__open bpf_object__close

Re: [RFC PATCH v3 09/37] bpf tools: Open eBPF object file and do basic validation

2015-05-22 Thread Jiri Olsa
On Sun, May 17, 2015 at 10:56:34AM +, Wang Nan wrote: SNIP + +void bpf_close_object(struct bpf_object *obj) +{ + if (!obj) + return; + + bpf_obj_clear_elf(obj); + + if (obj-path) + free(obj-path); you're safe calling free with NULL, so there's

Re: [RFC PATCH v3 09/37] bpf tools: Open eBPF object file and do basic validation

2015-05-22 Thread Jiri Olsa
On Sun, May 17, 2015 at 10:56:34AM +, Wang Nan wrote: SNIP + obj-path); + err = -EINVAL; + goto errout; + } + ep = obj-elf.ehdr; + + if ((ep-e_type != ET_REL) || (ep-e_machine != 0)) { + pr_warning(%s is not

Re: [RFC PATCH v3 09/37] bpf tools: Open eBPF object file and do basic validation

2015-05-18 Thread Alexei Starovoitov
On 5/17/15 3:56 AM, Wang Nan wrote: This patch adds basic 'struct bpf_object' which will be used for eBPF object file loading. eBPF object files are compiled by LLVM as ELF format. In this patch, libelf is used to open those files, read EHDR and do basic validation according to e_type and

Re: [RFC PATCH v3 09/37] bpf tools: Open eBPF object file and do basic validation

2015-05-18 Thread Alexei Starovoitov
On 5/17/15 3:56 AM, Wang Nan wrote: This patch adds basic 'struct bpf_object' which will be used for eBPF object file loading. eBPF object files are compiled by LLVM as ELF format. In this patch, libelf is used to open those files, read EHDR and do basic validation according to e_type and

[RFC PATCH v3 09/37] bpf tools: Open eBPF object file and do basic validation

2015-05-17 Thread Wang Nan
This patch adds basic 'struct bpf_object' which will be used for eBPF object file loading. eBPF object files are compiled by LLVM as ELF format. In this patch, libelf is used to open those files, read EHDR and do basic validation according to e_type and e_machine. All elf related staffs are

[RFC PATCH v3 09/37] bpf tools: Open eBPF object file and do basic validation

2015-05-17 Thread Wang Nan
This patch adds basic 'struct bpf_object' which will be used for eBPF object file loading. eBPF object files are compiled by LLVM as ELF format. In this patch, libelf is used to open those files, read EHDR and do basic validation according to e_type and e_machine. All elf related staffs are