!36 [sync] PR-33: Update to 1.0.1 version

From: @openeuler-sync-bot 
Reviewed-by: @dowzyx 
Signed-off-by: @dowzyx
This commit is contained in:
openeuler-ci-bot 2022-12-12 09:04:21 +00:00 committed by Gitee
commit 66225648a5
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
13 changed files with 5 additions and 418601 deletions

View File

@ -1,106 +0,0 @@
From 6ca0c40764df50e82676e719724518566fba7f1b Mon Sep 17 00:00:00 2001
From: Vchanger <vchanger123456@163.com>
Date: Sat, 19 Nov 2022 17:42:58 +0800
Subject: [PATCH] Only check the installation of dep when building ebpf.probes
---
src/probes/extends/ebpf.probe/build.sh | 50 ++++++++------------------
1 file changed, 15 insertions(+), 35 deletions(-)
diff --git a/src/probes/extends/ebpf.probe/build.sh b/src/probes/extends/ebpf.probe/build.sh
index ab4aa3e..05a1547 100755
--- a/src/probes/extends/ebpf.probe/build.sh
+++ b/src/probes/extends/ebpf.probe/build.sh
@@ -7,6 +7,7 @@ TOOLS_DIR=${PRJ_DIR}/tools
SRC_DIR=${PRJ_DIR}/src
VMLINUX_DIR=${SRC_DIR}/include
LINUX_VER=$(uname -r)
+DEP_LIST=(elfutils-devel libbpf libbpf-devel clang llvm)
function gen_vmlinux_header_file()
{
@@ -17,51 +18,29 @@ function gen_vmlinux_header_file()
./gen_vmlinux_h.sh
}
-function add_bpftool() {
+function add_bpftool()
+{
cd ${TOOLS_DIR}
if [ ! -f "bpftool" ];then
ln -s bpftool_${ARCH} bpftool
fi
}
-function prepare_dep()
+function check_dep()
{
- yum install -y elfutils-devel
- if [ $? -ne 0 ];then
- echo "Error: elfutils-devel install failed"
- return 1
- fi
+ for dep in "${DEP_LIST[@]}" ; do
+ rpm -q $dep --quiet
+ if [ $? -ne 0 ];then
+ echo "Error: $dep not installed"
+ exit 1
+ fi
+ done
- yum install -y clang
- if [ $? -ne 0 ];then
- echo "Error: clang install failed"
- return 1
- fi
V=`clang --version | grep version | awk -F ' ' '{print $3}' | awk -F . '{print $1}'`
if [ "$V" -lt 10 ];then
echo "Error: clange version need >= 10.x.x"
- return 1
+ exit 1
fi
-
- yum install -y llvm
- if [ $? -ne 0 ];then
- echo "Error: llvm install failed"
- return 1
- fi
-
- yum install -y libbpf
- if [ $? -ne 0 ]; then
- echo "Error: Failed to install libbpf."
- return 1
- fi
-
- yum install -y libbpf-devel
- if [ $? -ne 0 ]; then
- echo "Error: Failed to install libbpf-devel."
- return 1
- fi
-
- return 0
}
function compile_probe_prev()
@@ -123,7 +102,7 @@ fi
if [ "$1" == "--check" ];
then
- prepare_dep
+ check_dep
exit
fi
@@ -137,7 +116,8 @@ fi
if [ "$1" == "-b" -o "$1" == "--build" ];
then
- prepare_dep
+ check_dep
+
if [ "$2" == "-d" -o "$2" == "--debug" ];
then
compile_probe_prev
--
2.23.0

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

View File

@ -1,87 +0,0 @@
From 4519bf3ce98b819c0cf421b902df3124bc9e4374 Mon Sep 17 00:00:00 2001
From: wo_cow <niuqianqian@huawei.com>
Date: Sat, 26 Nov 2022 17:05:18 +0800
Subject: [PATCH] add documentation related to docker images. set nsprobe to
start automatically
---
README.md | 44 +++++++++++++++++++++++++++++++++++++----
config/gala-gopher.conf | 4 +++-
2 files changed, 43 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
index efcea94..002dbb6 100644
--- a/README.md
+++ b/README.md
@@ -59,13 +59,49 @@ gala-gopher集成了常用的native探针以及知名中间件探针gala-goph
#### 基于容器镜像安装运行
-- 准备工作
- 获取gala-gopher的rpm包获取方式详见第一小节[基于rpm包安装运行](#基于rpm包安装运行)。
+- 获取容器镜像
-- 生成容器镜像
+ 用户可以选择直接[获取官方容器镜像](#docker1)或自行[构建容器镜像](#docker2)
- 用于生成容器镜像的Dockerfile文件归档在[build目录](./build),生成方法详见[如何生成gala-gopher容器镜像](doc/how_to_build_docker_image.md)。
+ <a id="docker1"></a>
+ - 获取官方容器镜像
+
+ 打开docker配置文件
+
+ ```shell
+ vi /etc/docker/daemon.json
+ ```
+
+ 添加hub.oepkgs.net镜像仓库
+
+ ```shell
+ {
+ "insecure-registries" : [ "hub.oepkgs.net" ]
+ }
+ ```
+
+ 重启docker服务
+
+ ```shell
+ systemctl daemon-reload
+ systemctl restart docker
+ ```
+
+ 拉取指定版本的gala-gopher官方容器镜像
+
+ 目前支持的镜像版本tag有euleros-v2r920.03-lts20.03-lts-sp122.03-lts
+
+ ```shell
+ docker pull hub.oepkgs.net/a-ops/gala-gopher:20.03-lts-sp1
+ ```
+
+ <a id="docker2"></a>
+ - 构建容器镜像
+
+ 获取gala-gopher的rpm包获取方式详见第一小节[基于rpm包安装运行](#基于rpm包安装运行)。
+
+ 用于生成容器镜像的Dockerfile文件归档在[build目录](./build),生成方法详见[如何生成gala-gopher容器镜像](doc/how_to_build_docker_image.md)。
- 创建并运行容器
diff --git a/config/gala-gopher.conf b/config/gala-gopher.conf
index cb7fec1..33d9714 100644
--- a/config/gala-gopher.conf
+++ b/config/gala-gopher.conf
@@ -156,7 +156,9 @@ extend_probes =
name = "nsprobe";
command = "/opt/gala-gopher/extend_probes/nsprobe"
param = "";
- switch = "off";
+ start_check = "echo \"isulad docker\" | xargs systemctl status | grep Active | grep running | wc -l";
+ check_type = "count";
+ switch = "auto";
},
{
name = "ioprobe";
--
2.28.0.windows.1

File diff suppressed because it is too large Load Diff

View File

@ -1,349 +0,0 @@
From 72946403263a0ac056a65f85fd19736d200c8aa4 Mon Sep 17 00:00:00 2001
From: wo_cow <niuqianqian@huawei.com>
Date: Tue, 22 Nov 2022 15:40:11 +0800
Subject: [PATCH] fix bugs for ksliprobe pgsliprobe stackprobe
---
src/common/common.h | 1 +
src/common/util.c | 19 +++++
.../ebpf.probe/src/ksliprobe/ksliprobe.bpf.c | 4 +
.../ebpf.probe/src/pgsliprobe/pgsliprobe.c | 74 +++++++++----------
.../src/pgsliprobe/pgsliprobe_bpf.h | 7 +-
.../src/stackprobe/conf/stackprobe.conf | 2 +-
.../src/stackprobe/stack_bpf/memleak.bpf.c | 11 +--
.../extends/ebpf.probe/src/stackprobe/svg.c | 31 +++++++-
.../pg_stat.probe/pg_stat_probe.py | 8 +-
src/probes/system_infos.probe/system_procs.c | 2 +-
10 files changed, 105 insertions(+), 54 deletions(-)
diff --git a/src/common/common.h b/src/common/common.h
index 4ce6a81..49496c4 100644
--- a/src/common/common.h
+++ b/src/common/common.h
@@ -168,6 +168,7 @@ unsigned short ntohs(unsigned short netshort);
/* get uprobe func offset */
int get_func_offset(char *proc_name, char *func_name, char *bin_file_path);
+char *get_cur_date(void);
char *get_cur_time(void);
void ip_str(unsigned int family, unsigned char *ip, unsigned char *ip_str, unsigned int ip_str_size);
diff --git a/src/common/util.c b/src/common/util.c
index 65e5d4d..dbe5f75 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -21,6 +21,25 @@
#include <stdarg.h>
#include "common.h"
+char *get_cur_date(void)
+{
+ /* return date str, ex: 2021/5/17 */
+ static char tm[TM_STR_LEN] = {0};
+ struct tm *tmp_ptr = NULL;
+ time_t t;
+
+ (void)time(&t);
+
+ tmp_ptr = localtime(&t);
+ (void)snprintf(tm,
+ TM_STR_LEN,
+ "%d-%d-%d",
+ (1900 + tmp_ptr->tm_year),
+ (1 + tmp_ptr->tm_mon),
+ tmp_ptr->tm_mday);
+ return tm;
+}
+
char *get_cur_time(void)
{
/* return time str, ex: 2021/5/17 19:56:03 */
diff --git a/src/probes/extends/ebpf.probe/src/ksliprobe/ksliprobe.bpf.c b/src/probes/extends/ebpf.probe/src/ksliprobe/ksliprobe.bpf.c
index bf653f0..6fa64ab 100644
--- a/src/probes/extends/ebpf.probe/src/ksliprobe/ksliprobe.bpf.c
+++ b/src/probes/extends/ebpf.probe/src/ksliprobe/ksliprobe.bpf.c
@@ -374,6 +374,10 @@ static __always_inline void process_rd_msg(u32 tgid, int fd, const char *buf, co
#ifndef KERNEL_SUPPORT_TSTAMP
csd->start_ts_nsec = ts_nsec;
+#else
+ if (csd->start_ts_nsec == 0) {
+ csd->start_ts_nsec = ts_nsec;
+ }
#endif
csd->status = SAMP_READ_READY;
diff --git a/src/probes/extends/ebpf.probe/src/pgsliprobe/pgsliprobe.c b/src/probes/extends/ebpf.probe/src/pgsliprobe/pgsliprobe.c
index 9171985..6b75f06 100644
--- a/src/probes/extends/ebpf.probe/src/pgsliprobe/pgsliprobe.c
+++ b/src/probes/extends/ebpf.probe/src/pgsliprobe/pgsliprobe.c
@@ -180,7 +180,6 @@ static void *msg_event_receiver(void *arg)
}
poll_pb(pb, params.period * 1000);
-
stop = 1;
return NULL;
}
@@ -380,6 +379,7 @@ 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);
@@ -409,15 +409,6 @@ 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) {
@@ -426,37 +417,46 @@ int main(int argc, char **argv)
set_bpf_link_inactive();
if (add_bpf_link_by_search_pids() != SLI_OK) {
- if (noDependLibssl) {
- continue;
+ if (!noDependLibssl) {
+ goto init_err;
}
- goto init_err;
- }
-
- // attach to libssl
- H_ITER(head, item, tmp) {
- if (item->v.pid_state == PID_ELF_TOBE_ATTACHED) {
- UBPF_ATTACH_ONELINK(pgsli_uprobe, SSL_read, item->v.elf_path, SSL_read,
- item->v.bpf_link_read, ret);
- if (ret <= 0) {
- fprintf(stderr, "Can't attach function SSL_read at elf_path %s.\n", item->v.elf_path);
- goto init_err;
- }
- UBPF_RET_ATTACH_ONELINK(pgsli_uprobe, SSL_read, item->v.elf_path, SSL_read,
- item->v.bpf_link_read_ret, ret);
- if (ret <= 0) {
- fprintf(stderr, "Can't attach ret function SSL_read at elf_path %s.\n", item->v.elf_path);
- goto init_err;
+ } else {
+ // attach to libssl
+ H_ITER(head, item, tmp) {
+ if (item->v.pid_state == PID_ELF_TOBE_ATTACHED) {
+ UBPF_ATTACH_ONELINK(pgsli_uprobe, SSL_read, item->v.elf_path, SSL_read,
+ item->v.bpf_link_read, ret);
+ if (ret <= 0) {
+ fprintf(stderr, "Can't attach function SSL_read at elf_path %s.\n", item->v.elf_path);
+ goto init_err;
+ }
+ UBPF_RET_ATTACH_ONELINK(pgsli_uprobe, SSL_read, item->v.elf_path, SSL_read,
+ item->v.bpf_link_read_ret, ret);
+ if (ret <= 0) {
+ fprintf(stderr, "Can't attach ret function SSL_read at elf_path %s.\n", item->v.elf_path);
+ goto init_err;
+ }
+ UBPF_ATTACH_ONELINK(pgsli_uprobe, SSL_write, item->v.elf_path, SSL_write,
+ item->v.bpf_link_write, ret);
+ if (ret <= 0) {
+ fprintf(stderr, "Can't attach function SSL_write at elf_path %s.\n", item->v.elf_path);
+ goto init_err;
+ }
+ item->v.pid_state = PID_ELF_ATTACHED;
}
- UBPF_ATTACH_ONELINK(pgsli_uprobe, SSL_write, item->v.elf_path, SSL_write,
- item->v.bpf_link_write, ret);
- if (ret <= 0) {
- fprintf(stderr, "Can't attach function SSL_write at elf_path %s.\n", item->v.elf_path);
- goto init_err;
- }
- 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;
+ }
+ printf("pgsliprobe probe successfully started!\n");
+ init = 1;
}
- clear_invalid_bpf_link();
}
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 a2e85b2..a3dfc5d 100644
--- a/src/probes/extends/ebpf.probe/src/pgsliprobe/pgsliprobe_bpf.h
+++ b/src/probes/extends/ebpf.probe/src/pgsliprobe/pgsliprobe_bpf.h
@@ -156,7 +156,7 @@ static __always_inline void periodic_report(u64 ts_nsec, struct conn_data_t *con
if (ts_nsec > conn_data->last_report_ts_nsec &&
ts_nsec - conn_data->last_report_ts_nsec >= period) {
// rtt larger than period is considered an invalid value
- if (conn_data->latency.rtt_nsec < period && conn_data->max.rtt_nsec < period) {
+ if (conn_data->latency.rtt_nsec < period * 2 && conn_data->max.rtt_nsec < period * 2) {
struct msg_event_data_t msg_evt_data = {0};
msg_evt_data.tgid = conn_key->tgid;
msg_evt_data.fd = conn_key->fd;
@@ -224,10 +224,13 @@ static __always_inline void process_rdwr_msg(int fd, const char *buf, int count,
}
csd->req_cmd = cmd;
+#ifndef KERNEL_SUPPORT_TSTAMP
+ csd->start_ts_nsec = ts_nsec;
+#else
if (csd->start_ts_nsec == 0) {
csd->start_ts_nsec = ts_nsec;
}
-
+#endif
csd->status = SAMP_READ_READY;
} else { // MSG_WRITE
if (csd->status == SAMP_READ_READY) {
diff --git a/src/probes/extends/ebpf.probe/src/stackprobe/conf/stackprobe.conf b/src/probes/extends/ebpf.probe/src/stackprobe/conf/stackprobe.conf
index f0b3c29..a2edd5d 100644
--- a/src/probes/extends/ebpf.probe/src/stackprobe/conf/stackprobe.conf
+++ b/src/probes/extends/ebpf.probe/src/stackprobe/conf/stackprobe.conf
@@ -12,7 +12,7 @@ flame_name =
oncpu = true;
offcpu = false;
io = false;
- memleak = true;
+ memleak = false;
};
application =
diff --git a/src/probes/extends/ebpf.probe/src/stackprobe/stack_bpf/memleak.bpf.c b/src/probes/extends/ebpf.probe/src/stackprobe/stack_bpf/memleak.bpf.c
index e855401..fe2f22b 100644
--- a/src/probes/extends/ebpf.probe/src/stackprobe/stack_bpf/memleak.bpf.c
+++ b/src/probes/extends/ebpf.probe/src/stackprobe/stack_bpf/memleak.bpf.c
@@ -109,20 +109,12 @@ struct bpf_map_def SEC("maps") mmap_allocs = {
};
struct bpf_map_def SEC("maps") brk_allocs = {
- .type = BPF_MAP_TYPE_HASH,
+ .type = BPF_MAP_TYPE_LRU_HASH,
.key_size = sizeof(u32), // tgid
.value_size = sizeof(struct brk_info_t),
.max_entries = 1000000,
};
-// allocated memory for the process
-struct bpf_map_def SEC("maps") combined_allocs = {
- .type = BPF_MAP_TYPE_HASH,
- .key_size = sizeof(struct stack_id_s),
- .value_size = sizeof(struct combined_alloc_info_t),
- .max_entries = 1000,
-};
-
static __always_inline u64 get_real_start_time()
{
struct task_struct* task = (struct task_struct*)bpf_get_current_task();
@@ -185,7 +177,6 @@ static inline void update_statistics(void *ctx, char stackmap_cur, s64 count, st
}
}
-
static inline int alloc_exit(void *ctx, u64 addr) {
u32 tgid = bpf_get_current_pid_tgid() >> INT_LEN;
struct pid_addr_t pa = {0};
diff --git a/src/probes/extends/ebpf.probe/src/stackprobe/svg.c b/src/probes/extends/ebpf.probe/src/stackprobe/svg.c
index db43aab..78a1cb0 100644
--- a/src/probes/extends/ebpf.probe/src/stackprobe/svg.c
+++ b/src/probes/extends/ebpf.probe/src/stackprobe/svg.c
@@ -156,10 +156,33 @@ static int __create_svg_files(struct stack_svg_s* svg_files, u32 period)
return 0;
}
+int __mkdir_with_svg_date(const char *svg_dir, char *svg_date_dir, size_t size)
+{
+ size_t len = strlen(svg_dir);
+ const char *day = get_cur_date();
+ if (len <= 1 || len + strlen(day) + 1 >= size) {
+ return -1;
+ }
+
+ (void)snprintf(svg_date_dir, size, "%s/%s", svg_dir, day);
+ if (access(svg_date_dir, F_OK) != 0) {
+ FILE *fp;
+ char command[COMMAND_LEN] = {0};
+ (void)snprintf(command, COMMAND_LEN, "/usr/bin/mkdir -p %s", svg_date_dir);
+ fp = popen(command, "r");
+ if (fp != NULL) {
+ (void)pclose(fp);
+ }
+ }
+
+ return 0;
+}
+
static int stack_get_next_svg_file(struct stack_svgs_s* svgs, char svg_file[], size_t size, int en_type)
{
int next;
char svg_name[PATH_LEN];
+ char svg_date_dir[PATH_LEN] = {0};
if (svgs->svg_files.files == NULL) {
return -1;
@@ -176,11 +199,15 @@ static int stack_get_next_svg_file(struct stack_svgs_s* svgs, char svg_file[], s
svgs->svg_files.files[next] = NULL;
}
+ if (__mkdir_with_svg_date(svgs->svg_dir, svg_date_dir, PATH_LEN) < 0) {
+ return -1;
+ }
+
svg_name[0] = 0;
- (void)snprintf(svg_name, PATH_LEN, "%s_%s.svg", svg_params[en_type].file_name, get_cur_time());
+ (void)snprintf(svg_name, PATH_LEN, "%s.svg", get_cur_time());
svg_file[0] = 0;
- (void)snprintf(svg_file, size, "%s/%s", svgs->svg_dir, svg_name);
+ (void)snprintf(svg_file, size, "%s/%s", svg_date_dir, svg_name);
__rm_svg(svg_file);
svgs->svg_files.files[next] = strdup(svg_file);
diff --git a/src/probes/extends/python.probe/pg_stat.probe/pg_stat_probe.py b/src/probes/extends/python.probe/pg_stat.probe/pg_stat_probe.py
index 45f80b5..fe8f955 100644
--- a/src/probes/extends/python.probe/pg_stat.probe/pg_stat_probe.py
+++ b/src/probes/extends/python.probe/pg_stat.probe/pg_stat_probe.py
@@ -121,5 +121,11 @@ if __name__ == "__main__":
while True:
time.sleep(g_period)
- get_metrics()
+ try:
+ get_metrics()
+ except Exception as e:
+ print("[pg_stat_probe]get metrics failed. Err:" + str(e))
+ stop_conns()
+
+
diff --git a/src/probes/system_infos.probe/system_procs.c b/src/probes/system_infos.probe/system_procs.c
index 6812bbc..0e1f8a4 100644
--- a/src/probes/system_infos.probe/system_procs.c
+++ b/src/probes/system_infos.probe/system_procs.c
@@ -31,7 +31,7 @@
#define PROC_START_TIME_CMD "/usr/bin/cat /proc/%s/stat | awk '{print $22}'"
#define PROC_CMDLINE_CMD "/proc/%s/cmdline"
#define PROC_FD "/proc/%s/fd"
-#define PROC_FD_CNT_CMD "/usr/bin/ls -l /proc/%s/fd | wc -l"
+#define PROC_FD_CNT_CMD "/usr/bin/ls -l /proc/%s/fd 2>/dev/null | wc -l 2>/dev/null"
#define PROC_IO "/proc/%s/io"
#define PROC_IO_CMD "/usr/bin/cat /proc/%s/io"
#define PROC_SMAPS "/proc/%s/smaps_rollup"
--
2.28.0.windows.1

View File

@ -1,25 +0,0 @@
From 69d770bce51f93eff26577642580eeeedc976afd Mon Sep 17 00:00:00 2001
From: Vchanger <vchanger123456@163.com>
Date: Tue, 29 Nov 2022 20:53:18 +0800
Subject: [PATCH] fix java.probe build error caused by a typo in build.sh
---
src/probes/extends/java.probe/build.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletion(-)
diff --git a/src/probes/extends/java.probe/build.sh b/src/probes/extends/java.probe/build.sh
index d02c5cb..0ea7782 100755
--- a/src/probes/extends/java.probe/build.sh
+++ b/src/probes/extends/java.probe/build.sh
@@ -10,7 +10,7 @@ function find_jars()
then
# find jdk
clink_path=$(echo $(ls -lrt $javac_link) | awk -F " " '{print $NF}' )
- link_path=$(echo $(ls -lrt $link_path) | awk -F " " '{print $NF}' )
+ link_path=$(echo $(ls -lrt $clink_path) | awk -F " " '{print $NF}' )
jdk_path=$(dirname $(dirname $link_path))
dir=$jdk_path
else
--
2.23.0

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

View File

@ -1,54 +0,0 @@
From 7eb391faa77d79b321df6667fbff6c1ffc07fe8d Mon Sep 17 00:00:00 2001
From: wo_cow <niuqianqian@huawei.com>
Date: Wed, 23 Nov 2022 16:56:58 +0800
Subject: [PATCH] fix the problem that the gopher in docker doesn't support tc
command and docker command
---
README.md | 2 +-
build/Dockerfile_2003_sp1_aarch64 | 2 ++
build/Dockerfile_2003_sp1_x86_64 | 2 ++
3 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/README.md b/README.md
index fd00153..efcea94 100644
--- a/README.md
+++ b/README.md
@@ -86,7 +86,7 @@ gala-gopher集成了常用的native探针以及知名中间件探针gala-goph
最后按照如下示例命令启动容器:
```shell
- docker run -d --name xxx -p 8888:8888 --privileged -v /etc/machine-id:/etc/machine-id -v /lib/modules:/lib/modules:ro -v /usr/src:/usr/src:ro -v /boot:/boot:ro -v /sys/kernel/debug:/sys/kernel/debug -v /sys/fs/bpf:/sys/fs/bpf -v /root/gopher_user_conf:/gala-gopher/user_conf/ -v /etc/localtime:/etc/localtime:ro --pid=host gala-gopher:0.0.1
+ docker run -d --name xxx -p 8888:8888 --privileged -v /etc/machine-id:/etc/machine-id -v /lib/modules:/lib/modules:ro -v /usr/src:/usr/src:ro -v /boot:/boot:ro -v /sys/kernel/debug:/sys/kernel/debug -v /sys/fs/bpf:/sys/fs/bpf -v /root/gopher_user_conf:/gala-gopher/user_conf/ -v /etc/localtime:/etc/localtime:ro -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker/overlay2:/var/lib/docker/overlay2 --pid=host gala-gopher:0.0.1
```
成功启动容器后通过docker ps可以看到正在运行的容器
diff --git a/build/Dockerfile_2003_sp1_aarch64 b/build/Dockerfile_2003_sp1_aarch64
index 36f378a..176987d 100644
--- a/build/Dockerfile_2003_sp1_aarch64
+++ b/build/Dockerfile_2003_sp1_aarch64
@@ -40,6 +40,8 @@ RUN yum update -y \
&& yum install -y libbpf-0.3-1.h0.oe1.aarch64.rpm \
&& yum install -y libbpf-devel-0.3-1.h0.oe1.aarch64.rpm \
&& yum install -y kmod \
+ && yum install -y docker \
+ && yum install -y iproute \
&& yum install -y gala-gopher-v1.1.0-52.aarch64.rpm
# expose port
diff --git a/build/Dockerfile_2003_sp1_x86_64 b/build/Dockerfile_2003_sp1_x86_64
index bde0b73..31f1ced 100644
--- a/build/Dockerfile_2003_sp1_x86_64
+++ b/build/Dockerfile_2003_sp1_x86_64
@@ -40,6 +40,8 @@ RUN yum update -y \
&& yum install -y libbpf-0.3-1.h0.oe1.x86_64.rpm \
&& yum install -y libbpf-devel-0.3-1.h0.oe1.x86_64.rpm \
&& yum install -y kmod \
+ && yum install -y docker \
+ && yum install -y iproute \
&& yum install -y gala-gopher-v1.1.0-52.x86_64.rpm
# expose port
--
2.28.0.windows.1

Binary file not shown.

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

Binary file not shown.

View File

@ -4,8 +4,8 @@
Summary: Intelligent ops toolkit for openEuler
Name: gala-gopher
Version: 1.0.0
Release: 12
Version: 1.0.1
Release: 1
License: Mulan PSL v2
URL: https://gitee.com/openeuler/gala-gopher
Source: %{name}-%{version}.tar.gz
@ -18,17 +18,6 @@ Requires: bash glibc elfutils zlib elfutils-devel bpftool
Requires: dmidecode python3-psycopg2 python3-yaml erlang-eflame
Requires: flamegraph-stackcollapse iproute
patch0: add-vmlinux-for-2203LTS-2203LTS-SP1.patch
patch1: fix-pgsliprobe.patch
patch2: adapt-libbpf-v08.patch
patch3: fix-bugs-for-ksliprobe-pgsliprobe-stackprobe.patch
patch4: move-docs-about-creating-and-running-in-docker.patch
patch5: fix-the-problem-that-the-gopher-in-docker-doesn-t-su.patch
patch6: add-documentation-related-to-docker-images.patch
patch7: fix-java.probe-build-error-caused-by-a-typo-in-build.patch
patch8: Only-check-the-installation-of-dep-when-building-ebp.patch
patch9: simplify-vmlinux.h-management-with-different-kernel-.patch
%description
gala-gopher is a low-overhead eBPF-based probes framework
@ -75,6 +64,9 @@ 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
* Mon Dec 12 2022 Zhen Chen <chenzhen126@huawei.com> - 1.0.0-12
- remove debug_package %{nil} to strip files and provide debug packages

View File

@ -1,123 +0,0 @@
From b6bb388d21f3eac7565eddcfabaf9845bfa71454 Mon Sep 17 00:00:00 2001
From: Vchanger <vchanger123456@163.com>
Date: Mon, 21 Nov 2022 14:36:14 +0800
Subject: [PATCH] move docs about creating and running in docker
---
README.md | 41 ++++++++++++++++++++++++++++--
doc/how_to_build_docker_image.md | 43 --------------------------------
2 files changed, 39 insertions(+), 45 deletions(-)
diff --git a/README.md b/README.md
index b38ba22..fd00153 100644
--- a/README.md
+++ b/README.md
@@ -67,12 +67,49 @@ gala-gopher集成了常用的native探针以及知名中间件探针gala-goph
用于生成容器镜像的Dockerfile文件归档在[build目录](./build),生成方法详见[如何生成gala-gopher容器镜像](doc/how_to_build_docker_image.md)。
-- 运行容器
+- 创建并运行容器
+
+ gala-gopher涉及两个配置文件gala-gopher.conf和gala-gopher-app.conf。gala-gopher.conf主要用于配置探针的数据上报开关、探针参数、探针是否开启等gala-gopher-app.conf是观测白名单可以把用户感兴趣的进程名加入白名单gala-gopher就会观测这个进程了。
+
+ 容器启动前需要用户自定义配置这两个配置文件,请在宿主机创建配置文件目录,并将[config目录](./config)下两个配置文件保存到该目录,示例如下:
```shell
- # docker run -d --name xxx -p 8888:8888 --privileged -v /lib/modules:/lib/modules:ro -v /usr/src:/usr/src:ro -v /boot:/boot:ro -v /sys/kernel/debug:/sys/kernel/debug -v /sys/fs/bpf:/sys/fs/bpf -v /root/gopher_user_conf:/gala-gopher/user_conf/ -v /etc/machine-id:/etc/machine-id -v /etc/localtime:/etc/localtime:ro --pid=host gala-gopher:0.0.1
+ [root@localhost ~]# mkdir gopher_user_conf
+ [root@localhost gopher_user_conf]# ll
+ total 8.0K
+ -rw-r--r--. 1 root root 3.2K Jun 28 09:43 gala-gopher.conf
+ -rw-r--r--. 1 root root 108 Jun 27 21:45 gala-gopher-app.conf
```
+ 请按照[配置文件介绍](./doc/conf_introduction.md)自定义修改配置文件。在执行docker run命令时需要将宿主机上自定义的配置文件目录和容器内/gala-gopher/user_conf目录映射从而将自定义的配置信息同步到容器内。
+
+ 最后按照如下示例命令启动容器:
+
+ ```shell
+ docker run -d --name xxx -p 8888:8888 --privileged -v /etc/machine-id:/etc/machine-id -v /lib/modules:/lib/modules:ro -v /usr/src:/usr/src:ro -v /boot:/boot:ro -v /sys/kernel/debug:/sys/kernel/debug -v /sys/fs/bpf:/sys/fs/bpf -v /root/gopher_user_conf:/gala-gopher/user_conf/ -v /etc/localtime:/etc/localtime:ro --pid=host gala-gopher:0.0.1
+ ```
+
+ 成功启动容器后通过docker ps可以看到正在运行的容器
+
+ ```shell
+ [root@localhost build]# docker ps
+ CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
+ eaxxxxxxxx02 gala-gopher:0.0.1 "/bin/sh -c 'cp -f /…" About a minute ago Up About a minute 0.0.0.0:8888->8888/tcp xxx
+ ```
+
+- 获取数据
+
+ 如上步骤docker run命令中所示我们映射了宿主机8888端口和容器的8888端口因而可以通过8888端口获取数据来验证gala-gopher是否运行成功
+
+ ```shell
+ [root@localhost build]# curl http://localhost:8888
+ ...
+ gala_gopher_udp_que_rcv_drops{tgid="1234",s_addr="192.168.12.34",machine_id="xxxxx",hostname="eaxxxxxxxx02"} 0 1656383357000
+ ...
+ ```
+
+ 如上有指标数据输出则证明gala-gopher运行成功。
+
#### 基于源码编译、安装、运行
##### 仅编译二进制
diff --git a/doc/how_to_build_docker_image.md b/doc/how_to_build_docker_image.md
index 6955f5b..c2b147d 100644
--- a/doc/how_to_build_docker_image.md
+++ b/doc/how_to_build_docker_image.md
@@ -69,49 +69,6 @@
gala-gopher 0.0.1 211913592b58 22 minutes ago 614MB
```
-### 创建并运行容器
-
-gala-gopher涉及两个配置文件gala-gopher.conf和task_whitelist.conf。gala-gopher.conf主要用于配置探针的数据上报开关、探针参数、探针是否开启等task_whitelist.conf是观测白名单可以把用户感兴趣的进程名加入白名单gala-gopher就会观测这个进程了。
-
-容器启动前需要用户自定义配置这两个配置文件,请在宿主机创建配置文件目录,并将[config目录](../config)下两个配置文件保存到该目录,示例如下:
-
-```shell
-[root@localhost ~]# mkdir gopher_user_conf
-[root@localhost gopher_user_conf]# ll
-total 8.0K
--rw-r--r--. 1 root root 3.2K Jun 28 09:43 gala-gopher.conf
--rw-r--r--. 1 root root 108 Jun 27 21:45 gala-gopher-app.conf
-```
-
-请按照[配置文件介绍](conf_introduction.md)自定义修改配置文件。在执行docker run命令时需要将宿主机上自定义的配置文件目录和容器内/gala-gopher/user_conf目录映射从而将自定义的配置信息同步到容器内。
-
-最后按照如下示例命令启动容器:
-
-```shell
-docker run -d --name xxx -p 8888:8888 --privileged -v /etc/machine-id:/etc/machine-id -v /lib/modules:/lib/modules:ro -v /usr/src:/usr/src:ro -v /boot:/boot:ro -v /sys/kernel/debug:/sys/kernel/debug -v /sys/fs/bpf:/sys/fs/bpf -v /root/gopher_user_conf:/gala-gopher/user_conf/ -v /etc/localtime:/etc/localtime:ro --pid=host gala-gopher:0.0.1
-```
-
-成功启动容器后通过docker ps可以看到正在运行的容器
-
-```shell
-[root@localhost build]# docker ps
-CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
-eaxxxxxxxx02 gala-gopher:0.0.1 "/bin/sh -c 'cp -f /…" About a minute ago Up About a minute 0.0.0.0:8888->8888/tcp xxx
-```
-
-### 获取数据
-
-如上步骤docker run命令中所示我们映射了宿主机8888端口和容器的8888端口因而可以通过8888端口获取数据来验证gala-gopher是否运行成功
-
-```shell
-[root@localhost build]# curl http://localhost:8888
-...
-gala_gopher_udp_que_rcv_drops{tgid="1234",s_addr="192.168.12.34",machine_id="xxxxx",hostname="eaxxxxxxxx02"} 0 1656383357000
-...
-```
-
-如上有指标数据输出则证明gala-gopher运行成功。
-
### 保存容器镜像
生成容器镜像后可以将镜像保存为tar文件其他宿主机可以通过load命令导入容器镜像
--
2.36.0.windows.1

View File

@ -1,78 +0,0 @@
From ce5349ae6bcc922130bd19cbed5224727ee21c9a Mon Sep 17 00:00:00 2001
From: Vchanger <348085547@qq.com>
Date: Sun, 4 Dec 2022 21:51:03 +0800
Subject: [PATCH] simplify vmlinux.h management with different kernel versions
---
build/build.sh | 2 ++
src/probes/extends/ebpf.probe/build.sh | 12 ++++--------
src/probes/extends/ebpf.probe/src/mk/var.mk | 4 ++--
3 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/build/build.sh b/build/build.sh
index 7d259e3..40171e3 100755
--- a/build/build.sh
+++ b/build/build.sh
@@ -17,6 +17,8 @@ DAEMON_FOLDER=${PROJECT_FOLDER}/src/daemon
TAILOR_PATH=${PROJECT_FOLDER}/tailor.conf
TAILOR_PATH_TMP=${TAILOR_PATH}.tmp
+export LINUX_VER="${2:-$(uname -r)}"
+
function load_tailor()
{
if [ -f ${TAILOR_PATH} ]; then
diff --git a/src/probes/extends/ebpf.probe/build.sh b/src/probes/extends/ebpf.probe/build.sh
index 05a1547..dcc7ffe 100755
--- a/src/probes/extends/ebpf.probe/build.sh
+++ b/src/probes/extends/ebpf.probe/build.sh
@@ -6,24 +6,20 @@ PRJ_DIR=$(dirname $(readlink -f "$0"))
TOOLS_DIR=${PRJ_DIR}/tools
SRC_DIR=${PRJ_DIR}/src
VMLINUX_DIR=${SRC_DIR}/include
-LINUX_VER=$(uname -r)
DEP_LIST=(elfutils-devel libbpf libbpf-devel clang llvm)
-function gen_vmlinux_header_file()
+function add_bpftool()
{
cd ${TOOLS_DIR}
if [ ! -f "bpftool" ];then
ln -s bpftool_${ARCH} bpftool
fi
- ./gen_vmlinux_h.sh
}
-function add_bpftool()
+function gen_vmlinux_header_file()
{
- cd ${TOOLS_DIR}
- if [ ! -f "bpftool" ];then
- ln -s bpftool_${ARCH} bpftool
- fi
+ add_bpftool
+ ./gen_vmlinux_h.sh
}
function check_dep()
diff --git a/src/probes/extends/ebpf.probe/src/mk/var.mk b/src/probes/extends/ebpf.probe/src/mk/var.mk
index fc33e22..8990bda 100644
--- a/src/probes/extends/ebpf.probe/src/mk/var.mk
+++ b/src/probes/extends/ebpf.probe/src/mk/var.mk
@@ -23,11 +23,11 @@ else ifeq ($(ARCH), aarch64)
ARCH = arm64
endif
-KER_VER = $(shell uname -r | awk -F'-' '{print $$1}')
+KER_VER = $(shell echo $(LINUX_VER) | 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}')
+RELEASE_INFOS = $(shell echo $(LINUX_VER) | 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}')
--
2.33.0