From f808abf8fd450e76ea3c6e5db0efcaaaa3e56e3c Mon Sep 17 00:00:00 2001 From: Jiping Yin Date: Fri, 1 Nov 2024 10:13:54 +0800 Subject: [PATCH] feat: agent - eBPF Support for the ARM version of Kylin v10 SP2 --- .../src/ebpf/kernel/include/protocol_inference.h | 16 +++++++++++++--- .../src/ebpf/kernel/include/task_struct_utils.h | 3 ++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/agent/src/ebpf/kernel/include/protocol_inference.h b/agent/src/ebpf/kernel/include/protocol_inference.h index 646ab1a0ac4..fa5706f3dd1 100644 --- a/agent/src/ebpf/kernel/include/protocol_inference.h +++ b/agent/src/ebpf/kernel/include/protocol_inference.h @@ -1431,7 +1431,14 @@ static __inline bool mqtt_decoding_length(const __u8 * buffer, int *length, buffer += 1; *length = 0; *lensize = 0; - do { + + /* + * Limit the number of loop iterations, ensuring the byte usage remains + * within 32 bytes. This also resolves the issue of loading eBPF bytecode + * on the 4.19.90-25.24.v2101.ky10.aarch64 kernel. + */ + static const int loop_count = 32; + for (int i = 0; i < loop_count; i++) { digit = buffer[(*lensize)++]; *length += (digit & 127) * multiplier; multiplier *= 128; @@ -1439,8 +1446,11 @@ static __inline bool mqtt_decoding_length(const __u8 * buffer, int *length, // mqtt 最多用4个字节表示长度 if ((*lensize) > 4) return false; - } while ((digit & 128) != 0); - return true; + if((digit & 128) == 0) + return true; + } + + return false; } static __inline bool mqtt_decoding_message_type(const __u8 * buffer, diff --git a/agent/src/ebpf/kernel/include/task_struct_utils.h b/agent/src/ebpf/kernel/include/task_struct_utils.h index 256ece17056..bdde729b644 100644 --- a/agent/src/ebpf/kernel/include/task_struct_utils.h +++ b/agent/src/ebpf/kernel/include/task_struct_utils.h @@ -108,12 +108,13 @@ static __inline void *infer_and_get_socket_from_fd(int fd_num, struct member_fie // 0x6b8 for 4.19.117.business.1-amd64 // 0xb88 for 4.19.0-91.77.112.uelc20.x86_64, 4.19.0-91.82.65.uelc20.x86_64 // 0xcd8 for 4.14.105-1-tlinux3-0023.1 + // 0x7c8 for 4.19.90-25.24.v2101.ky10.aarch64 int files_offset_array[] = { 0x6c0, 0x790, 0x7b0, 0xa80, 0xa88, 0xaa0, 0xaa8, 0xab0, 0xab8, 0xac0, 0xac8, 0xad0, 0xad8, 0xae0, 0xae8, 0xaf0, 0xaf8, 0xb00, 0xb08, 0xb10, 0xb18, 0xb20, 0xb48, 0xb50, 0xb58, 0xb60, 0xb68, 0xb70, 0xb78, 0xb90, 0xb98, 0xba0, 0xbb0, 0x740, 0xbc0, 0xbc8, 0xbd0, 0xbd8, 0xbe0, 0xbe8, - 0xbf0, 0xbf8, 0xc00, 0xc08, 0xcc8, 0xd08, 0x6b8, 0xb88, 0xcd8 + 0xbf0, 0xbf8, 0xc00, 0xc08, 0xcc8, 0xd08, 0x6b8, 0xb88, 0xcd8, 0x7c8 }; #endif /* *INDENT-ON* */