Skip to content

Commit

Permalink
edriver-rust: trivial patch
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskaliX committed Feb 16, 2024
1 parent 6f197e2 commit c1b21b4
Show file tree
Hide file tree
Showing 4 changed files with 9,472 additions and 9,436 deletions.
10 changes: 10 additions & 0 deletions plugins/edriver-rust/src/bpf/common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ static inline struct mount *real_mount(struct vfsmount *mnt)
return container_of(mnt, struct mount, mnt);
}

static inline struct hds_context init_context(void *ctx, int dt)
{
struct hds_context c = {
.ctx = ctx,
.data_type = dt,
.sbt = get_percpu_buf(PRINT_CACHE)
};
return c;
}

/* notice: char * to void * */
static __noinline int do_u32toa(uint32_t v, void *s, int l)
{
Expand Down
16 changes: 6 additions & 10 deletions plugins/edriver-rust/src/bpf/common/edriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,18 @@ int rtp__process_exec(struct bpf_raw_tracepoint_args *ctx)
/* ingore kernel threads */
u32 flags = BPF_CORE_READ(task, flags);
if (flags & PF_KTHREAD)
return -1;
return 0;

/* fulfill proc information */
struct proc_info *proc_i = proc_info_init(task);
if (proc_i == NULL)
return -1;
return 0;
proc_info_args(proc_i, task);
proc_info_envs(proc_i, task);
proc_pid_tree(proc_i, task);

/* report */
struct hds_context c = {0};
c.ctx = ctx;
c.data_type = SYS_ENTER_EXECVE;
c.sbt = get_percpu_buf(PRINT_CACHE);
struct hds_context c = init_context(ctx, SYS_ENTER_EXECVE);

SBT((&c), &c.data_type, S_U32);
SBT((&c), &proc_i->pid, S_U32);
Expand Down Expand Up @@ -75,8 +72,7 @@ int rtp__process_exec(struct bpf_raw_tracepoint_args *ctx)
SBT((&c), &proc_i->sinfo, sizeof(struct hds_socket_info));
SBT_CHAR((&c), &proc_i->pidtree);

report_event(&c);
return 0;
return report_event(&c);
}

/* proc_info init */
Expand Down Expand Up @@ -116,9 +112,9 @@ static struct proc_info *proc_info_init(struct task_struct *task)
} else {
struct hds_socket_info sinfo = {};
sinfo.family = BPF_CORE_READ(sk, sk_family);
if (sinfo.family == AF_INET) {
if (sinfo.family == AF_INET)
get_sock_v4(sk, &sinfo);
}
// else if (sinfo.family == AF_INET6)
proc_i->sinfo = sinfo;
}
/* user */
Expand Down
2 changes: 1 addition & 1 deletion plugins/edriver-rust/src/bpf/common/maps.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
/* maps defination */
BPF_PERF_OUTPUT(events, 1024);
BPF_PERCPU_ARRAY(bufs, buf_t, MAX_BUFFERS);
BPF_LRU_HASH(proc_info_cache, u32, struct proc_info, 10240);
BPF_LRU_HASH(proc_info_cache, pid_t, struct proc_info, 10240);
BPF_HASH(pid_filter, u32, u32, 512);

#endif
Loading

0 comments on commit c1b21b4

Please sign in to comment.