Skip to content

Commit

Permalink
fix(modern_bpf): define the compat timespec in struct flavors
Browse files Browse the repository at this point in the history
Signed-off-by: therealbobo <[email protected]>
  • Loading branch information
therealbobo committed May 16, 2024
1 parent 8cbff21 commit 54f46c4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions driver/modern_bpf/definitions/struct_flavors.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,15 @@ struct modern_bpf__kernel_timex_timeval
long long int tv_usec;
};

/*
* This is equivalent to old_timespec32 or compat_timespec. Some old distros
* don't define old_timespec32 (e.g. centos 8 with 4.18 kernel), so we define
* it here.
*/
struct modern_bpf__kernel_timespec_ia32
{
int tv_sec;
int tv_nsec;
};

#endif /* __STRUCT_FLAVORS_H__ */
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ int BPF_PROG(ppoll_e,
}
else
{
struct old_timespec32 ts = {0};
struct modern_bpf__kernel_timespec_ia32 ts = {0};
bpf_probe_read_user(&ts, sizeof(ts), (void *)ts_pointer);
nanosec = ((uint32_t)ts.tv_sec) * SECOND_TO_NS + ts.tv_nsec;
}
Expand Down

0 comments on commit 54f46c4

Please sign in to comment.