|
@@ -333,16 +333,8 @@ int trace_enter_write(void *ctx, __u64 fd, __u16 is_tls, char *buf, __u64 size,
|
|
|
__u32 http_status ;
|
|
__u32 http_status ;
|
|
|
pid = id >> 32;
|
|
pid = id >> 32;
|
|
|
tid = (__u32)id;
|
|
tid = (__u32)id;
|
|
|
- struct connection_id cid = {};
|
|
|
|
|
- cid.pid = pid;
|
|
|
|
|
- cid.fd = fd;
|
|
|
|
|
__u64 total_size = size;
|
|
__u64 total_size = size;
|
|
|
|
|
|
|
|
- struct connection *conn = bpf_map_lookup_elem(&active_connections, &cid);
|
|
|
|
|
- if (!conn) {
|
|
|
|
|
- return 0;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
if (load_filter_pid() != 0 && pid != load_filter_pid()) {
|
|
if (load_filter_pid() != 0 && pid != load_filter_pid()) {
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
@@ -359,10 +351,6 @@ int trace_enter_write(void *ctx, __u64 fd, __u16 is_tls, char *buf, __u64 size,
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (!is_tls) {
|
|
|
|
|
- __sync_fetch_and_add(&conn->bytes_sent, total_size);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
struct l7_request *req = bpf_map_lookup_elem(&l7_request_heap, &zero);
|
|
struct l7_request *req = bpf_map_lookup_elem(&l7_request_heap, &zero);
|
|
|
if (!req) {
|
|
if (!req) {
|
|
|
return 0;
|
|
return 0;
|
|
@@ -373,8 +361,8 @@ int trace_enter_write(void *ctx, __u64 fd, __u16 is_tls, char *buf, __u64 size,
|
|
|
req->ns = 0;
|
|
req->ns = 0;
|
|
|
req->payload_size = size;
|
|
req->payload_size = size;
|
|
|
struct l7_request_key k = {};
|
|
struct l7_request_key k = {};
|
|
|
- k.pid = cid.pid;
|
|
|
|
|
- k.fd = cid.fd;
|
|
|
|
|
|
|
+ k.pid = pid;
|
|
|
|
|
+ k.fd = fd;
|
|
|
k.is_tls = is_tls;
|
|
k.is_tls = is_tls;
|
|
|
k.stream_id = -1;
|
|
k.stream_id = -1;
|
|
|
|
|
|
|
@@ -455,6 +443,19 @@ int trace_enter_write(void *ctx, __u64 fd, __u16 is_tls, char *buf, __u64 size,
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ struct connection_id cid = {};
|
|
|
|
|
+ cid.pid = pid;
|
|
|
|
|
+ cid.fd = fd;
|
|
|
|
|
+
|
|
|
|
|
+ struct connection *conn = bpf_map_lookup_elem(&active_connections, &cid);
|
|
|
|
|
+ if (!conn) {
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!is_tls) {
|
|
|
|
|
+ __sync_fetch_and_add(&conn->bytes_sent, total_size);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (is_http_request(payload)) {
|
|
if (is_http_request(payload)) {
|
|
|
cw_bpf_debug("");
|
|
cw_bpf_debug("");
|
|
|
cw_bpf_debug("-----[Kernel HTTP Enter]: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);
|
|
@@ -617,15 +618,15 @@ int trace_enter_write(void *ctx, __u64 fd, __u16 is_tls, char *buf, __u64 size,
|
|
|
|
|
|
|
|
static inline __attribute__((__always_inline__))
|
|
static inline __attribute__((__always_inline__))
|
|
|
int trace_enter_read(__u64 id, __u32 pid, __u64 fd, char *buf, __u64 *ret, __u64 iovlen) {
|
|
int trace_enter_read(__u64 id, __u32 pid, __u64 fd, char *buf, __u64 *ret, __u64 iovlen) {
|
|
|
- struct connection_id cid = {};
|
|
|
|
|
- cid.pid = pid;
|
|
|
|
|
- cid.fd = fd;
|
|
|
|
|
-
|
|
|
|
|
- struct connection *conn = bpf_map_lookup_elem(&active_connections, &cid);
|
|
|
|
|
- if (!conn) {
|
|
|
|
|
- return 0;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+ // struct connection_id cid = {};
|
|
|
|
|
+ // cid.pid = pid;
|
|
|
|
|
+ // cid.fd = fd;
|
|
|
|
|
+
|
|
|
|
|
+ // struct connection *conn = bpf_map_lookup_elem(&active_connections, &cid);
|
|
|
|
|
+ // if (!conn) {
|
|
|
|
|
+ // // cw_bpf_debug("trace_enter_read no conn\n");
|
|
|
|
|
+ // return 0;
|
|
|
|
|
+ // }
|
|
|
struct read_args args = {};
|
|
struct read_args args = {};
|
|
|
args.fd = fd;
|
|
args.fd = fd;
|
|
|
args.buf = buf;
|
|
args.buf = buf;
|
|
@@ -647,17 +648,9 @@ int trace_exit_read(void *ctx, __u64 id, __u32 pid, __u16 is_tls, long int ret)
|
|
|
if (!args) {
|
|
if (!args) {
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
- struct connection_id cid = {};
|
|
|
|
|
- cid.pid = pid;
|
|
|
|
|
- cid.fd = args->fd;
|
|
|
|
|
- struct connection *conn = bpf_map_lookup_elem(&active_connections, &cid);
|
|
|
|
|
- if (!conn) {
|
|
|
|
|
- bpf_map_delete_elem(&active_reads, &id);
|
|
|
|
|
- return 0;
|
|
|
|
|
- }
|
|
|
|
|
struct l7_request_key k = {};
|
|
struct l7_request_key k = {};
|
|
|
- k.pid = cid.pid;
|
|
|
|
|
- k.fd = cid.fd;
|
|
|
|
|
|
|
+ k.pid = pid;
|
|
|
|
|
+ k.fd = args->fd;
|
|
|
k.is_tls = is_tls;
|
|
k.is_tls = is_tls;
|
|
|
k.stream_id = -1;
|
|
k.stream_id = -1;
|
|
|
|
|
|
|
@@ -689,10 +682,6 @@ int trace_exit_read(void *ctx, __u64 id, __u32 pid, __u16 is_tls, long int ret)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (!is_tls) {
|
|
|
|
|
- __sync_fetch_and_add(&conn->bytes_received, total_size);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
struct l7_event *e = bpf_map_lookup_elem(&l7_event_heap, &zero);
|
|
struct l7_event *e = bpf_map_lookup_elem(&l7_event_heap, &zero);
|
|
|
if (!e) {
|
|
if (!e) {
|
|
|
return 0;
|
|
return 0;
|
|
@@ -777,6 +766,19 @@ int trace_exit_read(void *ctx, __u64 id, __u32 pid, __u16 is_tls, long int ret)
|
|
|
return 0;
|
|
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);
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!is_tls) {
|
|
|
|
|
+ __sync_fetch_and_add(&conn->bytes_received, total_size);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (is_rabbitmq_consume(payload, ret)) {
|
|
if (is_rabbitmq_consume(payload, ret)) {
|
|
|
e->protocol = PROTOCOL_RABBITMQ;
|
|
e->protocol = PROTOCOL_RABBITMQ;
|
|
|
e->method = METHOD_CONSUME;
|
|
e->method = METHOD_CONSUME;
|