From d859879d2a61dfd5b601a2196fe7f46811f9ba6b Mon Sep 17 00:00:00 2001 From: chendotjs Date: Wed, 5 Jan 2022 03:26:15 +0800 Subject: [PATCH] libbpf-tools: fix fentry prog in tcprtt (#3757) This commit fixes judgement if tcp_rcv_established fentry exists and fentry prog by introducing BPF_CORE_READ. Signed-off-by: chendotjs --- libbpf-tools/tcprtt.bpf.c | 3 ++- libbpf-tools/tcprtt.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libbpf-tools/tcprtt.bpf.c b/libbpf-tools/tcprtt.bpf.c index 52afad0a..0b332e4e 100644 --- a/libbpf-tools/tcprtt.bpf.c +++ b/libbpf-tools/tcprtt.bpf.c @@ -2,6 +2,7 @@ // Copyright (c) 2021 Wenbo Zhang #include #include +#include #include #include #include "tcprtt.h" @@ -56,7 +57,7 @@ int BPF_PROG(tcp_rcv, struct sock *sk) if (!histp) return 0; ts = (struct tcp_sock *)(sk); - srtt = ts->srtt_us >> 3; + srtt = BPF_CORE_READ(ts, srtt_us) >> 3; if (targ_ms) srtt /= 1000U; slot = log2l(srtt); diff --git a/libbpf-tools/tcprtt.c b/libbpf-tools/tcprtt.c index e847b8d2..bed6efa7 100644 --- a/libbpf-tools/tcprtt.c +++ b/libbpf-tools/tcprtt.c @@ -243,7 +243,7 @@ int main(int argc, char **argv) obj->rodata->targ_daddr = env.raddr; obj->rodata->targ_ms = env.milliseconds; - if (!fentry_exists("tcp_rcv_established", NULL)) + if (fentry_exists("tcp_rcv_established", NULL)) bpf_program__set_autoload(obj->progs.tcp_rcv_kprobe, false); else bpf_program__set_autoload(obj->progs.tcp_rcv, false); -- 2.34.1