Skip to content

Commit bfd03ff

Browse files
authored
Delete libraries and user-side programs (#172)
1 parent 6a598c6 commit bfd03ff

File tree

165 files changed

+78
-55887
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

165 files changed

+78
-55887
lines changed

.dockerfiles/build.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ set -e
55
build() {
66
echo "[XXX]: Building against Kernel ${KERNEL_VERSION} for libc ${_LIBC} ..."
77
(
8-
cd user || exit 1
98
if [ "${DEBUG:-0}" -eq 1 ]; then
109
echo "[XXX]: Building with debug symbols ..."
1110
make CFLAGS='-fno-stack-protector -I /usr/src/linux/usr/include' EXTRA_CFLAGS='-g -fno-stack-protector'

.gitignore

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,5 @@
55
*.tar.*
66
*.tar
77

8-
*.so*
98
*.ll
109
*.o*
11-
12-
user/process_monitor
13-
user/process_latency
14-
user/process_test
15-
16-
libbpf/src/build/
17-
libbpf/src/root/
18-
library/libbpf.a

Makefile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
CC=gcc
2+
3+
KERNEL_DIR = kernel/
4+
KERNEL_PROGRAM = $(KERNEL_DIR)process_kern.o
5+
6+
KERNEL_VERSION="$(shell if [ -f /usr/src/linux/include/config/kernel.release ]; then cat /usr/src/linux/include/config/kernel.release; else cat /proc/sys/kernel/osrelease; fi)"
7+
FIRST_KERNEL_VERSION=$(shell sh tools/complement.sh "$(KERNEL_VERSION)")
8+
9+
NETDATA_KERNEL_VERSION=$(shell echo $(KERNEL_VERSION) | tr -s "." "_")
10+
11+
VER_MAJOR=$(shell echo $(KERNEL_VERSION) | cut -d. -f1)
12+
VER_MINOR=$(shell echo $(KERNEL_VERSION) | cut -d. -f2)
13+
VER_PATCH=$(shell echo $(KERNEL_VERSION) | cut -d. -f3)
14+
15+
_LIBC ?= glibc
16+
17+
EXTRA_CFLAGS += -fno-stack-protector
18+
19+
all: $(KERNEL_PROGRAM)
20+
cp $(KERNEL_DIR)rprocess_kern.o rnetdata_ebpf_process.$(VER_MAJOR).$(VER_MINOR).$(VER_PATCH).o
21+
cp $(KERNEL_DIR)pprocess_kern.o pnetdata_ebpf_process.$(VER_MAJOR).$(VER_MINOR).$(VER_PATCH).o
22+
cp $(KERNEL_DIR)rnetwork_viewer_kern.o rnetdata_ebpf_socket.$(VER_MAJOR).$(VER_MINOR).$(VER_PATCH).o
23+
cp $(KERNEL_DIR)pnetwork_viewer_kern.o pnetdata_ebpf_socket.$(VER_MAJOR).$(VER_MINOR).$(VER_PATCH).o
24+
if [ -f pnetdata_ebpf_process.$(VER_MAJOR).$(VER_MINOR).$(VER_PATCH).o ]; then tar -cf artifacts/netdata_ebpf-$(FIRST_KERNEL_VERSION)_$(NETDATA_KERNEL_VERSION)-$(_LIBC).tar [pr]netdata_ebpf_*.$(VER_MAJOR).$(VER_MINOR).$(VER_PATCH).o; else echo "ERROR: Cannot find BPF programs"; exit 1; fi
25+
if [ "$${DEBUG:-0}" -eq 1 ]; then tar -uvf artifacts/netdata_ebpf-$(FIRST_KERNEL_VERSION)_$(NETDATA_KERNEL_VERSION)-$(_LIBC).tar tools/check-kernel-config.sh; fi
26+
xz artifacts/netdata_ebpf-$(FIRST_KERNEL_VERSION)_$(NETDATA_KERNEL_VERSION)-$(_LIBC).tar
27+
( cd artifacts; sha256sum netdata_ebpf-$(FIRST_KERNEL_VERSION)_$(NETDATA_KERNEL_VERSION)-$(_LIBC).tar.xz > netdata_ebpf-$(FIRST_KERNEL_VERSION)_$(NETDATA_KERNEL_VERSION)-$(_LIBC).tar.xz.sha256sum )
28+
29+
$(KERNEL_PROGRAM):
30+
cd $(KERNEL_DIR) && $(MAKE) all;
31+
32+
clean:
33+
if [ -f pnetdata_ebpf_process.$(VER_MAJOR).$(VER_MINOR).$(VER_PATCH).o ] ; then rm *.o; fi
34+
cd $(KERNEL_DIR) && $(MAKE) clean;
35+
rm artifacts/*
36+
37+
install:
38+
cp *netdata_ebpf_process.$(VER_MAJOR).$(VER_MINOR).$(VER_PATCH).o /usr/libexec/netdata/plugins.d/

README.md

Lines changed: 18 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,17 @@ Linux Kernel eBPF Collectors
99

1010
The respository has the following directory structure:
1111

12-
- `artifacts`: Directory that will have the eBPF programs and shared libraries when the compilation process ends.
12+
- `artifacts`: Directory that will have the eBPF programs when the compilation process ends.
1313
- `includes`: Common headers
1414
- `kernel`: The eBPF programs source code
15-
- `lib`: The libelf static used to create the shared library.
16-
- `library`: Codes from Linux kernel-source changed to create the shared library.
17-
- `libbpf_0_0_1`: An inexistent version of the libbpf library, we changed it to support old Linux kernels.
18-
- `libbpf`: The latest libbpf version from kernel.
19-
- `tools`: scripts used to verify system status before to install or test any eBPF code.
20-
- `user`: Software to tests the eBPF program
15+
- `tools`: scripts used to verify system status before installing eBPF code.
2116

2217
## Necessary packages
2318

24-
To compile the shared libraries and the eBPF programs, it will be necessary to have the following packages:
19+
To compile the eBPF programs, it will be necessary to have the following packages:
2520

2621
- Libelf headers
27-
- llvm/clang , because GCC cannot compile eBPF codes.
22+
- llvm/clang, because GCC prior to 10.0 cannot compile eBPF code.
2823
- Kernel headers
2924

3025
The last group of files can be extracted direct from kernel source doing the following steps:
@@ -37,7 +32,7 @@ make prepare
3732
make headers_install
3833
```
3934

40-
Case you are using the kernel `5.4` or newer, it is necessary to comment the following line inside the file
35+
In case you are using the kernel `5.4` or newer, it is necessary to comment the following line inside the file
4136
`generated/autoconf.h`:
4237

4338
```
@@ -46,13 +41,13 @@ Case you are using the kernel `5.4` or newer, it is necessary to comment the fol
4641

4742
## Necessary changes
4843

49-
Before to compile this repository, it is necessary to change the Makefiles according your environment. The original
44+
Before compilation of this repository, it is necessary to change the Makefiles according your environment. The original
5045
files were adjusted to compile on Slackware Linux Current.
5146

5247

5348
### `kernel/Makefile`
5449

55-
Inside this file probably it will be neecssary to change the following variable:
50+
Inside this file probably it will be necessary to change the following variable:
5651

5752
- `KERNELSOURCE`: Where is your kernel-source? This variable was set initially to work on Slackware, Fedora and Ubuntu
5853
- `KERNELBUILD`: Directory where the headers are expected to be stored.
@@ -112,46 +107,28 @@ This sets `EXTRA_CFLAGS=-g` up before building.
112107

113108
## Compilation (manually)
114109

115-
After to do the necessaries changes inside the file `kernel/Makefille`, to compile the libraries
116-
and the eBPF programs, you only need to do the following steps:
110+
After the necessary changes have been done inside the `kernel/Makefille` file, you need to run the following
111+
command to compile the eBPF programs:
117112

118113
```bash
119-
# cd user
120114
# make
121115
```
122116

123-
When the compilation finishes, you will have inside `artificats` directory a file with the following
117+
When the compilation finishes, you will have a file inside `artifacts` directory with the following
124118
content:
125119

126120
```
127-
usr/lib64/libbpf_kernel.so
128-
libnetdata_ebpf.so
129-
dnetdata_ebpf_process.o
130-
pnetdata_ebpf_process.o
131-
rnetdata_ebpf_process.o
121+
pnetdata_ebpf_process.<kernel version>.o
122+
pnetdata_ebpf_socket.<kernel version>.o
123+
rnetdata_ebpf_process.<kernel version>.o
124+
rnetdata_ebpf_socket.<kernel version>.o
132125
```
133126

134-
We can group these files as:
127+
`p*.o`: eBPF programs used with entry mode, this is the default mode.
128+
`r*.o`: eBPF programs used with return mode.
135129

136-
- `libbpf_kernel.so`: This is the libbpf shared library that must be moved to a directory listed inside
137-
`/etc/ld.so.conf`, when you move it for one of the directory, it will be necessary to create a symbolic link,
138-
for example, let us assume that the distribution uses `/usr/lib64/` to store shared libraries, the following
139-
commands are necessaries:
140-
141-
```bash
142-
cp usr/lib64/libbpf_kernel.so /usr/lib64/
143-
ln -s /usr/lib64/libbpf_kernel.so /usr/lib64/libbpf_kernel.so.0
144-
```
145-
146-
- `Collector files`: the collector works with all files created during the compilation, but the next 4 files
147-
need to be copied to `/usr/libexec/netdata/plugins.d` for the collector to have condition to access them:
148-
- `libnetdata_ebpf.so`: Shared library used to load the eBPF programs.
149-
- `dnetdata_ebpf_process.o`: eBPF program used with developer mode.
150-
- `pnetdata_ebpf_process.o`: eBPF program used with entry mode, this is the default mode.
151-
- `rnetdata_ebpf_process.o`: eBPF program used with return mode.
152-
153-
154-
After this you can start the new collector `ebpf_program.plugin`.
130+
These files have to be copied to your plugins directory, which is usually at `/usr/libexec/netdata/plugins.d/`,
131+
for the collector to be able to access them. After this you can start the new collector `ebpf_program.plugin`.
155132

156133
## Releasing
157134

docs/Compilation-as-normal-user.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
# Compilation as normal user
22

3-
The `kernel-collector` repository can be compiled as normal user, but before to do this it is necessary
4-
some steps as `root`.
3+
The `kernel-collector` repository can be compiled as normal user, but before doing this it is necessary
4+
to do some steps as `root`.
55

66
## Steps as root
77

8-
Before to compile this repository, it is necessary to install the nessary packages available on your
9-
Linux distribution. The complete list of packages can be found inside the Docker files on this repository.
8+
Before compiling this repository, you have to install necessary packages available on your
9+
Linux distribution. The complete list of packages can be found inside the Docker files in this repository.
1010

11-
Case you are trying to compile on a kernel newer than `5.0`, it will be necessary to disable the
12-
`assembly inline`, this can be done editing the file `/usr/src/linux/include/generated/autoconf.h`
11+
In case you are trying to compile on a kernel newer than `5.0`, it will be necessary to disable the
12+
`assembly inline`, this can be done by editing the file `/usr/src/linux/include/generated/autoconf.h`
1313
and commenting the line `//#define CONFIG_CC_HAS_ASM_INLINE 1`.
1414

15-
Finally case your distribution does not create the symbolic link `/usr/src/linux` to your kernel source,
15+
Finally, if your distribution does not create the symbolic link `/usr/src/linux` to your kernel source,
1616
you will need to do it manually.
1717

1818
## Step as normal user
1919

20-
After to do the necessary installation, you only need to run the next commands to compile the repository:
20+
After the necessary installation has been prepared, you need to run the next command to compile the repository:
2121

2222
```bash
23-
$ cd user/
2423
$ make
2524
```

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Docs
22

3-
The following directory contains general documentation related to this repository.
3+
This directory contains general documentation related to this repository.

docs/Update-libbpf.md

Lines changed: 0 additions & 67 deletions
This file was deleted.

includes/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
# Include files
22

3-
This directory has only one file that Netdata developed, the file `api.h`, all theother files were
4-
copied from kernel source repository.
3+
Copied from the kernel source repository.

includes/api.h

Lines changed: 0 additions & 22 deletions
This file was deleted.

includes/bpf_endian.h

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)