diff --git a/fix-pgsliprobe.patch b/fix-pgsliprobe.patch new file mode 100644 index 0000000000000000000000000000000000000000..8e8f1aaec3774a45cf37a2035e25fa02352b80a3 --- /dev/null +++ b/fix-pgsliprobe.patch @@ -0,0 +1,144 @@ +From bb78dcf76c2ef7d0ba297161dda5bcaa42f0f63e Mon Sep 17 00:00:00 2001 +From: wo_cow +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, ¶ms); +@@ -405,11 +409,26 @@ int main(int argc, char **argv) + goto init_err; + } + ++ load_args(GET_MAP_FD(pgsli_kprobe, args_map), ¶ms); ++ 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), ¶ms); +- 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 + diff --git a/gala-gopher.spec b/gala-gopher.spec index 7e827a8c6973faa6e48af4237469d3ee8be1e30f..de02b4faba1b63f47e2b3be5e48f872299767bdf 100644 --- a/gala-gopher.spec +++ b/gala-gopher.spec @@ -4,7 +4,7 @@ Summary: Intelligent ops toolkit for openEuler Name: gala-gopher Version: 1.0.0 -Release: 2 +Release: 3 License: Mulan PSL v2 URL: https://gitee.com/openeuler/gala-gopher Source: %{name}-%{version}.tar.gz @@ -23,6 +23,7 @@ patch1: modify-to-adapt-to-oe2203-LTS-SP1-x86.patch %ifarch aarch64 patch1: modify-to-adapt-to-oe2203-LTS-SP1-arm.patch %endif +patch2: fix-pgsliprobe.patch %description gala-gopher is a low-overhead eBPF-based probes framework @@ -31,6 +32,7 @@ gala-gopher is a low-overhead eBPF-based probes framework %setup -q %patch0 -p1 %patch1 -p1 +%patch2 -p1 %build pushd build @@ -71,6 +73,9 @@ popd /usr/lib/systemd/system/gala-gopher.service %changelog +* Mon Nov 14 2022 Zhen Chen - 1.0.0-3 +- fix pgsliprobe + * Mon Nov 14 2022 Zhen Chen - 1.0.0-2 - add vmlinux for 22.03-LTS & 22.03-LTS-SP1