Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ebpf): adjust inode struct to kernel v6.11 #4457

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions pkg/ebpf/c/common/filesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,24 @@ statfunc u64 get_time_nanosec_timespec(struct timespec64 *ts)

statfunc u64 get_ctime_nanosec_from_inode(struct inode *inode)
{
struct timespec64 ts;
if (bpf_core_field_exists(inode->__i_ctime)) { // Version >= 6.6
ts = BPF_CORE_READ(inode, __i_ctime);
} else {
struct inode___older_v66 *old_inode = (void *) inode;
ts = BPF_CORE_READ(old_inode, i_ctime);
struct timespec64 ts = {};

// Kernel >= 6.11
if (bpf_core_field_exists(inode->i_ctime_sec) && bpf_core_field_exists(inode->i_ctime_nsec)) {
ts.tv_sec = BPF_CORE_READ(inode, i_ctime_sec);
ts.tv_nsec = BPF_CORE_READ(inode, i_ctime_nsec);
}
// Kernel 6.6 - 6.10
else if (bpf_core_field_exists(((struct inode___older_v611 *) inode)->__i_ctime)) {
struct inode___older_v611 *old_inode_v611 = (void *) inode;
ts = BPF_CORE_READ(old_inode_v611, __i_ctime);
}
// Kernel < 6.6
else {
struct inode___older_v66 *old_inode_v66 = (void *) inode;
ts = BPF_CORE_READ(old_inode_v66, i_ctime);
}

return get_time_nanosec_timespec(&ts);
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/ebpf/c/vmlinux.h
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,8 @@ struct inode {
umode_t i_mode;
struct super_block *i_sb;
long unsigned int i_ino;
struct timespec64 __i_ctime;
time64_t i_ctime_sec;
u32 i_ctime_nsec;
loff_t i_size;
struct file_operations *i_fop;
};
Expand Down
5 changes: 5 additions & 0 deletions pkg/ebpf/c/vmlinux_flavors.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ struct inode___older_v66 {
struct timespec64 i_ctime;
};

// kernel >= v6.11 inode i_ctime field change
struct inode___older_v611 {
struct timespec64 __i_ctime;
};

///////////////////

#pragma clang attribute pop
Expand Down
Loading