From a3c7d22e037eacbf5115a399b64b1a93cda48477 Mon Sep 17 00:00:00 2001 From: wo_cow Date: Tue, 25 Oct 2022 17:13:16 +0800 Subject: [PATCH] fix: tc bpf get wrong version --- src/probes/extends/ebpf.probe/src/ksliprobe/tc_tstamp.bpf.c | 1 + src/probes/extends/ebpf.probe/src/pgsliprobe/pgsliprobe.h | 6 +++++- .../extends/ebpf.probe/src/pgsliprobe/pgsliprobe_bpf.h | 4 ---- .../extends/ebpf.probe/src/pgsliprobe/tc_tstamp.bpf.c | 6 ++++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/probes/extends/ebpf.probe/src/ksliprobe/tc_tstamp.bpf.c b/src/probes/extends/ebpf.probe/src/ksliprobe/tc_tstamp.bpf.c index a594b8fc..6aefd5bc 100644 --- a/src/probes/extends/ebpf.probe/src/ksliprobe/tc_tstamp.bpf.c +++ b/src/probes/extends/ebpf.probe/src/ksliprobe/tc_tstamp.bpf.c @@ -19,6 +19,7 @@ #include "bpf.h" #include +#include "ksliprobe.h" SEC("tc") int get_start_ts(struct __sk_buff *skb) diff --git a/src/probes/extends/ebpf.probe/src/pgsliprobe/pgsliprobe.h b/src/probes/extends/ebpf.probe/src/pgsliprobe/pgsliprobe.h index 668ca740..5d49fd5c 100644 --- a/src/probes/extends/ebpf.probe/src/pgsliprobe/pgsliprobe.h +++ b/src/probes/extends/ebpf.probe/src/pgsliprobe/pgsliprobe.h @@ -15,11 +15,15 @@ #ifndef __PGSLIPROBE_H__ #define __PGSLIPROBE_H__ -#define TC_PROG "tc_tstamp.bpf.o" +#define TC_TSTAMP_PROG "tc_tstamp.bpf.o" #define SLI_OK 0 #define SLI_ERR (-1) +#if ((CURRENT_KERNEL_VERSION == KERNEL_VERSION(4, 18, 0)) || (CURRENT_KERNEL_VERSION >= KERNEL_VERSION(5, 10, 0))) +#define KERNEL_SUPPORT_TSTAMP +#endif + struct ogsli_args_s { __u64 period; // Sampling period, unit ns }; 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 34f1787b..e5afad77 100644 --- a/src/probes/extends/ebpf.probe/src/pgsliprobe/pgsliprobe_bpf.h +++ b/src/probes/extends/ebpf.probe/src/pgsliprobe/pgsliprobe_bpf.h @@ -15,10 +15,6 @@ #ifndef __PGSLIPROBE_BPF_H__ #define __PGSLIPROBE_BPF_H__ -#if ((CURRENT_KERNEL_VERSION == KERNEL_VERSION(4, 18, 0)) || (CURRENT_KERNEL_VERSION >= KERNEL_VERSION(5, 10, 0))) -#define KERNEL_SUPPORT_TSTAMP -#endif - #ifndef __PERIOD #define __PERIOD NS(30) #endif diff --git a/src/probes/extends/ebpf.probe/src/pgsliprobe/tc_tstamp.bpf.c b/src/probes/extends/ebpf.probe/src/pgsliprobe/tc_tstamp.bpf.c index 2ba5634a..5d0474bf 100644 --- a/src/probes/extends/ebpf.probe/src/pgsliprobe/tc_tstamp.bpf.c +++ b/src/probes/extends/ebpf.probe/src/pgsliprobe/tc_tstamp.bpf.c @@ -19,13 +19,15 @@ #include "bpf.h" #include +#include "pgsliprobe.h" + SEC("tc") int get_start_ts(struct __sk_buff *skb) { #ifdef KERNEL_SUPPORT_TSTAMP - skb->tstamp = bpf_ktime_get_ns(); + skb->tstamp = bpf_ktime_get_ns(); #endif - return 0; + return 0; } char g_license[] SEC("license") = "GPL"; -- Gitee