!38 Update to 1.0.1 version

From: @Vchanger 
Reviewed-by: @MrRlu 
Signed-off-by: @MrRlu
This commit is contained in:
openeuler-ci-bot 2023-01-12 13:35:07 +00:00 committed by Gitee
commit 59a46ff8e0
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
8 changed files with 11 additions and 417913 deletions

View File

@ -1,140 +0,0 @@
From d3a5b078c4566c966280dad7a5efa7e74053b718 Mon Sep 17 00:00:00 2001
From: wo_cow <niuqianqian@huawei.com>
Date: Thu, 17 Nov 2022 16:29:47 +0800
Subject: [PATCH] adapt libbpf v0.8
---
.../ebpf.probe/src/include/__bpf_usr.h | 32 ++++++++++++++-----
.../extends/ebpf.probe/src/include/bpf.h | 4 ++-
.../ebpf.probe/src/ioprobe/io_count.bpf.c | 2 +-
.../ebpf.probe/src/ioprobe/io_err.bpf.c | 2 +-
src/probes/extends/ebpf.probe/src/mk/var.mk | 5 +++
5 files changed, 34 insertions(+), 11 deletions(-)
diff --git a/src/probes/extends/ebpf.probe/src/include/__bpf_usr.h b/src/probes/extends/ebpf.probe/src/include/__bpf_usr.h
index d75070c..95e7160 100644
--- a/src/probes/extends/ebpf.probe/src/include/__bpf_usr.h
+++ b/src/probes/extends/ebpf.probe/src/include/__bpf_usr.h
@@ -37,14 +37,6 @@
#define bpf_section(NAME) __attribute__((section(NAME), used))
-#define UPROBE(func, type) \
- bpf_section("uprobe/" #func) \
- void ubpf_##func(struct type *ctx)
-
-#define URETPROBE(func, type) \
- bpf_section("uretprobe/" #func) \
- void ubpf_ret_##func(struct type *ctx)
-
#define UPROBE_PARMS_STASH(func, ctx, prog_id) \
do { \
int ret; \
@@ -63,7 +55,30 @@
} \
} while (0)
+#if (CURRENT_LIBBPF_VERSION >= LIBBPF_VERSION(0, 8))
+#define UPROBE(func, type) \
+ bpf_section("uprobe") \
+ void ubpf_##func(struct type *ctx)
+
+#define URETPROBE(func, type) \
+ bpf_section("uretprobe") \
+ void ubpf_ret_##func(struct type *ctx)
+#define UPROBE_RET(func, type, prog_id) \
+ bpf_section("uprobe") \
+ void __uprobe_bpf_##func(struct type *ctx) { \
+ UPROBE_PARMS_STASH(func, ctx, prog_id); \
+ } \
+ \
+ bpf_section("uretprobe") \
+ void __uprobe_ret_bpf_##func(struct type *ctx)
+#else
+#define UPROBE(func, type) \
+ bpf_section("uprobe/" #func) \
+ void ubpf_##func(struct type *ctx)
+#define URETPROBE(func, type) \
+ bpf_section("uretprobe/" #func) \
+ void ubpf_ret_##func(struct type *ctx)
#define UPROBE_RET(func, type, prog_id) \
bpf_section("uprobe/" #func) \
void __uprobe_bpf_##func(struct type *ctx) { \
@@ -72,6 +87,7 @@
\
bpf_section("uretprobe/" #func) \
void __uprobe_ret_bpf_##func(struct type *ctx)
+#endif
#endif
diff --git a/src/probes/extends/ebpf.probe/src/include/bpf.h b/src/probes/extends/ebpf.probe/src/include/bpf.h
index cfeca26..5008c2a 100644
--- a/src/probes/extends/ebpf.probe/src/include/bpf.h
+++ b/src/probes/extends/ebpf.probe/src/include/bpf.h
@@ -19,10 +19,12 @@
#include "common.h"
-
#define KERNEL_VERSION(a, b, c) (((a) << 16) + ((b) << 8) + (c))
#define CURRENT_KERNEL_VERSION KERNEL_VERSION(KER_VER_MAJOR, KER_VER_MINOR, KER_VER_PATCH)
+#define LIBBPF_VERSION(a, b) (((a) << 8) + (b))
+#define CURRENT_LIBBPF_VERSION LIBBPF_VERSION(LIBBPF_VER_MAJOR, LIBBPF_VER_MINOR)
+
#include "__share_map_match.h"
#include "__obj_map.h"
#include "__bpf_kern.h"
diff --git a/src/probes/extends/ebpf.probe/src/ioprobe/io_count.bpf.c b/src/probes/extends/ebpf.probe/src/ioprobe/io_count.bpf.c
index 042292d..8fd71cb 100644
--- a/src/probes/extends/ebpf.probe/src/ioprobe/io_count.bpf.c
+++ b/src/probes/extends/ebpf.probe/src/ioprobe/io_count.bpf.c
@@ -105,7 +105,7 @@ static __always_inline char is_write_bio(struct block_bio_queue_args *bio)
}
bpf_section("tracepoint/block/block_bio_queue")
-static void tracepoint_block_bio_queue(struct block_bio_queue_args *ctx)
+void tracepoint_block_bio_queue(struct block_bio_queue_args *ctx)
{
u32 bio_size;
int major, minor;
diff --git a/src/probes/extends/ebpf.probe/src/ioprobe/io_err.bpf.c b/src/probes/extends/ebpf.probe/src/ioprobe/io_err.bpf.c
index d60a3d7..b48f766 100644
--- a/src/probes/extends/ebpf.probe/src/ioprobe/io_err.bpf.c
+++ b/src/probes/extends/ebpf.probe/src/ioprobe/io_err.bpf.c
@@ -112,7 +112,7 @@ static __always_inline void update_io_err(struct block_rq_complete_args* ctx, st
}
bpf_section("tracepoint/block/block_rq_complete")
-static void tracepoint_block_rq_complete(struct block_rq_complete_args *ctx)
+void tracepoint_block_rq_complete(struct block_rq_complete_args *ctx)
{
int major, minor;
struct io_err_s *io_err = NULL;
diff --git a/src/probes/extends/ebpf.probe/src/mk/var.mk b/src/probes/extends/ebpf.probe/src/mk/var.mk
index e41603c..2522a6f 100644
--- a/src/probes/extends/ebpf.probe/src/mk/var.mk
+++ b/src/probes/extends/ebpf.probe/src/mk/var.mk
@@ -30,12 +30,17 @@ KER_VER_PATCH = $(shell echo $(KER_VER) | awk -F'.' '{print $$3}')
RELEASE_INFOS = $(shell uname -r | awk -F'-' '{print $$2}')
KER_RELEASE = $(shell echo $(RELEASE_INFOS) | awk -F'.' '{print $$1}')
+LIBBPF_VER = $(shell rpm -qa | grep libbpf-devel | awk -F'-' '{print $$3}')
+LIBBPF_VER_MAJOR = $(shell echo $(LIBBPF_VER) | awk -F'.' '{print $$1}')
+LIBBPF_VER_MINOR = $(shell echo $(LIBBPF_VER) | awk -F'.' '{print $$2}')
+
LINK_TARGET ?= -lpthread -lbpf -lelf -llog4cplus -lz -lconfig
EXTRA_CFLAGS ?= -g -O2 -Wall -fPIC
EXTRA_CDEFINE ?= -D__TARGET_ARCH_$(ARCH)
CFLAGS := $(EXTRA_CFLAGS) $(EXTRA_CDEFINE)
CFLAGS += -DKER_VER_MAJOR=$(KER_VER_MAJOR) -DKER_VER_MINOR=$(KER_VER_MINOR) -DKER_VER_PATCH=$(KER_VER_PATCH)
CFLAGS += -DKER_RELEASE=$(KER_RELEASE)
+CFLAGS += -DLIBBPF_VER_MAJOR=$(LIBBPF_VER_MAJOR) -DLIBBPF_VER_MINOR=$(LIBBPF_VER_MINOR)
LDFLAGS += -Wl,--copy-dt-needed-entries -Wl,-z,relro,-z,now
CXXFLAGS += -std=c++11 -g -O2 -Wall -fPIC
--
2.36.0.windows.1

File diff suppressed because it is too large Load Diff

View File

@ -1,144 +0,0 @@
From bb78dcf76c2ef7d0ba297161dda5bcaa42f0f63e Mon Sep 17 00:00:00 2001
From: wo_cow <niuqianqian@huawei.com>
Date: Mon, 14 Nov 2022 16:51:59 +0800
Subject: [PATCH] fix pgsliprobe: 1. pgsliprobe reports error when gaussdb
doesn't depend on libssl. 2. add a check to ensure skb->tstamp is not 0
---
config/gala-gopher.conf | 6 ++++
.../ebpf.probe/src/pgsliprobe/pgsliprobe.c | 36 +++++++++++--------
.../src/pgsliprobe/pgsliprobe_bpf.h | 8 +++--
3 files changed, 33 insertions(+), 17 deletions(-)
diff --git a/config/gala-gopher.conf b/config/gala-gopher.conf
index 3c1848b..fad3214 100644
--- a/config/gala-gopher.conf
+++ b/config/gala-gopher.conf
@@ -205,5 +205,11 @@ extend_probes =
start_check = "[ -z $(which java 2>/dev/null) ] && echo 0 || echo 1";
check_type = "count";
switch = "auto";
+ },
+ {
+ name = "stackprobe";
+ command = "/opt/gala-gopher/extend_probes/stackprobe";
+ param = "";
+ switch = "off";
}
);
diff --git a/src/probes/extends/ebpf.probe/src/pgsliprobe/pgsliprobe.c b/src/probes/extends/ebpf.probe/src/pgsliprobe/pgsliprobe.c
index 10508ca..9171985 100644
--- a/src/probes/extends/ebpf.probe/src/pgsliprobe/pgsliprobe.c
+++ b/src/probes/extends/ebpf.probe/src/pgsliprobe/pgsliprobe.c
@@ -63,6 +63,7 @@
static volatile sig_atomic_t stop;
static struct probe_params params = {.period = DEFAULT_PERIOD};
static struct bpf_link_hash_t *head = NULL;
+static int noDependLibssl;
enum pid_state_t {
PID_NOEXIST,
@@ -241,7 +242,8 @@ static int get_elf_path(unsigned int pid, char elf_path[], int max_path_len)
// 1. get elf_path
(void)snprintf(cmd, COMMAND_LEN, PLDD_LIBSSL_COMMAND, pid);
if (exec_cmd((const char *)cmd, openssl_path, PATH_LEN) < 0) {
- fprintf(stderr, "pldd %u grep libssl failed\n", pid);
+ noDependLibssl = 1;
+ INFO("[DAEMON] GaussDB does not depend on libssl\n");
return SLI_ERR;
}
@@ -318,13 +320,16 @@ static int add_bpf_link_by_search_pids()
// find_bpf_link and add_bpf_link will set bpf_link status
if (!find_bpf_link(pid)) {
if (add_bpf_link(pid) != SLI_OK) {
+ if (noDependLibssl) {
+ goto out;
+ }
fprintf(stderr, "add_bpf_link of pid %u failed\n", pid);
} else {
printf("add_bpf_link of pid %u success\n", pid);
}
}
}
-
+out:
(void)pclose(f);
return ret;
}
@@ -375,7 +380,6 @@ int main(int argc, char **argv)
{
int err, ret;
FILE *fp = NULL;
- int init = 0;
struct bpf_link_hash_t *item, *tmp;
err = args_parse(argc, argv, &params);
@@ -405,11 +409,26 @@ int main(int argc, char **argv)
goto init_err;
}
+ load_args(GET_MAP_FD(pgsli_kprobe, args_map), &params);
+ err = init_conn_mgt_process(GET_MAP_FD(pgsli_kprobe, output));
+ if (err != 0) {
+ fprintf(stderr, "Init connection management process failed.\n");
+ goto init_err;
+ }
+
printf("pgsliprobe probe successfully started!\n");
while (!stop) {
+ sleep(params.period);
+ if (noDependLibssl) {
+ continue;
+ }
+
set_bpf_link_inactive();
if (add_bpf_link_by_search_pids() != SLI_OK) {
+ if (noDependLibssl) {
+ continue;
+ }
goto init_err;
}
@@ -437,18 +456,7 @@ int main(int argc, char **argv)
item->v.pid_state = PID_ELF_ATTACHED;
}
}
-
clear_invalid_bpf_link();
- if (init == 0) {
- load_args(GET_MAP_FD(pgsli_kprobe, args_map), &params);
- err = init_conn_mgt_process(GET_MAP_FD(pgsli_kprobe, output));
- if (err != 0) {
- fprintf(stderr, "Init connection management process failed.\n");
- goto init_err;
- }
- init = 1;
- }
- sleep(params.period);
}
init_err:
diff --git a/src/probes/extends/ebpf.probe/src/pgsliprobe/pgsliprobe_bpf.h b/src/probes/extends/ebpf.probe/src/pgsliprobe/pgsliprobe_bpf.h
index e5afad7..a2e85b2 100644
--- a/src/probes/extends/ebpf.probe/src/pgsliprobe/pgsliprobe_bpf.h
+++ b/src/probes/extends/ebpf.probe/src/pgsliprobe/pgsliprobe_bpf.h
@@ -223,9 +223,11 @@ static __always_inline void process_rdwr_msg(int fd, const char *buf, int count,
return;
}
csd->req_cmd = cmd;
-#ifndef KERNEL_SUPPORT_TSTAMP
- csd->start_ts_nsec = ts_nsec;
-#endif
+
+ if (csd->start_ts_nsec == 0) {
+ csd->start_ts_nsec = ts_nsec;
+ }
+
csd->status = SAMP_READ_READY;
} else { // MSG_WRITE
if (csd->status == SAMP_READ_READY) {
--
2.23.0

Binary file not shown.

BIN
gala-gopher-1.0.1.tar.gz Normal file

Binary file not shown.

View File

@ -1,31 +1,22 @@
%define debug_package %{nil}
%define __os_install_post %{nil}
%define vmlinux_ver 5.10.0-126.0.0.66.oe2203.%{_arch}
Summary: Intelligent ops toolkit for openEuler
Name: gala-gopher
Version: 1.0.0
Release: 7
Version: 1.0.1
Release: 1
License: Mulan PSL v2
URL: https://gitee.com/openeuler/gala-gopher
Source: %{name}-%{version}.tar.gz
BuildRoot: %{_builddir}/%{name}-%{version}
BuildRequires: systemd cmake gcc-c++ yum elfutils-devel
BuildRequires: clang >= 10.0.1 llvm
BuildRequires: systemd cmake gcc-c++ elfutils-devel
BuildRequires: clang >= 10.0.1 llvm java-1.8.0-openjdk-devel
BuildRequires: libconfig-devel librdkafka-devel libmicrohttpd-devel
BuildRequires: uthash-devel libbpf libbpf-devel log4cplus-devel
Requires: bash glibc elfutils zlib elfutils-devel bpftool
Requires: dmidecode python3-psycopg2 python3-yaml erlang-eflame
Requires: flamegraph-stackcollapse
patch0: add-vmlinux-for-2203LTS-2203LTS-SP1.patch
patch1: fix-pgsliprobe.patch
patch2: adapt-libbpf-v08.patch
%ifarch x86_64
patch3: modify-to-adapt-to-oe2203-LTS-SP1-x86.patch
%endif
%ifarch aarch64
patch3: modify-to-adapt-to-oe2203-LTS-SP1-arm.patch
%endif
Requires: flamegraph-stackcollapse iproute
%description
gala-gopher is a low-overhead eBPF-based probes framework
@ -35,7 +26,7 @@ gala-gopher is a low-overhead eBPF-based probes framework
%build
pushd build
sh build.sh --release
sh build.sh --release %{vmlinux_ver}
popd
%install
@ -65,6 +56,7 @@ popd
%{_bindir}/*
%config(noreplace) /opt/gala-gopher/*.conf
/opt/gala-gopher/extend_probes/*
%config(noreplace) /opt/gala-gopher/extend_probes/*.conf
%exclude /opt/gala-gopher/extend_probes/*.pyc
%exclude /opt/gala-gopher/extend_probes/*.pyo
/opt/gala-gopher/meta/*
@ -72,6 +64,8 @@ popd
/usr/lib/systemd/system/gala-gopher.service
%changelog
* Mon Dec 12 2022 Zhen Chen <chenzhen126@huawei.com> - 1.0.1-1
- Update to 1.0.1
* Thu Nov 17 2022 wo_cow <niuqianqian@huawei.com> - 1.0.0-7
- resolve patch conflict

View File

@ -1,65 +0,0 @@
From be59848fc48885c656dda02565b55e84dc4bcb12 Mon Sep 17 00:00:00 2001
From: zhaoyuxing <zhaoyuxing2@huawei.com>
Date: Wed, 10 Aug 2022 17:12:16 +0800
Subject: [PATCH] modify vmlinux.h and version infos of oe-22.03 LTS SP1 arm
---
src/probes/extends/ebpf.probe/build.sh | 20 +++-----------------
src/probes/extends/ebpf.probe/src/mk/var.mk | 10 ++++------
2 files changed, 7 insertions(+), 23 deletions(-)
diff --git a/src/probes/extends/ebpf.probe/build.sh b/src/probes/extends/ebpf.probe/build.sh
index ab4aa3e..ff08ab0 100755
--- a/src/probes/extends/ebpf.probe/build.sh
+++ b/src/probes/extends/ebpf.probe/build.sh
@@ -82,23 +82,9 @@ function compile_probe()
MATCH_VMLINUX=linux_${LINUX_VER}.h
cd ${VMLINUX_DIR}
- if [ -f ${MATCH_VMLINUX} ];then
- rm -f vmlinux.h
- ln -s ${MATCH_VMLINUX} vmlinux.h
- echo "debug: match vmlinux :" ${MATCH_VMLINUX}
- elif [ -f "vmlinux.h" ];then
- echo "debug: vmlinux.h is already here, continue compile."
- else
- echo "======================================ERROR==============================================="
- echo "there no match vmlinux :" ${MATCH_VMLINUX}
- echo "please create vmlinux.h manually."
- echo "methods:"
- echo " 1. generate linux_xxx.h by compile the kernel, refer to gen_vmlinux_h.sh;"
- echo " 2. ln -s vmlinux.h linux_xxx.h, (there are some include files in directory src/include)"
- echo " if your kernel version is similar to the include files provided, you can use method 2"
- echo "=========================================================================================="
- exit
- fi
+ rm -rf vmlinux.h
+ ln -s linux_5.10.0-126.0.0.66.oe2203.aarch64.h vmlinux.h
+ echo "debug: openEuler 22.03 LTS SP1 vmlinux :" ${MATCH_VMLINUX}
cd ${SRC_DIR}
echo "=======Begin to compile ebpf-based probes======:" ${EBPF_PROBES}
diff --git a/src/probes/extends/ebpf.probe/src/mk/var.mk b/src/probes/extends/ebpf.probe/src/mk/var.mk
index 2522a6f..16a14d0 100644
--- a/src/probes/extends/ebpf.probe/src/mk/var.mk
+++ b/src/probes/extends/ebpf.probe/src/mk/var.mk
@@ -23,12 +23,10 @@ else ifeq ($(ARCH), aarch64)
ARCH = arm64
endif
-KER_VER = $(shell uname -r | awk -F'-' '{print $$1}')
-KER_VER_MAJOR = $(shell echo $(KER_VER) | awk -F'.' '{print $$1}')
-KER_VER_MINOR = $(shell echo $(KER_VER) | awk -F'.' '{print $$2}')
-KER_VER_PATCH = $(shell echo $(KER_VER) | awk -F'.' '{print $$3}')
-RELEASE_INFOS = $(shell uname -r | awk -F'-' '{print $$2}')
-KER_RELEASE = $(shell echo $(RELEASE_INFOS) | awk -F'.' '{print $$1}')
+KER_VER_MAJOR = 5
+KER_VER_MINOR = 10
+KER_VER_PATCH = 0
+KER_RELEASE = 126
LIBBPF_VER = $(shell rpm -qa | grep libbpf-devel | awk -F'-' '{print $$3}')
LIBBPF_VER_MAJOR = $(shell echo $(LIBBPF_VER) | awk -F'.' '{print $$1}')
--
2.27.0

View File

@ -1,65 +0,0 @@
From 5c1507c880fb8c80bfe6e1809cc03195e9fd9c7f Mon Sep 17 00:00:00 2001
From: zhaoyuxing <zhaoyuxing2@huawei.com>
Date: Wed, 10 Aug 2022 17:12:16 +0800
Subject: [PATCH] modify vmlinux.h and version infos of oe-22.03 LTS SP1 x86
---
src/probes/extends/ebpf.probe/build.sh | 20 +++-----------------
src/probes/extends/ebpf.probe/src/mk/var.mk | 10 ++++------
2 files changed, 7 insertions(+), 23 deletions(-)
diff --git a/src/probes/extends/ebpf.probe/build.sh b/src/probes/extends/ebpf.probe/build.sh
index ab4aa3e..00f9bd8 100755
--- a/src/probes/extends/ebpf.probe/build.sh
+++ b/src/probes/extends/ebpf.probe/build.sh
@@ -82,23 +82,9 @@ function compile_probe()
MATCH_VMLINUX=linux_${LINUX_VER}.h
cd ${VMLINUX_DIR}
- if [ -f ${MATCH_VMLINUX} ];then
- rm -f vmlinux.h
- ln -s ${MATCH_VMLINUX} vmlinux.h
- echo "debug: match vmlinux :" ${MATCH_VMLINUX}
- elif [ -f "vmlinux.h" ];then
- echo "debug: vmlinux.h is already here, continue compile."
- else
- echo "======================================ERROR==============================================="
- echo "there no match vmlinux :" ${MATCH_VMLINUX}
- echo "please create vmlinux.h manually."
- echo "methods:"
- echo " 1. generate linux_xxx.h by compile the kernel, refer to gen_vmlinux_h.sh;"
- echo " 2. ln -s vmlinux.h linux_xxx.h, (there are some include files in directory src/include)"
- echo " if your kernel version is similar to the include files provided, you can use method 2"
- echo "=========================================================================================="
- exit
- fi
+ rm -rf vmlinux.h
+ ln -s linux_5.10.0-126.0.0.66.oe2203.x86_64.h vmlinux.h
+ echo "debug: openEuler 22.03 LTS SP1 match vmlinux :" ${MATCH_VMLINUX}
cd ${SRC_DIR}
echo "=======Begin to compile ebpf-based probes======:" ${EBPF_PROBES}
diff --git a/src/probes/extends/ebpf.probe/src/mk/var.mk b/src/probes/extends/ebpf.probe/src/mk/var.mk
index 2522a6f..16a14d0 100644
--- a/src/probes/extends/ebpf.probe/src/mk/var.mk
+++ b/src/probes/extends/ebpf.probe/src/mk/var.mk
@@ -23,12 +23,10 @@ else ifeq ($(ARCH), aarch64)
ARCH = arm64
endif
-KER_VER = $(shell uname -r | awk -F'-' '{print $$1}')
-KER_VER_MAJOR = $(shell echo $(KER_VER) | awk -F'.' '{print $$1}')
-KER_VER_MINOR = $(shell echo $(KER_VER) | awk -F'.' '{print $$2}')
-KER_VER_PATCH = $(shell echo $(KER_VER) | awk -F'.' '{print $$3}')
-RELEASE_INFOS = $(shell uname -r | awk -F'-' '{print $$2}')
-KER_RELEASE = $(shell echo $(RELEASE_INFOS) | awk -F'.' '{print $$1}')
+KER_VER_MAJOR = 5
+KER_VER_MINOR = 10
+KER_VER_PATCH = 0
+KER_RELEASE = 126
LIBBPF_VER = $(shell rpm -qa | grep libbpf-devel | awk -F'-' '{print $$3}')
LIBBPF_VER_MAJOR = $(shell echo $(LIBBPF_VER) | awk -F'.' '{print $$1}')
--
2.27.0