|
|
@@ -366,6 +366,10 @@ int trace_enter_write(void *ctx, __u64 fd, __u16 is_tls, char *buf, __u64 size,
|
|
|
k.is_tls = is_tls;
|
|
|
k.stream_id = -1;
|
|
|
|
|
|
+ struct connection_id cid = {};
|
|
|
+ cid.pid = pid;
|
|
|
+ cid.fd = fd;
|
|
|
+
|
|
|
// cw_bpf_debug("enter-payload:%s|type:%s|FD:%d\n",payload,"type",k.fd);
|
|
|
|
|
|
if (is_http_response(payload, &http_status))
|
|
|
@@ -440,20 +444,24 @@ int trace_enter_write(void *ctx, __u64 fd, __u16 is_tls, char *buf, __u64 size,
|
|
|
// cw_bpf_debug("off->task__files_offset:%x", off->task__files_offset);
|
|
|
// cw_bpf_debug("e->test_id1111:%d", ttt->test_id);
|
|
|
cw_bpf_debug("HTTP_END");
|
|
|
+
|
|
|
+ //TODO 4 查询
|
|
|
+ cw_bpf_debug("socket accept bytes_sent cid.pid=%d, cid.fd=%d\n", cid.pid, cid.fd);
|
|
|
+ struct connection *accept_conn = bpf_map_lookup_elem(&active_accepts, &cid);
|
|
|
+ if (accept_conn && !is_tls) {
|
|
|
+ cw_bpf_debug("socket accept bytes_sent after cid.pid=%d, cid.fd=%d\n", cid.pid, cid.fd);
|
|
|
+ __sync_fetch_and_add(&accept_conn->bytes_sent, total_size);
|
|
|
+ }
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
- struct connection_id cid = {};
|
|
|
- cid.pid = pid;
|
|
|
- cid.fd = fd;
|
|
|
-
|
|
|
struct connection *conn = bpf_map_lookup_elem(&active_connections, &cid);
|
|
|
if (!conn) {
|
|
|
//TODO 4 查询
|
|
|
- // cw_bpf_debug("accept bytes_sent cid.pid=%d, cid.fd=d\n", cid.pid, cid.fd);
|
|
|
+ cw_bpf_debug("socket accept bytes_sent cid.pid=%d, cid.fd=%d\n", cid.pid, cid.fd);
|
|
|
struct connection *accept_conn = bpf_map_lookup_elem(&active_accepts, &cid);
|
|
|
if (accept_conn && !is_tls) {
|
|
|
- cw_bpf_debug("accept bytes_sent after cid.pid=%d, cid.fd=d\n", cid.pid, cid.fd);
|
|
|
+ cw_bpf_debug("socket accept bytes_sent after cid.pid=%d, cid.fd=%d\n", cid.pid, cid.fd);
|
|
|
__sync_fetch_and_add(&accept_conn->bytes_sent, total_size);
|
|
|
}
|
|
|
return 0;
|
|
|
@@ -715,7 +723,11 @@ int trace_exit_read(void *ctx, __u64 id, __u32 pid, __u16 is_tls, long int ret)
|
|
|
// infer_dns_message(payload, (int)PT_REGS_RC((struct pt_regs *)ctx),
|
|
|
// conn_info);
|
|
|
|
|
|
+ struct connection_id cid = {};
|
|
|
+ cid.pid = pid;
|
|
|
+ cid.fd = args->fd;
|
|
|
// 被调用方http入口
|
|
|
+ // 作为服务端在走。coroot 原有逻辑是没有的
|
|
|
if (is_http_request(payload)) {
|
|
|
struct l7_request *req = bpf_map_lookup_elem(&l7_request_heap, &zero);
|
|
|
if (!req)
|
|
|
@@ -770,19 +782,24 @@ int trace_exit_read(void *ctx, __u64 id, __u32 pid, __u16 is_tls, long int ret)
|
|
|
// bpf_map_update_elem(&fd_trace_info_heap, &fd_trace_key, &trace_info, BPF_NOEXIST);
|
|
|
bpf_perf_event_output(ctx, &l7_events, BPF_F_CURRENT_CPU, e, sizeof(*e));
|
|
|
cw_bpf_debug("[Receive][HTTP] to user space");
|
|
|
+
|
|
|
+ // 作为服务端统计 bytes_received 使用
|
|
|
+ struct connection *accept_conn = bpf_map_lookup_elem(&active_accepts, &cid);
|
|
|
+ cw_bpf_debug("socket accept bytes_received cid.pid=%d, cid.fd=%d\n", cid.pid, cid.fd);
|
|
|
+ if (accept_conn && !is_tls){
|
|
|
+ cw_bpf_debug("socket accept bytes_received after cid.pid=%d, cid.fd=%d\n", cid.pid, cid.fd);
|
|
|
+ __sync_fetch_and_add(&accept_conn->bytes_received, total_size);
|
|
|
+ }
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
- struct connection_id cid = {};
|
|
|
- cid.pid = pid;
|
|
|
- cid.fd = args->fd;
|
|
|
struct connection *conn = bpf_map_lookup_elem(&active_connections, &cid);
|
|
|
if (args && !conn) {
|
|
|
bpf_map_delete_elem(&active_reads, &id);
|
|
|
struct connection *accept_conn = bpf_map_lookup_elem(&active_accepts, &cid);
|
|
|
- // cw_bpf_debug("accept bytes_received cid.pid=%d, cid.fd=d\n", cid.pid, cid.fd);
|
|
|
+ cw_bpf_debug("socket accept bytes_received cid.pid=%d, cid.fd=%d\n", cid.pid, cid.fd);
|
|
|
if (accept_conn && !is_tls){
|
|
|
- cw_bpf_debug("accept bytes_received after cid.pid=%d, cid.fd=d\n", cid.pid, cid.fd);
|
|
|
+ cw_bpf_debug("socket accept bytes_received after cid.pid=%d, cid.fd=%d\n", cid.pid, cid.fd);
|
|
|
__sync_fetch_and_add(&accept_conn->bytes_received, total_size);
|
|
|
}
|
|
|
return 0;
|
|
|
@@ -790,6 +807,7 @@ int trace_exit_read(void *ctx, __u64 id, __u32 pid, __u16 is_tls, long int ret)
|
|
|
|
|
|
//TODO 5 同发送逻辑。
|
|
|
|
|
|
+ /// coroot 是以客户端为主体做统计的,所以这里是客户端逻辑
|
|
|
if (!is_tls) {
|
|
|
__sync_fetch_and_add(&conn->bytes_received, total_size);
|
|
|
}
|