Skip to content

Commit e678fbc

Browse files
committed
Add tuple info
1 parent 50bc182 commit e678fbc

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

agent/src/ebpf/kernel/include/common.h

+1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ enum process_data_extra_source {
103103
DATA_SOURCE_GO_HTTP2_DATAFRAME_UPROBE,
104104
DATA_SOURCE_CLOSE,
105105
DATA_SOURCE_DPDK,
106+
DATA_SOURCE_UNIX_SOCKET,
106107
};
107108

108109
struct protocol_message_t {

agent/src/ebpf/kernel/socket_trace.bpf.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -1640,7 +1640,11 @@ __data_submit(struct pt_regs *ctx, struct conn_info_s *conn_info,
16401640
v->extra_data_count = 0;
16411641

16421642
v->coroutine_id = trace_key.goid;
1643-
v->source = extra->source;
1643+
1644+
if (conn_info->sk_type == SOCK_UNIX)
1645+
v->source = DATA_SOURCE_UNIX_SOCKET;
1646+
else
1647+
v->source = extra->source;
16441648

16451649
#if defined(LINUX_VER_KFUNC) || defined(LINUX_VER_5_2_PLUS)
16461650
__u32 cache_key = ((__u32) bpf_get_current_pid_tgid()) >> 16;

agent/src/ebpf/user/socket.c

+8
Original file line numberDiff line numberDiff line change
@@ -1126,6 +1126,14 @@ static void reader_raw_cb(void *cookie, void *raw, int raw_size)
11261126
if (sd->source != DATA_SOURCE_DPDK) {
11271127
submit_data->socket_id = sd->socket_id;
11281128
submit_data->tuple = sd->tuple;
1129+
if (sd->source == DATA_SOURCE_UNIX_SOCKET) {
1130+
submit_data->tuple.l4_protocol = IPPROTO_UDP;
1131+
submit_data->tuple.dport = submit_data->tuple.num = 0;
1132+
submit_data->tuple.addr_len = 4;
1133+
*(in_addr_t *)submit_data->tuple.rcv_saddr = htonl(0x7F000001);
1134+
*(in_addr_t *)submit_data->tuple.daddr = htonl(0x7F000001);
1135+
}
1136+
11291137
submit_data->need_reconfirm =
11301138
need_proto_reconfirm(sd->data_type);
11311139
submit_data->process_id = sd->tgid;

0 commit comments

Comments
 (0)