lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <B1F03B56-E1AF-4269-BC52-FE5ACB820751@163.com>
Date:	Thu, 21 Apr 2016 03:29:43 +0800
From:	pi3orama <pi3orama@....com>
To:	Arnaldo Carvalho de Melo <acme@...nel.org>
Cc:	Wang Nan <wangnan0@...wei.com>, jolsa@...hat.com,
	brendan.d.gregg@...il.com, linux-kernel@...r.kernel.org,
	Arnaldo Carvalho de Melo <acme@...hat.com>,
	Alexei Starovoitov <ast@...nel.org>,
	Jiri Olsa <jolsa@...nel.org>, Li Zefan <lizefan@...wei.com>
Subject: Re: [RFC PATCH 05/13] bpf tools: Save engine type in bpf_program



发自我的 iPhone

> 在 2016年4月21日,上午3:23,Arnaldo Carvalho de Melo <acme@...nel.org> 写道:
> 
> Em Wed, Apr 20, 2016 at 06:01:45PM +0000, Wang Nan escreveu:
>> 

[SNIP]

>> 
>> +    if (prog->engine == ENGINE_UNKNOWN)
>> +        prog->engine = ENGINE_KBPF;
>> +    if (prog->engine != ENGINE_KBPF)
> 
>    else if (prog->engine != ENGINE_KBPF)
> 
> Nitpicking a bit :-)
> 

We set it to ENGINE_KBPF in previous "if",
so can't use "else".

Do this because I want the engine is KBPF
if not explicitly set to UNPF.

Thank you.

>> +        return -EINVAL;
>> +
>>    if (prog->instances.nr < 0 || !prog->instances.array) {
>>        if (prog->preprocessor) {
>>            pr_warning("Internal error: can't load program '%s'\n",
>> @@ -1318,6 +1330,34 @@ int bpf_program__nth_fd(struct bpf_program *prog, int n)
>>    return fd;
>> }
>> 
>> +#ifdef HAVE_UBPF_SUPPORT
>> +int bpf_program__set_ubpf(struct bpf_program *prog)
>> +{
>> +    if (prog->engine != ENGINE_UNKNOWN) {
>> +        pr_warning("Can't set program %s to ubpf\n",
>> +               prog->section_name);
>> +        return -EINVAL;
>> +    }
>> +    prog->engine = ENGINE_UBPF;
>> +    return 0;
>> +}
>> +
>> +bool bpf_program__is_ubpf(struct bpf_program *prog)
>> +{
>> +    return prog->engine == ENGINE_UBPF;
>> +}
>> +#else
>> +int bpf_program__set_ubpf(struct bpf_program *prog __maybe_unused)
>> +{
>> +    return -LIBBPF_ERRNO__NOUBPF;
>> +}
>> +
>> +bool bpf_program__is_ubpf(struct bpf_program *prog __maybe_unused)
>> +{
>> +    return false;
>> +}
>> +#endif
>> +
>> int bpf_map__get_fd(struct bpf_map *map)
>> {
>>    if (!map)
>> diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
>> index a51594c..f6965ce 100644
>> --- a/tools/lib/bpf/libbpf.h
>> +++ b/tools/lib/bpf/libbpf.h
>> @@ -26,6 +26,7 @@ enum libbpf_errno {
>>    LIBBPF_ERRNO__VERIFY,    /* Kernel verifier blocks program loading */
>>    LIBBPF_ERRNO__PROG2BIG,    /* Program too big */
>>    LIBBPF_ERRNO__KVER,    /* Incorrect kernel version */
>> +    LIBBPF_ERRNO__NOUBPF,    /* UBPF support is not compiled */
>>    __LIBBPF_ERRNO__END,
>> };
>> 
>> @@ -86,6 +87,9 @@ int bpf_program__get_private(struct bpf_program *prog,
>> 
>> const char *bpf_program__title(struct bpf_program *prog, bool needs_copy);
>> 
>> +int bpf_program__set_ubpf(struct bpf_program *prog);
>> +bool bpf_program__is_ubpf(struct bpf_program *prog);
>> +
>> int bpf_program__fd(struct bpf_program *prog);
>> 
>> struct bpf_insn;
>> -- 
>> 1.8.3.4


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ