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] [day] [month] [year] [list]
Message-ID: <20181121024232.gsgcgme54kde2p52@ast-mbp>
Date:   Tue, 20 Nov 2018 18:42:33 -0800
From:   Alexei Starovoitov <alexei.starovoitov@...il.com>
To:     Stanislav Fomichev <sdf@...ichev.me>
Cc:     Stanislav Fomichev <sdf@...gle.com>, netdev@...r.kernel.org,
        ast@...nel.org, daniel@...earbox.net, ys114321@...il.com
Subject: Re: [PATCH bpf-next v2] libbpf: make sure bpf headers are c++
 include-able

On Tue, Nov 20, 2018 at 05:59:52PM -0800, Stanislav Fomichev wrote:
> On 11/20, Alexei Starovoitov wrote:
> > On Tue, Nov 20, 2018 at 04:05:55PM -0800, Stanislav Fomichev wrote:
> > > On 11/20, Alexei Starovoitov wrote:
> > > > On Tue, Nov 20, 2018 at 01:37:23PM -0800, Stanislav Fomichev wrote:
> > > > > Wrap headers in extern "C", to turn off C++ mangling.
> > > > > This simplifies including libbpf in c++ and linking against it.
> > > > > 
> > > > > v2 changes:
> > > > > * do the same for btf.h
> > > > > 
> > > > > Signed-off-by: Stanislav Fomichev <sdf@...gle.com>
> > > > > ---
> > > > >  tools/lib/bpf/bpf.h    | 9 +++++++++
> > > > >  tools/lib/bpf/btf.h    | 8 ++++++++
> > > > >  tools/lib/bpf/libbpf.h | 9 +++++++++
> > > > >  3 files changed, 26 insertions(+)
> > > > > 
> > > > > diff --git a/tools/lib/bpf/bpf.h b/tools/lib/bpf/bpf.h
> > > > > index 26a51538213c..9ea3aec82d8a 100644
> > > > > --- a/tools/lib/bpf/bpf.h
> > > > > +++ b/tools/lib/bpf/bpf.h
> > > > > @@ -27,6 +27,10 @@
> > > > >  #include <stdbool.h>
> > > > >  #include <stddef.h>
> > > > >  
> > > > > +#ifdef __cplusplus
> > > > > +extern "C" {
> > > > > +#endif
> > > > 
> > > > Acked-by: Alexei Starovoitov <ast@...nel.org>
> > > > 
> > > > was wondering whether it's possible to make it testable.
> > > > HOSTCXX is available, but I don't see much of the kernel tree
> > > > using it...
> > > By testable you mean compile some dummy c++ main and link against libbpf?
> > 
> > yes. something like this.
> > to make sure that it keeps being functional and no one introduces 'int new'
> > in some function argument list by accident.
> I tried something like the patch below, it does seem to work locally (building
> in the same directory, no cross-compile). Who would be the best to
> review that kind of stuff?
> 
> diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile
> index 425b480bda75..4c0e58628aad 100644
> --- a/tools/lib/bpf/Makefile
> +++ b/tools/lib/bpf/Makefile
> @@ -66,7 +66,7 @@ ifndef VERBOSE
>  endif
>  
>  FEATURE_USER = .libbpf
> -FEATURE_TESTS = libelf libelf-mmap bpf reallocarray
> +FEATURE_TESTS = libelf libelf-mmap bpf reallocarray cxx
>  FEATURE_DISPLAY = libelf bpf
>  
>  INCLUDES = -I. -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(ARCH)/include/uapi -I$(srctree)/tools/include/uapi
> @@ -148,6 +148,10 @@ LIB_FILE := $(addprefix $(OUTPUT),$(LIB_FILE))
>  
>  CMD_TARGETS = $(LIB_FILE)
>  
> +ifeq ($(feature-cxx), 1)
> +	CMD_TARGETS += $(OUTPUT)test_libbpf
> +endif
> +
>  TARGETS = $(CMD_TARGETS)
>  
>  all: fixdep all_cmd
> @@ -175,6 +179,9 @@ $(OUTPUT)libbpf.so: $(BPF_IN)
>  $(OUTPUT)libbpf.a: $(BPF_IN)
>  	$(QUIET_LINK)$(RM) $@; $(AR) rcs $@ $^
>  
> +$(OUTPUT)test_libbpf: test_libbpf.cpp $(OUTPUT)libbpf.a
> +	$(QUIET_LINK)$(CXX) $^ -lelf -o $@

looks good to me.
pls include test_libbpf.cpp and resubmit for bpf-next.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ