This is an automated email from the ASF dual-hosted git repository.
liuhan pushed a commit to branch reduce-handle-connect-time
in repository https://gitbox.apache.org/repos/asf/skywalking-rover.git
The following commit(s) were added to refs/heads/reduce-handle-connect-time by
this push:
new dbd6f51 add test log
dbd6f51 is described below
commit dbd6f51663c1a39f5342a7b38b2201453205b2a8
Author: mrproliu <[email protected]>
AuthorDate: Fri Dec 27 20:10:48 2024 +0800
add test log
---
bpf/accesslog/common/connection.h | 6 +++---
bpf/accesslog/syscalls/connect.c | 6 ++++--
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/bpf/accesslog/common/connection.h
b/bpf/accesslog/common/connection.h
index 0a01f38..0a75214 100644
--- a/bpf/accesslog/common/connection.h
+++ b/bpf/accesslog/common/connection.h
@@ -200,7 +200,7 @@ static __always_inline void submit_new_connection(void*
ctx, bool success, __u32
event->conntrack_upstream_iph = (__u64)conntrack->iph;
event->conntrack_upstream_ipl = (__u64)conntrack->ipl;
event->conntrack_upstream_port = conntrack->port;
- bpf_printk("update conntrack, conid: %lld", conid);
+ bpf_printk("update conntrack, conid: %lld, port: %d", conid,
conntrack->port);
}
event->success = success;
@@ -287,7 +287,7 @@ static __inline struct active_connection_t*
get_or_create_active_conn(void *ctx,
if (conn != NULL) {
return conn;
}
- submit_new_connection(ctx, true, func_name, tgid, fd, 0, NULL, NULL, NULL,
role);
+ submit_new_connection(ctx, true, func_name, tgid, fd, 0, 0, NULL, NULL,
NULL, role, 0);
return bpf_map_lookup_elem(&active_connection_map, &conid);
}
@@ -301,7 +301,7 @@ static __inline void submit_connection_when_not_exists(void
*ctx, __u64 id, stru
if (conn != NULL) {
return;
}
- submit_new_connection(ctx, true, func_name, tgid, connect_args->fd,
connect_args->start_nacs, connect_args->addr, NULL, &connect_args->remote,
role);
+ submit_new_connection(ctx, true, func_name, tgid, connect_args->fd,
connect_args->start_nacs, connect_args->randomid, connect_args->addr, NULL,
&connect_args->remote, role, connect_args->has_remote);
}
static __inline void notify_close_connection(void* ctx, __u64 conid, struct
active_connection_t* con, __u64 start_time, __u64 end_time, int ret) {
diff --git a/bpf/accesslog/syscalls/connect.c b/bpf/accesslog/syscalls/connect.c
index 061a4ee..8e0363c 100644
--- a/bpf/accesslog/syscalls/connect.c
+++ b/bpf/accesslog/syscalls/connect.c
@@ -32,14 +32,15 @@ static __inline void process_connect(void *ctx, __u64 id,
struct connect_args_t
__u32 tgid = id >> 32;
struct sock *sock = connect_args->sock;
struct socket *s = _(sock->sk_socket);
- submit_new_connection(ctx, success, SOCKET_OPTS_TYPE_CONNECT, tgid,
connect_args->fd, connect_args->start_nacs, connect_args->addr, s,
&connect_args->remote, 0);
+ submit_new_connection(ctx, success, SOCKET_OPTS_TYPE_CONNECT, tgid,
connect_args->fd, connect_args->start_nacs,
+ connect_args->randomid, connect_args->addr, s, &connect_args->remote,
0, connect_args->has_remote);
}
static __inline void process_accept(void *ctx, __u64 id, struct accept_args_t
*accept_args, long ret) {
int fd = (int) ret;
__u32 tgid = id >> 32;
struct socket *s = accept_args->socket;
- submit_new_connection(ctx, true, SOCKET_OPTS_TYPE_ACCEPT, tgid, fd,
accept_args->start_nacs, accept_args->addr, s, NULL, 0);
+ submit_new_connection(ctx, true, SOCKET_OPTS_TYPE_ACCEPT, tgid, fd,
accept_args->start_nacs, 0, accept_args->addr, s, NULL, 0, 0);
}
SEC("tracepoint/syscalls/sys_enter_connect")
@@ -53,6 +54,7 @@ int tracepoint_enter_connect(struct syscall_trace_enter *ctx)
{
connect_args.fd = (__u32)ctx->args[0];
connect_args.addr = (struct sockaddr *)ctx->args[1];
connect_args.start_nacs = bpf_ktime_get_ns();
+ connect_args.randomid = bpf_get_prandom_u32();
bpf_map_update_elem(&conecting_args, &id, &connect_args, 0);
return 0;
}