Commit Graph

1172 Commits

Author SHA1 Message Date
Andrii Nakryiko
d5fa4150f0 libbpf sync 2019-02-17T06:35:29.358Z (#14)
* tools/libbpf: support bigger BTF data sizes

While it's understandable why kernel limits number of BTF types to 65535
and size of string section to 64KB, in libbpf as user-space library it's
too restrictive. E.g., pahole converting DWARF to BTF type information
for Linux kernel generates more than 3 million BTF types and more than
3MB of strings, before deduplication. So to allow btf__dedup() to do its
work, we need to be able to load bigger BTF sections using btf__new().

Singed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

* sync: latest libbpf changes from kernel

Syncing latest libbpf commits from kernel repository.
Baseline commit:   789f6bab849e04ea029c09b81dc8401dc0268cf9
Checkpoint commit: 5aab392c55c96f9bb26d9294f965f156a87ee81c

Andrii Nakryiko (1):
  tools/libbpf: support bigger BTF data sizes

 src/btf.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

--
2.17.1
2019-02-16 22:41:31 -08:00
Andrii Nakryiko
8e42f42533 scripts: add script to sync kernel changes (#13)
This script automates the process of applying libbpf-relevant changes
from kernel repository on top of current state of libbpf repository.

It uses CHECKPOINT-COMMIT file to keep track of last commit in kernel
repo up to which libbpf is in sync with. If there are any new libbpf
changes in kernel repository, script extracts them, preserving original
commit metadata. It also creates a "sync commit" using cover letter as
a template, which nicely summarizes changes since last sync with kernel.

Usage: ./scripts/sync-kernel.sh <linux-repo> <libbpf-repo>

If it succeeds, script will create a bunch of local commits in
<libbpf-repo> in separate branch, which can be easily pushed into github
to create a pull request.

Script tries to clean up after itself, except in case of failure. But it
doesn't clean up timestamped branches it creates in both kernel and
libbpf repositories for now. We can add that later.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
2019-02-16 22:22:30 -08:00
Andrey Ignatov
8008be5657 Install bpf_common.h in install_uapi_headers (#12)
bpf_common.h is hardly ever changed so it was not installed together
with other uapi headers. Some environments are still prefer to be
consistent and install all relevant uapi headers so add bpf_common.h to
uapi headers.

Signed-off-by: Andrey Ignatov <rdna@fb.com>
2019-02-15 14:43:41 -08:00
Yonghong Song
5beb8a2ebf sync with latest bpf-next
Signed-off-by: Yonghong Song <yhs@fb.com>
2019-02-15 08:50:10 -08:00
Andrii Nakryiko
6f9a833985 sync with latest bpf-next (#11)
Sync latest libbpf sources. Tested against pahole.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
2019-02-15 07:38:45 -08:00
yonghong-song
f0bcba631d
sync with latest bpf-next (#10)
sync with latest bpf-next. tested with fb internal testcase and bcc.

Signed-off-by: Yonghong Song <yhs@fb.com>
2019-02-07 21:58:07 -08:00
Yonghong Song
b19c6dcf62 sync with bpf-next
Sync with the following bug fix:
  commit a8a1f7d09cfc7e18874786c7634c9e71384fcd4e (HEAD -> bpf-next2, bpf-next/master)
  Author: Stanislav Fomichev <sdf@google.com>
  Date:   Mon Feb 4 16:20:55 2019 -0800

    libbpf: fix libbpf_print

    With the recent print rework we now have the following problem:
    pr_{warning,info,debug} expand to __pr which calls libbpf_print.
    libbpf_print does va_start and calls __libbpf_pr with va_list argument.
    In __base_pr we again do va_start. Because the next argument is a
    va_list, we don't get correct pointer to the argument (and print noting
    in my case, I don't know why it doesn't crash tbh).

    ......

    Signed-off-by: Stanislav Fomichev <sdf@google.com>

Signed-off-by: Yonghong Song <yhs@fb.com>
2019-02-04 19:42:31 -08:00
Yonghong Song
30388a7afd add BPF_EMIT_CALL macro for libbpf_probes.c
libbpf_probes.c accessed BPF_EMIT_CALL. Added the
definition in include/linux/filter.h.

Signed-off-by: Yonghong Song <yhs@fb.com>
2019-02-04 14:39:30 -08:00
Yonghong Song
1dc0296fce sync with latest bpf-next
The following three files are added:
  libbpf_probes.c
  libbpf_util.h
  libbpf.map

Signed-off-by: Yonghong Song <yhs@fb.com>
2019-02-04 13:29:57 -08:00
yonghong-song
d5b146fec5
add asm/errno.h to linux/err.h (#8)
Otherwise, we will have the following compilation error:

  /home/yhs/work/bcc-new/src/cc/libbpf/src/bpf_prog_linfo.c:
      In function ‘dissect_jited_func’:
  /home/yhs/work/bcc-new/src/cc/libbpf/src/bpf_prog_linfo.c:88:10:
      error: ‘EINVAL’ undeclared (first use in this function)
    return -EINVAL;

The original linux/err.h at linux:tools/include directory
does include "asm/errno.h" as well.

Signed-off-by: Yonghong Song <yhs@fb.com>
2019-01-16 17:16:50 -08:00
David Ahern
29eca541b8 Fix redirect in check-reallocarray (#7)
Builds on debian stretch are failing due to:

../scripts/check-reallocarray.sh: 17: ../scripts/check-reallocarray.sh: Syntax error: Bad fd number

Fix the redirect of stdout and stderr.

Signed-off-by: David Ahern <dsahern@gmail.com>
2019-01-07 20:34:42 -08:00
yonghong-song
07a48dcda2
sync with latest bpf-next (#6)
The following two new files are added:
  README.rst
  bpf_prog_linfo.c

Signed-off-by: Yonghong Song <yhs@fb.com>
2019-01-03 12:44:33 -08:00
yonghong-song
556e0a0def
bpf: sync with latest bpf-next tree (#5)
sync with latest bpf-next tree.
the include/linux/filter.h is created as libbpf.c tries
to use various insn define macros.

Signed-off-by: Yonghong Song <yhs@fb.com>
2018-11-26 14:32:21 -08:00
4ast
319ff2f0f6
Merge pull request #4 from libbpf/pr/add-ring-buffer-header
bpf: add ring_buffer.h drop in replacement header
2018-10-19 14:29:41 -07:00
Daniel Borkmann
a0e4e323bb bpf: add ring_buffer.h drop in replacement header
Add fast variant for x86-64 for now, and we can later extend for
others upon demand.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2018-10-19 23:14:46 +02:00
Andrey Ignatov
62706e5557 Symbols visibility (#3)
* Sync from bpf-next

Sync the following commits from bpf-next:
commit ab9e08482122 ("libbpf: Per-symbol visibility for DSO")
commit c034a177d3c8 ("bpf: bpftool, add flag to allow non-compat map definitions")

Signed-off-by: Andrey Ignatov <rdna@fb.com>

* Use -fvisibility=hidden by default for DSO

This is Makefile part of:
commit ab9e08482122 ("libbpf: Per-symbol visibility for DSO")

See original commit for details.
2018-10-16 17:24:08 -07:00
yonghong-song
e5c75f8e94
mirror uapi/linux/bpf_common.h file (#2)
bcc still has this file in its src/cc/compat/linux directory.
Add this file to libbpf as well.

Signed-off-by: Yonghong Song <yhs@fb.com>
2018-10-12 12:57:55 -07:00
yonghong-song
a907cbaee9
Merge pull request #1 from rdna/extend-build-install
Extend build and install
2018-10-11 16:25:11 -07:00
Andrey Ignatov
a82a66eda3 Extend build and add install rules to Makefile
Introduce multiple improvements to Makefile to make the build more
flexible and support install:

* Support overriding CFLAGS by user but keep required flags in place.
  ALL_FLAGS is used in Makefile as recommended in [1].

* Add additional BUILD_SHARED flag to build dynamically linked flavor of
  the library. If the flag is set, -fPIC is also passed to make it
  possible to build .so.

* Support building in a separate directory provided by OBJDIR variable.

* Add multiple install targets. By default the library itself and libbpf
  headers are installed (install target). UAPI headers can be optionally
  installed by user.

* All installation paths, including PREFIX, library and include
  directories can be overridden. UAPI can be made different from include
  directory for libbpf headers. That makes it possible to keep latest
  <linux/bpf.h> in a place that doesn't conflict with the one installed
  e.g. by kernel-headers package and use it in user's build system.

* Support DESTDIR (see [2]).

* Support overriding LDFLAGS.

* Use utilities such as rm directly as recommended in [3].

* Use compiler and related programs (such as ar) via make variables as
  recommended in [3].

* In clean rule remove all possible build artifacts not to rely on passed
  options (e.g. if build was done w/ BUILD_SHARED, but clean w/o it).

* Document new build options in README.

[1] https://www.gnu.org/software/make/manual/html_node/Command-Variables.html#Command-Variables
[2] https://www.gnu.org/prep/standards/html_node/DESTDIR.html
[3] https://www.gnu.org/software/make/manual/html_node/Utilities-in-Makefiles.html#Utilities-in-Makefiles

Signed-off-by: Andrey Ignatov <rdna@fb.com>
2018-10-11 15:45:50 -07:00
Andrey Ignatov
c2015d0a65 Add if_link.h and netlink.h UAPI headers
Add more UAPI headers from kernel tree since libbpf relies on their
latest versions that may not be present on target system to use in
build.

if_link.h and netlink.h are synced to include/uapi/linux/ from [1]

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/tree/tools/include/uapi/linux

Signed-off-by: Andrey Ignatov <rdna@fb.com>
2018-10-11 15:26:06 -07:00
Yonghong Song
8acf2635c3 add a simple Makefile to build and clean up
add missing macros, static inline functions, etc.
add README to illustrate the purpose of this repo.

Signed-off-by: Yonghong Song <yhs@fb.com>
2018-10-10 09:40:15 -07:00
Yonghong Song
66684189f0 initial commit
This initial commit added the following files
from bpf-next repository:
  src:
    <files from linux:tools/lib/bpf>
    bpf.c bpf.h btf.c btf.h libbpf.c libbpf.h
    libbpf_errno.c netlink.c nlattr.c nlattr.h
    str_error.c str_error.h
  include:
    <files from linux:tools/include/uapi/linux>
    uapi/linux/{bpf.h, btf.h}

    <files from linux:tools/include/tools>
    tools/libc_compat.h

The following files are also added:
  include/linux/{err.h, kernel.h, list.h, overflow.h, types.h}
These files are customized headers to satisfy compilation.
Their original counterparts are at linux:tools/include/linux
directory.

Signed-off-by: Yonghong Song <yhs@fb.com>
2018-10-09 21:56:40 -07:00