|
|
@@ -142,6 +142,9 @@ struct l7_request {
|
|
|
__u8 partial;
|
|
|
__u8 request_type;
|
|
|
__s32 request_id;
|
|
|
+ __u64 trace_id;
|
|
|
+ unsigned char assumed_app_id[APM_ASSUMED_APP_ID_SIZE];
|
|
|
+ unsigned char span_id[APM_SPAN_ID_SIZE];
|
|
|
__u64 payload_size;
|
|
|
char payload[MAX_PAYLOAD_SIZE];
|
|
|
};
|
|
|
@@ -234,7 +237,7 @@ void send_event(void *ctx, struct l7_event *e, __u32 pid, __u64 fd) {
|
|
|
__u64 *timestamp = bpf_map_lookup_elem(&connection_timestamps, &sk);
|
|
|
if (timestamp) {
|
|
|
if (*timestamp == 0) {
|
|
|
- bpf_printk("timestamp=0");
|
|
|
+// cw_bpf_debug("timestamp=0");
|
|
|
return;
|
|
|
}
|
|
|
e->connection_timestamp = *timestamp;
|
|
|
@@ -398,7 +401,7 @@ int trace_enter_write(void *ctx, __u64 fd, __u16 is_tls, char *buf, __u64 size,
|
|
|
cw_copy_byte_arrays(cw_psc->app_id, e->app_id_from, APM_APP_ID_SIZE);
|
|
|
cw_copy_byte_arrays(cw_psc->span_id, e->span_id_from, APM_SPAN_ID_SIZE);
|
|
|
// for (int i = 0; i < APM_TRACE_ID_SIZE; i++) {
|
|
|
-// bpf_printk("trace_enter_write - span_id_from = %02x", e->span_id_from[i]);
|
|
|
+// cw_bpf_debug("trace_enter_write - span_id_from = %02x", e->span_id_from[i]);
|
|
|
// }
|
|
|
}
|
|
|
struct l7_request *req = bpf_map_lookup_elem(&active_l7_requests, &k);
|
|
|
@@ -445,19 +448,41 @@ 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");
|
|
|
+ cw_bpf_debug("HTTP_END");
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
if (is_http_request(payload)) {
|
|
|
cw_bpf_debug("");
|
|
|
- cw_bpf_debug("-----[Kernel Enter][HTTP]:pid:[%d]|CURRENT-GOID:[%llu]|FD:[%d]", tid, get_current_goroutine(), k.fd);
|
|
|
+ cw_bpf_debug("-----[Kernel HTTP Enter]:pid:[%d]|CURRENT-GOID:[%llu]|FD:[%d]", tid, get_current_goroutine(), k.fd);
|
|
|
+ __u8 type = 0;
|
|
|
+ __u64 trace_id = 0;
|
|
|
+ struct apm_trace_info_t * trace_info = get_apm_trace_info(pid, tid);
|
|
|
|
|
|
- req->protocol = PROTOCOL_HTTP;
|
|
|
-// struct apm_trace_key_t trace_key = {0};
|
|
|
-// trace_key = get_apm_trace_key(120 * NS_PER_SEC, true);
|
|
|
-// cw_bpf_debug("[Enter] [HTTP]:goid:%llu",trace_key.goid);
|
|
|
+ if (trace_info== NULL) {
|
|
|
+ trace_info = get_apm_trace_info_v3(id, pid, tid);
|
|
|
+ }
|
|
|
|
|
|
+ if (trace_info) {
|
|
|
+// cw_bpf_debug("%llu",trace_info->trace_id);
|
|
|
+ trace_id = trace_info->trace_id;
|
|
|
+ type = trace_info->type;
|
|
|
+ }
|
|
|
+ req->protocol = PROTOCOL_HTTP;
|
|
|
+ req->trace_id = trace_id;
|
|
|
+ struct apm_span_context * sc = cw_get_current_tracking_span(trace_info);
|
|
|
+ if (sc) {
|
|
|
+ cw_copy_byte_arrays(sc->assumed_app_id, req->assumed_app_id, APM_ASSUMED_APP_ID_SIZE);
|
|
|
+ cw_copy_byte_arrays(sc->span_id, req->span_id, APM_SPAN_ID_SIZE);
|
|
|
+// for (int i = 0; i < APM_ASSUMED_APP_ID_SIZE; i++) {
|
|
|
+// cw_bpf_debug("assumed_app_id-assumed_app_id[%d] = %02x", i, req->assumed_app_id[i]);
|
|
|
+// }
|
|
|
+// for (int i = 0; i < APM_SPAN_ID_SIZE; i++) {
|
|
|
+// cw_bpf_debug("cw_get_current_tracking_span-span_id[%d] = %02x", i, req->span_id[i]);
|
|
|
+// }
|
|
|
+ }
|
|
|
+ // 0默认,1
|
|
|
+ cw_bpf_debug("[Kernel HTTP Enter]req-payload:%s [traceid:%llu][type:%d]",payload,trace_id,type);
|
|
|
|
|
|
} else if (is_postgres_query(payload, size, &req->request_type)) {
|
|
|
if (req->request_type == POSTGRES_FRAME_CLOSE) {
|
|
|
@@ -498,7 +523,7 @@ int trace_enter_write(void *ctx, __u64 fd, __u16 is_tls, char *buf, __u64 size,
|
|
|
}
|
|
|
req->protocol = PROTOCOL_MYSQL;
|
|
|
} else if (is_dm_query(payload, size,&req->request_type)) {
|
|
|
-// bpf_printk("[Request][DM] start -------->");
|
|
|
+// cw_bpf_debug("[Request][DM] start -------->");
|
|
|
req->protocol = PROTOCOL_DM;
|
|
|
|
|
|
struct l7_request_dm_ctx *dm_ctx ;
|
|
|
@@ -511,7 +536,7 @@ int trace_enter_write(void *ctx, __u64 fd, __u16 is_tls, char *buf, __u64 size,
|
|
|
dm_ctx->req_start_at_ns = 0 ;
|
|
|
dm_ctx->status = 0;
|
|
|
bpf_map_update_elem(&active_l7_requests_dm_ctx, &k, dm_ctx, BPF_NOEXIST);
|
|
|
-// bpf_printk("[Request][DM] init active_l7_requests_dm_ctx,request_type <0x%x> [%d]",req->request_type,req->request_type);
|
|
|
+// cw_bpf_debug("[Request][DM] init active_l7_requests_dm_ctx,request_type <0x%x> [%d]",req->request_type,req->request_type);
|
|
|
}
|
|
|
|
|
|
if (req->request_type == DM_QUERY) {
|
|
|
@@ -528,8 +553,8 @@ int trace_enter_write(void *ctx, __u64 fd, __u16 is_tls, char *buf, __u64 size,
|
|
|
bpf_map_update_elem(&active_l7_requests, &k, req, BPF_ANY);
|
|
|
return 0 ;
|
|
|
}
|
|
|
-// bpf_printk("[Request][DM] is request ,request_type <0x%x> [%d]",req->request_type,req->request_type);
|
|
|
-// bpf_printk("[Request][DM] end <--------");
|
|
|
+// cw_bpf_debug("[Request][DM] is request ,request_type <0x%x> [%d]",req->request_type,req->request_type);
|
|
|
+// cw_bpf_debug("[Request][DM] end <--------");
|
|
|
} else if (is_mongo_query(payload, size)) {
|
|
|
req->protocol = PROTOCOL_MONGO;
|
|
|
} else if (is_rabbitmq_produce(payload, size)) {
|
|
|
@@ -657,7 +682,6 @@ int trace_exit_read(void *ctx, __u64 id, __u32 pid, __u16 is_tls, long int ret)
|
|
|
e->payload_size = 0;
|
|
|
__u8 b[8];
|
|
|
bpf_read(payload, b);
|
|
|
- bpf_printk("payload44444:[0x%x]",b[4]);
|
|
|
// __u32 k0 = 0;
|
|
|
// struct member_fields_offset *offset = members_offset__lookup(&k0);
|
|
|
// if (!offset)
|
|
|
@@ -745,9 +769,9 @@ int trace_exit_read(void *ctx, __u64 id, __u32 pid, __u16 is_tls, long int ret)
|
|
|
struct l7_request *req = bpf_map_lookup_elem(&active_l7_requests, &k);
|
|
|
int response = 0;
|
|
|
if (!req) {
|
|
|
- bpf_printk("no req? 6:[0x%x] k.pid:%d, k.fd:%d",b[4],k.pid,k.fd);
|
|
|
+// cw_bpf_debug("no req? 6:[0x%x] k.pid:%d, k.fd:%d",b[4],k.pid,k.fd);
|
|
|
if (is_dns_response(payload, ret, &k.stream_id, &e->status)) {
|
|
|
- bpf_printk("dns");
|
|
|
+// cw_bpf_debug("dns");
|
|
|
req = bpf_map_lookup_elem(&active_l7_requests, &k);
|
|
|
if (!req) {
|
|
|
return 0;
|
|
|
@@ -775,7 +799,7 @@ int trace_exit_read(void *ctx, __u64 id, __u32 pid, __u16 is_tls, long int ret)
|
|
|
send_event(ctx, e, k.pid, k.fd);
|
|
|
return 0;
|
|
|
} else {
|
|
|
- bpf_printk("bb 6:[0x%x] k.pid:%d, k.fd:%d",b[4],k.pid,k.fd);
|
|
|
+// cw_bpf_debug("bb 6:[0x%x] k.pid:%d, k.fd:%d",b[4],k.pid,k.fd);
|
|
|
return 0;
|
|
|
}
|
|
|
}
|
|
|
@@ -785,90 +809,76 @@ int trace_exit_read(void *ctx, __u64 id, __u32 pid, __u16 is_tls, long int ret)
|
|
|
COPY_PAYLOAD(e->payload, req->payload_size, req->payload);
|
|
|
|
|
|
bpf_map_delete_elem(&active_l7_requests, &k);
|
|
|
- bpf_printk("delete req--------:[0x%x] k.pid:%d, k.fd:%d",b[4],k.pid,k.fd);
|
|
|
- if (e->protocol == PROTOCOL_HTTP) {
|
|
|
- __u64 trace_id = get_apm_trace_id(pid, tid);
|
|
|
- e->trace_id = trace_id;
|
|
|
- struct apm_span_context * sc = cw_get_current_tracking_span();
|
|
|
- if (sc) {
|
|
|
- cw_copy_byte_arrays(sc->assumed_app_id, e->assumed_app_id, APM_ASSUMED_APP_ID_SIZE);
|
|
|
- cw_copy_byte_arrays(sc->span_id, e->span_id, APM_SPAN_ID_SIZE);
|
|
|
+// cw_bpf_debug("delete req--------:[0x%x] k.pid:%d, k.fd:%d",b[4],k.pid,k.fd);
|
|
|
+ if (e->protocol == PROTOCOL_HTTP) {
|
|
|
+ __u64 trace_id = req->trace_id;
|
|
|
+ e->trace_id = trace_id;
|
|
|
+// struct apm_span_context * sc = cw_get_current_tracking_span();
|
|
|
+// if (sc) {
|
|
|
+ cw_copy_byte_arrays(req->assumed_app_id, e->assumed_app_id, APM_ASSUMED_APP_ID_SIZE);
|
|
|
+ cw_copy_byte_arrays(req->span_id, e->span_id, APM_SPAN_ID_SIZE);
|
|
|
// for (int i = 0; i < APM_ASSUMED_APP_ID_SIZE; i++) {
|
|
|
-// bpf_printk("assumed_app_id-assumed_app_id[%d] = %02x", i, sc->assumed_app_id[i]);
|
|
|
+// cw_bpf_debug("assumed_app_id-assumed_app_id[%d] = %02x", i, req->assumed_app_id[i]);
|
|
|
// }
|
|
|
- }
|
|
|
+// for (int i = 0; i < APM_SPAN_ID_SIZE; i++) {
|
|
|
+// cw_bpf_debug("cw_get_current_tracking_span-span_id[%d] = %02x", i, req->span_id[i]);
|
|
|
+// }
|
|
|
+// }
|
|
|
// cw_bpf_debug("[Response][HTTP222]:thread_id:%d|type:%s|FD:%d\n",k.pid,"",k.fd);
|
|
|
// cw_bpf_debug("[Response][HTTP222] trace_id:%llu", trace_id);
|
|
|
// // 请求报文
|
|
|
-// cw_bpf_debug("[Response][HTTP222] req-payload:%s",e->payload);
|
|
|
+// cw_bpf_debug("[Response][HTTP222] req-payload:%s",e->payload);
|
|
|
// // 响应报文
|
|
|
// cw_bpf_debug("[Response][HTTP222] resp-payload:%s",payload);
|
|
|
|
|
|
- response = is_http_response(payload, &e->status);
|
|
|
-// if (trace_id == 0) {
|
|
|
-// __u64 goid = get_current_goroutine();
|
|
|
-// cw_bpf_debug("[Kernel End] go_id:%llu",goid);
|
|
|
-//
|
|
|
-// }
|
|
|
- if (e->trace_id == 0){
|
|
|
- struct thread_trace_key_t t_key = get_thread_trace_key(id);
|
|
|
- struct apm_trace_info_t *trace_info = bpf_map_lookup_elem(&thread_trace_info_heap, &t_key);
|
|
|
- if (trace_info) {
|
|
|
- if (trace_info->trace_id == 0){
|
|
|
- cw_bpf_debug("get trace_id from enter pid:[%d]|thread_trace_key_t:[%llu]", tid,trace_info->trace_id);
|
|
|
- e->trace_id=trace_info->trace_id;
|
|
|
- }
|
|
|
- } else {
|
|
|
- // 从子事件的头获取线程id
|
|
|
- }
|
|
|
- }
|
|
|
- cw_bpf_debug("[Kernel End][HTTP]:pid:[%d]|CURRENT-GOID:[%llu]|trace_id:[%llu]---------\n", tid, get_current_goroutine(),e->trace_id);
|
|
|
+ response = is_http_response(payload, &e->status);
|
|
|
+// cw_bpf_debug("[Kernel End][HTTP]:pid:[%d]|CURRENT-GOID:[%llu]|trace_id:[%llu]---------\n", tid, get_current_goroutine(),e->trace_id);
|
|
|
|
|
|
- } else if (e->protocol == PROTOCOL_POSTGRES) {
|
|
|
- response = is_postgres_response(payload, ret, &e->status);
|
|
|
- if (req->request_type == POSTGRES_FRAME_PARSE) {
|
|
|
- e->method = METHOD_STATEMENT_PREPARE;
|
|
|
- }
|
|
|
- } else if (e->protocol == PROTOCOL_REDIS) {
|
|
|
- cw_bpf_debug("[Response][Redis]:TGID:%d|type:%s|FD:%d\n",k.pid,"",k.fd);
|
|
|
- __u64 trace_id = get_apm_trace_id(pid, tid);
|
|
|
- cw_bpf_debug("[Redis] trace_id:%llu", trace_id);
|
|
|
- e->trace_id = trace_id;
|
|
|
- response = is_redis_response(payload, ret, &e->status);
|
|
|
- } else if (e->protocol == PROTOCOL_MEMCACHED) {
|
|
|
- response = is_memcached_response(payload, ret, &e->status);
|
|
|
- } else if (e->protocol == PROTOCOL_MYSQL) {
|
|
|
- bpf_printk("[Response][Mysql]:thread_id:%d\n",tid);
|
|
|
- __u64 trace_id = get_apm_trace_id(pid, tid);
|
|
|
+ } else if (e->protocol == PROTOCOL_POSTGRES) {
|
|
|
+ response = is_postgres_response(payload, ret, &e->status);
|
|
|
+ if (req->request_type == POSTGRES_FRAME_PARSE) {
|
|
|
+ e->method = METHOD_STATEMENT_PREPARE;
|
|
|
+ }
|
|
|
+ } else if (e->protocol == PROTOCOL_REDIS) {
|
|
|
+ cw_bpf_debug("[Response][Redis]:TGID:%d|type:%s|FD:%d\n", k.pid, "", k.fd);
|
|
|
+ __u64 trace_id = get_apm_trace_id(pid, tid);
|
|
|
+ cw_bpf_debug("[Redis] trace_id:%llu", trace_id);
|
|
|
+ e->trace_id = trace_id;
|
|
|
+ response = is_redis_response(payload, ret, &e->status);
|
|
|
+ } else if (e->protocol == PROTOCOL_MEMCACHED) {
|
|
|
+ response = is_memcached_response(payload, ret, &e->status);
|
|
|
+ } else if (e->protocol == PROTOCOL_MYSQL) {
|
|
|
+ cw_bpf_debug("[Response][Mysql]:thread_id:%d\n", tid);
|
|
|
+ __u64 trace_id = get_apm_trace_id(pid, tid);
|
|
|
// cw_bpf_debug("[Mysql] trace_id:%llu", trace_id);
|
|
|
- e->trace_id = trace_id;
|
|
|
- response = is_mysql_response(payload, ret, req->request_type, &e->statement_id, &e->status);
|
|
|
- if (req->request_type == MYSQL_COM_STMT_PREPARE) {
|
|
|
- e->method = METHOD_STATEMENT_PREPARE;
|
|
|
- }
|
|
|
- } else if (e->protocol == PROTOCOL_DM) {
|
|
|
+ e->trace_id = trace_id;
|
|
|
+ response = is_mysql_response(payload, ret, req->request_type, &e->statement_id, &e->status);
|
|
|
+ if (req->request_type == MYSQL_COM_STMT_PREPARE) {
|
|
|
+ e->method = METHOD_STATEMENT_PREPARE;
|
|
|
+ }
|
|
|
+ } else if (e->protocol == PROTOCOL_DM) {
|
|
|
|
|
|
-// bpf_printk("[Response][DM] start -------->");
|
|
|
+// cw_bpf_debug("[Response][DM] start -------->");
|
|
|
|
|
|
- struct l7_request_dm_ctx *dm_ctx = bpf_map_lookup_elem(&active_l7_requests_dm_ctx, &k);
|
|
|
- if (!dm_ctx) {
|
|
|
- return 0;
|
|
|
- }
|
|
|
- //获取server端的字符集类型(用来编码数据库名称,暂时不用)
|
|
|
+ struct l7_request_dm_ctx *dm_ctx = bpf_map_lookup_elem(&active_l7_requests_dm_ctx, &k);
|
|
|
+ if (!dm_ctx) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ //获取server端的字符集类型(用来编码数据库名称,暂时不用)
|
|
|
// if(req->request_type == DM_VERSION_CLI) {
|
|
|
// __u8 srv_encode_buf[4];
|
|
|
// bpf_read(payload+DM_SVR_ENCODING_OFFSET, srv_encode_buf);
|
|
|
//
|
|
|
-// bpf_printk(" srv_encode_buf:[0x%x]",srv_encode_buf[0]);
|
|
|
-// bpf_printk(" srv_encode_buf:[0x%x]",srv_encode_buf[1]);
|
|
|
-// bpf_printk(" srv_encode_buf:[0x%x]",srv_encode_buf[2]);
|
|
|
-// bpf_printk(" srv_encode_buf:[0x%x]",srv_encode_buf[3]);
|
|
|
+// cw_bpf_debug(" srv_encode_buf:[0x%x]",srv_encode_buf[0]);
|
|
|
+// cw_bpf_debug(" srv_encode_buf:[0x%x]",srv_encode_buf[1]);
|
|
|
+// cw_bpf_debug(" srv_encode_buf:[0x%x]",srv_encode_buf[2]);
|
|
|
+// cw_bpf_debug(" srv_encode_buf:[0x%x]",srv_encode_buf[3]);
|
|
|
// dm_ctx->srv_encoding = (__s32)(srv_encode_buf[0]& 0xff) | ((__s32)srv_encode_buf[1]&0xff) << 8 | ((__s32)srv_encode_buf[2]&0xff) << 16 | ((__s32)srv_encode_buf[3]&0xff) << 24 ;
|
|
|
-// bpf_printk(" srv_encode_buf:[%d]",dm_ctx->srv_encoding);
|
|
|
+// cw_bpf_debug(" srv_encode_buf:[%d]",dm_ctx->srv_encoding);
|
|
|
// bpf_map_update_elem(&active_l7_requests_dm_ctx, &k, dm_ctx, BPF_ANY);
|
|
|
// return 0;
|
|
|
// }
|
|
|
- //获取数据库名称(暂时不用)
|
|
|
+ //获取数据库名称(暂时不用)
|
|
|
// if(req->request_type == DM_DO_LOGIN ) {
|
|
|
//// //todo 拷贝payload 不进行处理,留给用户空间处理
|
|
|
//// //pack_type == DM_LOGIN_ACK
|
|
|
@@ -886,50 +896,50 @@ int trace_exit_read(void *ctx, __u64 id, __u32 pid, __u16 is_tls, long int ret)
|
|
|
// __s32 tmp_len = (__s32)(tmp_1[0]& 0xff) | ((__s32)tmp_1[1]&0xff) << 8 | ((__s32)tmp_1[2]&0xff) << 16 | ((__s32)tmp_1[3]&0xff) << 24 ;
|
|
|
// tmp_offset = tmp_offset + 4 ;
|
|
|
// tmp_offset = tmp_offset+tmp_len ;
|
|
|
-// bpf_printk("===== DM_LOGIN_ACK ----1 tmp_len:%d",tmp_len);
|
|
|
+// cw_bpf_debug("===== DM_LOGIN_ACK ----1 tmp_len:%d",tmp_len);
|
|
|
//
|
|
|
// //2
|
|
|
// bpf_read(payload+tmp_offset,tmp_1);
|
|
|
// tmp_len = (__s32)(tmp_1[0]& 0xff) | ((__s32)tmp_1[1]&0xff) << 8 | ((__s32)tmp_1[2]&0xff) << 16 | ((__s32)tmp_1[3]&0xff) << 24 ;
|
|
|
// tmp_offset = tmp_offset + 4 ;
|
|
|
// tmp_offset = tmp_offset+tmp_len ;
|
|
|
-// bpf_printk("===== DM_LOGIN_ACK ----2 tmp_len:%d",tmp_len);
|
|
|
+// cw_bpf_debug("===== DM_LOGIN_ACK ----2 tmp_len:%d",tmp_len);
|
|
|
// //3
|
|
|
// bpf_read(payload+tmp_offset,tmp_1);
|
|
|
// tmp_len = (__s32)(tmp_1[0]& 0xff) | ((__s32)tmp_1[1]&0xff) << 8 | ((__s32)tmp_1[2]&0xff) << 16 | ((__s32)tmp_1[3]&0xff) << 24 ;
|
|
|
// tmp_offset = tmp_offset + 4 ;
|
|
|
// tmp_offset = tmp_offset+tmp_len ;
|
|
|
-// bpf_printk("===== DM_LOGIN_ACK ----3 tmp_len:%d",tmp_len);
|
|
|
+// cw_bpf_debug("===== DM_LOGIN_ACK ----3 tmp_len:%d",tmp_len);
|
|
|
// //4
|
|
|
// bpf_read(payload+tmp_offset,tmp_1);
|
|
|
// tmp_len = (__s32)(tmp_1[0]& 0xff) | ((__s32)tmp_1[1]&0xff) << 8 | ((__s32)tmp_1[2]&0xff) << 16 | ((__s32)tmp_1[3]&0xff) << 24 ;
|
|
|
// tmp_offset = tmp_offset + 4 ;
|
|
|
// tmp_offset = tmp_offset+tmp_len ;
|
|
|
-// bpf_printk("===== DM_LOGIN_ACK ----4 tmp_len:%d",tmp_len);
|
|
|
+// cw_bpf_debug("===== DM_LOGIN_ACK ----4 tmp_len:%d",tmp_len);
|
|
|
// //5
|
|
|
// bpf_read(payload+tmp_offset,tmp_1);
|
|
|
// tmp_len = (__s32)(tmp_1[0]& 0xff) | ((__s32)tmp_1[1]&0xff) << 8 | ((__s32)tmp_1[2]&0xff) << 16 | ((__s32)tmp_1[3]&0xff) << 24 ;
|
|
|
// tmp_offset = tmp_offset + 4 ;
|
|
|
// tmp_offset = tmp_offset+tmp_len ;
|
|
|
-// bpf_printk("===== DM_LOGIN_ACK ----5 tmp_len:%d",tmp_len);
|
|
|
+// cw_bpf_debug("===== DM_LOGIN_ACK ----5 tmp_len:%d",tmp_len);
|
|
|
// //6
|
|
|
// bpf_read(payload+tmp_offset,tmp_1);
|
|
|
// tmp_len = (__s32)(tmp_1[0]& 0xff) | ((__s32)tmp_1[1]&0xff) << 8 | ((__s32)tmp_1[2]&0xff) << 16 | ((__s32)tmp_1[3]&0xff) << 24 ;
|
|
|
// tmp_offset = tmp_offset + 4 ;
|
|
|
// tmp_offset = tmp_offset+tmp_len ;
|
|
|
-// bpf_printk("===== DM_LOGIN_ACK ----6 tmp_len:%d",tmp_len);
|
|
|
+// cw_bpf_debug("===== DM_LOGIN_ACK ----6 tmp_len:%d",tmp_len);
|
|
|
// //7
|
|
|
// bpf_read(payload+tmp_offset,tmp_1);
|
|
|
// tmp_len = (__s32)(tmp_1[0]& 0xff) | ((__s32)tmp_1[1]&0xff) << 8 | ((__s32)tmp_1[2]&0xff) << 16 | ((__s32)tmp_1[3]&0xff) << 24 ;
|
|
|
// tmp_offset = tmp_offset + 4 ;
|
|
|
// tmp_offset = tmp_offset+tmp_len ;
|
|
|
-// bpf_printk("===== DM_LOGIN_ACK ----7 tmp_len:%d",tmp_len);
|
|
|
+// cw_bpf_debug("===== DM_LOGIN_ACK ----7 tmp_len:%d",tmp_len);
|
|
|
// //8
|
|
|
// bpf_read(payload+tmp_offset,tmp_1);
|
|
|
// tmp_len = (__s32)(tmp_1[0]& 0xff) | ((__s32)tmp_1[1]&0xff) << 8 | ((__s32)tmp_1[2]&0xff) << 16 | ((__s32)tmp_1[3]&0xff) << 24 ;
|
|
|
// tmp_offset = tmp_offset + 4 ;
|
|
|
// tmp_offset = tmp_offset+tmp_len ;
|
|
|
-// bpf_printk("===== DM_LOGIN_ACK ----8 tmp_len:%d",tmp_len);
|
|
|
+// cw_bpf_debug("===== DM_LOGIN_ACK ----8 tmp_len:%d",tmp_len);
|
|
|
//
|
|
|
// //9
|
|
|
// tmp_offset = tmp_offset + 4 ;
|
|
|
@@ -942,14 +952,14 @@ int trace_exit_read(void *ctx, __u64 id, __u32 pid, __u16 is_tls, long int ret)
|
|
|
// tmp_len = (__s32)(tmp_1[0]& 0xff) | ((__s32)tmp_1[1]&0xff) << 8 | ((__s32)tmp_1[2]&0xff) << 16 | ((__s32)tmp_1[3]&0xff) << 24 ;
|
|
|
// tmp_offset = tmp_offset + 4 ;
|
|
|
// tmp_offset = tmp_offset+tmp_len ;
|
|
|
-// bpf_printk("===== DM_LOGIN_ACK ----12 tmp_len:%d",tmp_len);
|
|
|
+// cw_bpf_debug("===== DM_LOGIN_ACK ----12 tmp_len:%d",tmp_len);
|
|
|
// //13
|
|
|
// bpf_read(payload+tmp_offset,tmp_1);
|
|
|
// tmp_offset = tmp_offset + 4 ;
|
|
|
// tmp_len = (__s32)(tmp_1[0]& 0xff) | ((__s32)tmp_1[1]&0xff) << 8 | ((__s32)tmp_1[2]&0xff) << 16 | ((__s32)tmp_1[3]&0xff) << 24 ;
|
|
|
-// bpf_printk("===== DM_LOGIN_ACK ----13 tmp_len:%d",tmp_len);
|
|
|
+// cw_bpf_debug("===== DM_LOGIN_ACK ----13 tmp_len:%d",tmp_len);
|
|
|
//
|
|
|
-// bpf_printk("===== DM_LOGIN_ACK dbName tmp_offset:%d",tmp_offset);
|
|
|
+// cw_bpf_debug("===== DM_LOGIN_ACK dbName tmp_offset:%d",tmp_offset);
|
|
|
// if(tmp_len>0){
|
|
|
//// char dbNameBuff[7] ;
|
|
|
// char dbNameBuff[128] ;
|
|
|
@@ -958,62 +968,62 @@ int trace_exit_read(void *ctx, __u64 id, __u32 pid, __u16 is_tls, long int ret)
|
|
|
// }
|
|
|
// bpf_read(payload+tmp_offset,dbNameBuff);
|
|
|
// dbNameBuff[tmp_len-1]='\0';
|
|
|
-//// bpf_printk("===== DM-resp DM_LOGIN_ACK dbName[0]:%c",dbNameBuff[0]);
|
|
|
-//// bpf_printk("===== DM-resp DM_LOGIN_ACK dbName[1]:%c",dbNameBuff[1]);
|
|
|
-//// bpf_printk("===== DM-resp DM_LOGIN_ACK dbName[2]:%c",dbNameBuff[2]);
|
|
|
-//// bpf_printk("===== DM-resp DM_LOGIN_ACK dbName[3]:%c",dbNameBuff[3]);
|
|
|
-//// bpf_printk("===== DM-resp DM_LOGIN_ACK dbName[4]:%c",dbNameBuff[4]);
|
|
|
-//// bpf_printk("===== DM-resp DM_LOGIN_ACK dbName[5]:%c",dbNameBuff[5]);
|
|
|
-// bpf_printk("===== DM_LOGIN_ACK dbName:%s",dbNameBuff);
|
|
|
+//// cw_bpf_debug("===== DM-resp DM_LOGIN_ACK dbName[0]:%c",dbNameBuff[0]);
|
|
|
+//// cw_bpf_debug("===== DM-resp DM_LOGIN_ACK dbName[1]:%c",dbNameBuff[1]);
|
|
|
+//// cw_bpf_debug("===== DM-resp DM_LOGIN_ACK dbName[2]:%c",dbNameBuff[2]);
|
|
|
+//// cw_bpf_debug("===== DM-resp DM_LOGIN_ACK dbName[3]:%c",dbNameBuff[3]);
|
|
|
+//// cw_bpf_debug("===== DM-resp DM_LOGIN_ACK dbName[4]:%c",dbNameBuff[4]);
|
|
|
+//// cw_bpf_debug("===== DM-resp DM_LOGIN_ACK dbName[5]:%c",dbNameBuff[5]);
|
|
|
+// cw_bpf_debug("===== DM_LOGIN_ACK dbName:%s",dbNameBuff);
|
|
|
//
|
|
|
// __u32 dn_name_size = (__u32)tmp_len + 1 ;
|
|
|
// COPY_PAYLOAD(dm_ctx->db_name,dn_name_size, dbNameBuff);
|
|
|
-// bpf_printk("===== DM_LOGIN_ACK strcpy(db_name,dbNameBuff):%s",dm_ctx->db_name);
|
|
|
+// cw_bpf_debug("===== DM_LOGIN_ACK strcpy(db_name,dbNameBuff):%s",dm_ctx->db_name);
|
|
|
// bpf_map_update_elem(&active_l7_requests_dm_ctx, &k, dm_ctx, BPF_ANY);
|
|
|
// }
|
|
|
// return 0;
|
|
|
// }
|
|
|
|
|
|
- __u64 trace_id = get_apm_trace_id(pid, tid);
|
|
|
- e->trace_id = trace_id;
|
|
|
-// bpf_printk("[Response][DM] trace_id:%llu", trace_id);
|
|
|
+ __u64 trace_id = get_apm_trace_id(pid, tid);
|
|
|
+ e->trace_id = trace_id;
|
|
|
+// cw_bpf_debug("[Response][DM] trace_id:%llu", trace_id);
|
|
|
|
|
|
- response = is_dm_response(payload, ret, req->request_type, &dm_ctx->status);
|
|
|
-// bpf_printk("[Response][DM] is_dm_response status ---------- %d",dm_ctx->status);
|
|
|
+ response = is_dm_response(payload, ret, req->request_type, &dm_ctx->status);
|
|
|
+// cw_bpf_debug("[Response][DM] is_dm_response status ---------- %d",dm_ctx->status);
|
|
|
|
|
|
- if(response) {
|
|
|
- req->ns = dm_ctx->req_start_at_ns;
|
|
|
- e->status = dm_ctx->status;
|
|
|
- e->payload_size = dm_ctx->query_sql_payload_size;
|
|
|
- COPY_PAYLOAD(e->payload, dm_ctx->query_sql_payload_size, dm_ctx->query_sql_payload);
|
|
|
- bpf_map_delete_elem(&active_l7_requests_dm_ctx, &k);
|
|
|
-// bpf_printk("[Response][DM] is response ,delete active_l7_requests_dm_ctx -- req->request_type<0x%x> , e->payload_size:[%d]",req->request_type,e->payload_size);
|
|
|
- }
|
|
|
+ if (response) {
|
|
|
+ req->ns = dm_ctx->req_start_at_ns;
|
|
|
+ e->status = dm_ctx->status;
|
|
|
+ e->payload_size = dm_ctx->query_sql_payload_size;
|
|
|
+ COPY_PAYLOAD(e->payload, dm_ctx->query_sql_payload_size, dm_ctx->query_sql_payload);
|
|
|
+ bpf_map_delete_elem(&active_l7_requests_dm_ctx, &k);
|
|
|
+// cw_bpf_debug("[Response][DM] is response ,delete active_l7_requests_dm_ctx -- req->request_type<0x%x> , e->payload_size:[%d]",req->request_type,e->payload_size);
|
|
|
+ }
|
|
|
// else {
|
|
|
-// bpf_printk("[Response][DM] not response req->request_type <0x%x>",req->request_type);
|
|
|
+// cw_bpf_debug("[Response][DM] not response req->request_type <0x%x>",req->request_type);
|
|
|
// }
|
|
|
|
|
|
-// bpf_printk("[Response][DM] end <---------\n");
|
|
|
- } else if (e->protocol == PROTOCOL_MONGO) {
|
|
|
- response = is_mongo_response(payload, ret, req->partial);
|
|
|
- if (response == 2) { // partial
|
|
|
- struct l7_request *r = bpf_map_lookup_elem(&l7_request_heap, &zero);
|
|
|
- if (!r) {
|
|
|
- return 0;
|
|
|
- }
|
|
|
- r->partial = 1;
|
|
|
- r->protocol = e->protocol;
|
|
|
- r->ns = req->ns;
|
|
|
- r->payload_size = req->payload_size;
|
|
|
- COPY_PAYLOAD(r->payload, req->payload_size, req->payload);
|
|
|
- bpf_map_update_elem(&active_l7_requests, &k, r, BPF_ANY);
|
|
|
- return 0;
|
|
|
- }
|
|
|
- } else if (e->protocol == PROTOCOL_KAFKA) {
|
|
|
- response = is_kafka_response(payload, req->request_id);
|
|
|
- } else if (e->protocol == PROTOCOL_DUBBO2) {
|
|
|
- response = is_dubbo2_response(payload, &e->status);
|
|
|
- }
|
|
|
+// cw_bpf_debug("[Response][DM] end <---------\n");
|
|
|
+ } else if (e->protocol == PROTOCOL_MONGO) {
|
|
|
+ response = is_mongo_response(payload, ret, req->partial);
|
|
|
+ if (response == 2) { // partial
|
|
|
+ struct l7_request *r = bpf_map_lookup_elem(&l7_request_heap, &zero);
|
|
|
+ if (!r) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ r->partial = 1;
|
|
|
+ r->protocol = e->protocol;
|
|
|
+ r->ns = req->ns;
|
|
|
+ r->payload_size = req->payload_size;
|
|
|
+ COPY_PAYLOAD(r->payload, req->payload_size, req->payload);
|
|
|
+ bpf_map_update_elem(&active_l7_requests, &k, r, BPF_ANY);
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ } else if (e->protocol == PROTOCOL_KAFKA) {
|
|
|
+ response = is_kafka_response(payload, req->request_id);
|
|
|
+ } else if (e->protocol == PROTOCOL_DUBBO2) {
|
|
|
+ response = is_dubbo2_response(payload, &e->status);
|
|
|
+ }
|
|
|
|
|
|
if (!response) {
|
|
|
return 0;
|