Skip to content

Commit

Permalink
[Fix] fix
Browse files Browse the repository at this point in the history
  • Loading branch information
hengyoush committed Sep 10, 2024
1 parent c501670 commit e7f5f90
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 21 deletions.
2 changes: 2 additions & 0 deletions agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ func TestRecvmsg(t *testing.T) {
connIdDirect: bpf.AgentTrafficDirectionTKIngress,
pid: uint64(os.Getpid()),
fd: uint32(conn.TgidFd),
ignoreFuncName: true,
funcName: "syscall",
dataLen: uint32(readBufSizeSlice[index]),
seq: seq,
Expand Down Expand Up @@ -644,6 +645,7 @@ func TestSendMsg(t *testing.T) {
KernDataEventAssertConditions: KernDataEventAssertConditions{connIdDirect: bpf.AgentTrafficDirectionTKEgress,
pid: uint64(os.Getpid()),
fd: uint32(conn.TgidFd),
ignoreFuncName: true,
funcName: "syscall",
dataLen: uint32(len(sendMessages[index])),
seq: seq,
Expand Down
12 changes: 6 additions & 6 deletions bpf/agent_x86_bpfel.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions bpf/agentold_x86_bpfel.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 13 additions & 7 deletions bpf/pktlatency.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1529,17 +1529,20 @@ int tracepoint__syscalls__sys_exit_close(struct trace_event_raw_sys_exit *ctx)


//int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
SEC("kprobe/__sys_connect")
int BPF_KPROBE(connect_entry, int sockfd, const struct sockaddr* addr) {
// SEC("kprobe/__sys_connect")
// int BPF_KPROBE(connect_entry, int sockfd, const struct sockaddr* addr) {
SEC("tracepoint/syscalls/sys_enter_connect")
int tracepoint__syscalls__sys_enter_connect(struct trace_event_raw_sys_enter *ctx) {
uint64_t id = bpf_get_current_pid_tgid();

struct connect_args args = {0};
args.fd = sockfd;
args.addr = addr;
TP_ARGS(&args.fd, 0, ctx)
TP_ARGS(&args.addr, 1, ctx)
args.start_ts = bpf_ktime_get_ns();
bpf_map_update_elem(&connect_args_map, &id, &args, BPF_ANY);
return 0;
}

SEC("tracepoint/syscalls/sys_exit_connect")
int tracepoint__syscalls__sys_exit_connect(struct trace_event_raw_sys_exit *ctx) {
uint64_t id = bpf_get_current_pid_tgid();
Expand All @@ -1555,12 +1558,15 @@ int tracepoint__syscalls__sys_exit_connect(struct trace_event_raw_sys_exit *ctx)
}


SEC("kprobe/accept4")
int BPF_KPROBE(accept4_entry, int sockfd, struct sockaddr* addr) {
// SEC("kprobe/accept4")
// int BPF_KPROBE(accept4_entry, int sockfd, struct sockaddr* addr) {

SEC("tracepoint/syscalls/sys_enter_accept4")
int tracepoint__syscalls__sys_enter_accept4(struct trace_event_raw_sys_enter *ctx) {
uint64_t id = bpf_get_current_pid_tgid();

struct accept_args args = {0};
args.addr = addr;
TP_ARGS(&args.addr, 1, ctx)
bpf_map_update_elem(&accept_args_map, &id, &args, BPF_ANY);
return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions bpf/prog.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func GetProgram(programs any, fieldName string) *ebpf.Program {

/* accept pair */
func AttachSyscallAcceptEntry(programs interface{}) link.Link {
return kprobe("__sys_accept4", GetProgram(programs, "Accept4Entry"))
return tracepoint("syscalls", "sys_enter_accept4", GetProgram(programs, "TracepointSyscallsSysEnterAccept4"))
}

func AttachSyscallAcceptExit(programs interface{}) link.Link {
Expand All @@ -43,7 +43,7 @@ func AttachSyscallSockAllocExit(programs interface{}) link.Link {

/* connect pair */
func AttachSyscallConnectEntry(programs interface{}) link.Link {
return kprobe("__sys_connect", GetProgram(programs, "ConnectEntry"))
return tracepoint("syscalls", "sys_enter_connect", GetProgram(programs, "TracepointSyscallsSysEnterConnect"))
}

func AttachSyscallConnectExit(programs interface{}) link.Link {
Expand Down

0 comments on commit e7f5f90

Please sign in to comment.