Skip to content

Commit

Permalink
[eBPF] Support debian 10.6 - 4.19.0-25-amd64 (#4483)
Browse files Browse the repository at this point in the history
  • Loading branch information
yinjiping authored Oct 16, 2023
1 parent 3d11340 commit 96b678d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
13 changes: 7 additions & 6 deletions agent/src/ebpf/kernel/include/task_struct_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,9 @@ static __inline void *infer_and_get_socket_from_fd(int fd_num,

// TAG: STRUCT_TASK_FILES_OFFSET
// 成员 files 在 struct task_struct 中的偏移量
// 0xd08 for kernel-devel-4.19.91-26.6.al7
#ifdef LINUX_VER_5_2_PLUS
// 0xa48 for 5.10.0-60.18.0.50.h322_1.hce2.aarch64
// 0xc60 for 5.10.0-106.18.0.68.oe2209.x86_64
#ifdef LINUX_VER_5_2_PLUS
int files_offset_array[] = {
0x790, 0xa80, 0xa88, 0xa90, 0xa98, 0xaa0, 0xaa8, 0xab0, 0xab8, 0xac0,
0xac8, 0xad0, 0xad8, 0xae0, 0xae8, 0xaf0, 0xaf8, 0xb00, 0xb08, 0xb10,
Expand All @@ -140,12 +139,14 @@ static __inline void *infer_and_get_socket_from_fd(int fd_num,
0xcc8, 0xa48, 0xc60
};
#else
// 0xd08 for kernel-devel-4.19.91-26.6.al7
// 0x740 for 4.19.113-300.el7.x86_64
// 0x6c0 for 4.19.0-25-amd64 #1 SMP Debian 4.19.289-2 (2023-08-08)
int files_offset_array[] = {
0x790, 0xa80, 0xa88, 0xa90, 0xa98, 0xaa0, 0xaa8, 0xab0, 0xab8, 0xac0,
0xac8, 0xad0, 0xad8, 0xae0, 0xae8, 0xaf0, 0xaf8, 0xb00, 0xb08, 0xb10,
0xb18, 0xb20, 0xb28, 0xb48, 0xb50, 0xb58, 0xb60, 0xb68, 0xb70, 0xb78,
0xb80, 0xb88, 0xb90, 0xb98, 0xba0, 0x740, 0xbb8, 0xbc0, 0xbc8, 0xbd0,
0x6c0, 0x790, 0xa80, 0xa88, 0xa90, 0xa98, 0xaa0, 0xaa8, 0xab0, 0xab8,
0xac0, 0xac8, 0xad0, 0xad8, 0xae0, 0xae8, 0xaf0, 0xaf8, 0xb00, 0xb08,
0xb10, 0xb18, 0xb20, 0xb28, 0xb48, 0xb50, 0xb58, 0xb60, 0xb68, 0xb70,
0xb78, 0xb88, 0xb90, 0xb98, 0xba0, 0x740, 0xbb8, 0xbc0, 0xbc8, 0xbd0,
0xbd8, 0xbe0, 0xbe8, 0xbf0, 0xbf8, 0xc00, 0xc08, 0xc10, 0xcc8, 0xd08,
};
#endif
Expand Down
9 changes: 9 additions & 0 deletions agent/src/ebpf/user/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,15 @@ int fetch_kernel_version(int *major, int *minor, int *patch)
if (sscanf(sys_info.release, "%u.%u.%u", major, minor, patch) != 3)
return ETR_INVAL;

// Get the real version of Debian
//#1 SMP Debian 4.19.289-2 (2023-08-08)
if (strstr(sys_info.version, "Debian")) {
int num;
if (sscanf(sys_info.version, "%*s %*s %*s %u.%u.%u-%u %*s",
major, minor, patch, &num) != 4)
return ETR_INVAL;
}

return ETR_OK;
}

Expand Down

0 comments on commit 96b678d

Please sign in to comment.