|
|
@@ -50,80 +50,80 @@ static __inline bool is_socket_info_valid(struct socket_info_t *sk_info)
|
|
|
return (sk_info != NULL && sk_info->uid != 0);
|
|
|
}
|
|
|
|
|
|
-//static __inline int is_http_response(const char *data)
|
|
|
-//{
|
|
|
-// return (data[0] == 'H' && data[1] == 'T' && data[2] == 'T'
|
|
|
-// && data[3] == 'P' && data[4] == '/' && data[5] == '1'
|
|
|
-// && data[6] == '.' && data[8] == ' ');
|
|
|
-//}
|
|
|
-
|
|
|
-//static __inline int is_http_request(const char *data, int data_len)
|
|
|
-//{
|
|
|
-// switch (data[0]) {
|
|
|
-// /* DELETE */
|
|
|
-// case 'D':
|
|
|
-// if ((data[1] != 'E') || (data[2] != 'L') || (data[3] != 'E')
|
|
|
-// || (data[4] != 'T') || (data[5] != 'E')
|
|
|
-// || (data[6] != ' ')) {
|
|
|
-// return 0;
|
|
|
-// }
|
|
|
-// break;
|
|
|
-//
|
|
|
-// /* GET */
|
|
|
-// case 'G':
|
|
|
-// if ((data[1] != 'E') || (data[2] != 'T') || (data[3] != ' ')) {
|
|
|
-// return 0;
|
|
|
-// }
|
|
|
-// break;
|
|
|
-//
|
|
|
-// /* HEAD */
|
|
|
-// case 'H':
|
|
|
-// if ((data[1] != 'E') || (data[2] != 'A') || (data[3] != 'D')
|
|
|
-// || (data[4] != ' ')) {
|
|
|
-// return 0;
|
|
|
-// }
|
|
|
-// break;
|
|
|
-//
|
|
|
-// /* OPTIONS */
|
|
|
-// case 'O':
|
|
|
-// if (data_len < 8 || (data[1] != 'P') || (data[2] != 'T')
|
|
|
-// || (data[3] != 'I') || (data[4] != 'O') || (data[5] != 'N')
|
|
|
-// || (data[6] != 'S') || (data[7] != ' ')) {
|
|
|
-// return 0;
|
|
|
-// }
|
|
|
-// break;
|
|
|
-//
|
|
|
-// /* PATCH/POST/PUT */
|
|
|
-// case 'P':
|
|
|
-// switch (data[1]) {
|
|
|
-// case 'A':
|
|
|
-// if ((data[2] != 'T') || (data[3] != 'C')
|
|
|
-// || (data[4] != 'H') || (data[5] != ' ')) {
|
|
|
-// return 0;
|
|
|
-// }
|
|
|
-// break;
|
|
|
-// case 'O':
|
|
|
-// if ((data[2] != 'S') || (data[3] != 'T')
|
|
|
-// || (data[4] != ' ')) {
|
|
|
-// return 0;
|
|
|
-// }
|
|
|
-// break;
|
|
|
-// case 'U':
|
|
|
-// if ((data[2] != 'T') || (data[3] != ' ')) {
|
|
|
-// return 0;
|
|
|
-// }
|
|
|
-// break;
|
|
|
-// default:
|
|
|
-// return 0;
|
|
|
-// }
|
|
|
-// break;
|
|
|
-//
|
|
|
-// default:
|
|
|
-// return 0;
|
|
|
-// }
|
|
|
-//
|
|
|
-// return 1;
|
|
|
-//}
|
|
|
+static __inline int is_http_response2(const char *data)
|
|
|
+{
|
|
|
+ return (data[0] == 'H' && data[1] == 'T' && data[2] == 'T'
|
|
|
+ && data[3] == 'P' && data[4] == '/' && data[5] == '1'
|
|
|
+ && data[6] == '.' && data[8] == ' ');
|
|
|
+}
|
|
|
+
|
|
|
+static __inline int is_http_request2(const char *data, int data_len)
|
|
|
+{
|
|
|
+ switch (data[0]) {
|
|
|
+ /* DELETE */
|
|
|
+ case 'D':
|
|
|
+ if ((data[1] != 'E') || (data[2] != 'L') || (data[3] != 'E')
|
|
|
+ || (data[4] != 'T') || (data[5] != 'E')
|
|
|
+ || (data[6] != ' ')) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+ /* GET */
|
|
|
+ case 'G':
|
|
|
+ if ((data[1] != 'E') || (data[2] != 'T') || (data[3] != ' ')) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+ /* HEAD */
|
|
|
+ case 'H':
|
|
|
+ if ((data[1] != 'E') || (data[2] != 'A') || (data[3] != 'D')
|
|
|
+ || (data[4] != ' ')) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+ /* OPTIONS */
|
|
|
+ case 'O':
|
|
|
+ if (data_len < 8 || (data[1] != 'P') || (data[2] != 'T')
|
|
|
+ || (data[3] != 'I') || (data[4] != 'O') || (data[5] != 'N')
|
|
|
+ || (data[6] != 'S') || (data[7] != ' ')) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+ /* PATCH/POST/PUT */
|
|
|
+ case 'P':
|
|
|
+ switch (data[1]) {
|
|
|
+ case 'A':
|
|
|
+ if ((data[2] != 'T') || (data[3] != 'C')
|
|
|
+ || (data[4] != 'H') || (data[5] != ' ')) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 'O':
|
|
|
+ if ((data[2] != 'S') || (data[3] != 'T')
|
|
|
+ || (data[4] != ' ')) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 'U':
|
|
|
+ if ((data[2] != 'T') || (data[3] != ' ')) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+ default:
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ return 1;
|
|
|
+}
|
|
|
|
|
|
static __inline __u8 get_block_fragment_offset(__u8 fix_sz,
|
|
|
__u8 flags_padding,
|
|
|
@@ -350,52 +350,52 @@ static __inline enum message_type parse_http2_headers_frame(const char *buf_src,
|
|
|
return msg_type;
|
|
|
}
|
|
|
|
|
|
-//static __inline enum message_type infer_http2_message(const char *buf_src,
|
|
|
-// size_t count,
|
|
|
-// struct conn_info_t
|
|
|
-// *conn_info)
|
|
|
-//{
|
|
|
-// if (!is_protocol_enabled(PROTO_HTTP2)) {
|
|
|
-// return MSG_UNKNOWN;
|
|
|
-// }
|
|
|
-//
|
|
|
-// // When go uprobe http2 cannot be used, use kprobe/tracepoint to collect data
|
|
|
-// if (skip_http2_kprobe()) {
|
|
|
-// if (conn_info->direction == T_INGRESS &&
|
|
|
-// conn_info->tuple.l4_protocol == IPPROTO_TCP) {
|
|
|
-// struct http2_tcp_seq_key tcp_seq_key = {
|
|
|
-// .tgid = bpf_get_current_pid_tgid() >> 32,
|
|
|
-// .fd = conn_info->fd,
|
|
|
-// .tcp_seq_end =
|
|
|
-// get_tcp_read_seq_from_fd(conn_info->fd),
|
|
|
-// };
|
|
|
-// // make linux 4.14 validator happy
|
|
|
-// __u32 tcp_seq = tcp_seq_key.tcp_seq_end - count;
|
|
|
-// bpf_map_update_elem(&http2_tcp_seq_map, &tcp_seq_key,
|
|
|
-// &tcp_seq, BPF_NOEXIST);
|
|
|
-// }
|
|
|
-// return MSG_UNKNOWN;
|
|
|
-// }
|
|
|
-//
|
|
|
-// if (is_socket_info_valid(conn_info->socket_info_ptr)) {
|
|
|
-// if (conn_info->socket_info_ptr->l7_proto != PROTO_HTTP2)
|
|
|
-// return MSG_UNKNOWN;
|
|
|
-//
|
|
|
-// if (parse_http2_headers_frame(buf_src, count, conn_info, false) !=
|
|
|
-// MSG_RECONFIRM)
|
|
|
-// return MSG_UNKNOWN;
|
|
|
-//
|
|
|
-// if (conn_info->socket_info_ptr->role == ROLE_SERVER)
|
|
|
-// return (conn_info->direction == T_INGRESS) ?
|
|
|
-// MSG_REQUEST : MSG_RESPONSE;
|
|
|
-//
|
|
|
-// if (conn_info->socket_info_ptr->role == ROLE_CLIENT)
|
|
|
-// return (conn_info->direction == T_INGRESS) ?
|
|
|
-// MSG_RESPONSE: MSG_REQUEST;
|
|
|
-// }
|
|
|
-//
|
|
|
-// return parse_http2_headers_frame(buf_src, count, conn_info, true);
|
|
|
-//}
|
|
|
+static __inline enum message_type infer_http2_message(const char *buf_src,
|
|
|
+ size_t count,
|
|
|
+ struct conn_info_t
|
|
|
+ *conn_info)
|
|
|
+{
|
|
|
+ if (!is_protocol_enabled(PROTO_HTTP2)) {
|
|
|
+ return MSG_UNKNOWN;
|
|
|
+ }
|
|
|
+
|
|
|
+ // When go uprobe http2 cannot be used, use kprobe/tracepoint to collect data
|
|
|
+ if (skip_http2_kprobe()) {
|
|
|
+ if (conn_info->direction == T_INGRESS &&
|
|
|
+ conn_info->tuple.l4_protocol == IPPROTO_TCP) {
|
|
|
+ struct http2_tcp_seq_key tcp_seq_key = {
|
|
|
+ .tgid = bpf_get_current_pid_tgid() >> 32,
|
|
|
+ .fd = conn_info->fd,
|
|
|
+ .tcp_seq_end =
|
|
|
+ get_tcp_read_seq_from_fd(conn_info->fd),
|
|
|
+ };
|
|
|
+ // make linux 4.14 validator happy
|
|
|
+ __u32 tcp_seq = tcp_seq_key.tcp_seq_end - count;
|
|
|
+ bpf_map_update_elem(&http2_tcp_seq_map, &tcp_seq_key,
|
|
|
+ &tcp_seq, BPF_NOEXIST);
|
|
|
+ }
|
|
|
+ return MSG_UNKNOWN;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (is_socket_info_valid(conn_info->socket_info_ptr)) {
|
|
|
+ if (conn_info->socket_info_ptr->l7_proto != PROTO_HTTP2)
|
|
|
+ return MSG_UNKNOWN;
|
|
|
+
|
|
|
+ if (parse_http2_headers_frame(buf_src, count, conn_info, false) !=
|
|
|
+ MSG_RECONFIRM)
|
|
|
+ return MSG_UNKNOWN;
|
|
|
+
|
|
|
+ if (conn_info->socket_info_ptr->role == ROLE_SERVER)
|
|
|
+ return (conn_info->direction == T_INGRESS) ?
|
|
|
+ MSG_REQUEST : MSG_RESPONSE;
|
|
|
+
|
|
|
+ if (conn_info->socket_info_ptr->role == ROLE_CLIENT)
|
|
|
+ return (conn_info->direction == T_INGRESS) ?
|
|
|
+ MSG_RESPONSE: MSG_REQUEST;
|
|
|
+ }
|
|
|
+
|
|
|
+ return parse_http2_headers_frame(buf_src, count, conn_info, true);
|
|
|
+}
|
|
|
|
|
|
static __inline enum message_type infer_http_message(const char *buf,
|
|
|
size_t count,
|
|
|
@@ -417,13 +417,13 @@ static __inline enum message_type infer_http_message(const char *buf,
|
|
|
return MSG_UNKNOWN;
|
|
|
}
|
|
|
|
|
|
-// if (is_http_response(buf)) {
|
|
|
-// return MSG_RESPONSE;
|
|
|
-// }
|
|
|
-//
|
|
|
-// if (is_http_request(buf, count)) {
|
|
|
-// return MSG_REQUEST;
|
|
|
-// }
|
|
|
+ if (is_http_response2(buf)) {
|
|
|
+ return MSG_RESPONSE;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (is_http_request2(buf, count)) {
|
|
|
+ return MSG_REQUEST;
|
|
|
+ }
|
|
|
|
|
|
return MSG_UNKNOWN;
|
|
|
}
|
|
|
@@ -482,9 +482,9 @@ static __inline enum message_type infer_mysql_message(const char *buf,
|
|
|
struct conn_info_t
|
|
|
*conn_info)
|
|
|
{
|
|
|
-// if (!is_protocol_enabled(PROTO_MYSQL)) {
|
|
|
-// return MSG_UNKNOWN;
|
|
|
-// }
|
|
|
+ if (!is_protocol_enabled(PROTO_MYSQL)) {
|
|
|
+ return MSG_UNKNOWN;
|
|
|
+ }
|
|
|
|
|
|
if (count == 4) {
|
|
|
save_prev_data(buf, conn_info);
|
|
|
@@ -636,198 +636,198 @@ static __inline bool infer_pgsql_startup_message(const char* buf,
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-///*
|
|
|
-// * ref: https://developer.aliyun.com/article/751984
|
|
|
-// * | char tag | int32 len | payload |
|
|
|
-// * tag 的取值参考 src/flow_generator/protocol_logs/sql/postgresql.rs
|
|
|
-// */
|
|
|
-//static __inline enum message_type infer_pgsql_query_message(const char *buf,
|
|
|
-// const char *s_buf,
|
|
|
-// size_t count)
|
|
|
-//{
|
|
|
-// // Only a judgement query.
|
|
|
-// static const char tag_q = 'Q';
|
|
|
-// // In the protocol format, the size of the "len" field is 4 bytes,
|
|
|
-// // and the minimum command length is 4 bytes for "COPY/MOVE",
|
|
|
-// // The minimal length is therefore 8.
|
|
|
-// static const __u32 min_payload_len = 8;
|
|
|
-// // Typical query message size is below an artificial limit.
|
|
|
-// // 30000 is copied from postgres code base:
|
|
|
-// // https://github.com/postgres/postgres/tree/master/src/interfaces/libpq/fe-protocol3.c#L94
|
|
|
-// static const __u32 max_payload_len = 30000;
|
|
|
-// // Minimum length = tag(char) + len(int32)
|
|
|
-// static const int min_msg_len = 1 + sizeof(__u32);
|
|
|
-//
|
|
|
-// // Msg length check
|
|
|
-// if (count < min_msg_len) {
|
|
|
-// return MSG_UNKNOWN;
|
|
|
-// }
|
|
|
-//
|
|
|
-// // Tag check
|
|
|
-// if (buf[0] != tag_q) {
|
|
|
-// return MSG_UNKNOWN;
|
|
|
-// }
|
|
|
-//
|
|
|
-// // Payload length check
|
|
|
-// __u32 length;
|
|
|
-// bpf_probe_read(&length, sizeof(length), s_buf + 1);
|
|
|
-// length = __bpf_ntohl(length);
|
|
|
-// if (length < min_payload_len || length > max_payload_len) {
|
|
|
-// return MSG_UNKNOWN;
|
|
|
-// }
|
|
|
-//
|
|
|
-// // If the input includes a whole message (1 byte tag + length),
|
|
|
-// // check the last character.
|
|
|
-// if (length + 1 <= (__u32)count) {
|
|
|
-// char last_char = ' '; //Non-zero initial value
|
|
|
-// bpf_probe_read(&last_char, sizeof(last_char), s_buf + length);
|
|
|
-// if (last_char != '\0')
|
|
|
-// return MSG_UNKNOWN;
|
|
|
-// }
|
|
|
-//
|
|
|
-// return MSG_REQUEST;
|
|
|
-//}
|
|
|
-
|
|
|
-//static __inline enum message_type infer_postgre_message(const char *buf,
|
|
|
-// size_t count,
|
|
|
-// struct conn_info_t
|
|
|
-// *conn_info)
|
|
|
-//{
|
|
|
-//#define POSTGRE_INFER_BUF_SIZE 32
|
|
|
-//
|
|
|
-// if (!is_protocol_enabled(PROTO_POSTGRESQL)) {
|
|
|
-// return MSG_UNKNOWN;
|
|
|
-// }
|
|
|
-//
|
|
|
-// if (conn_info->tuple.l4_protocol != IPPROTO_TCP){
|
|
|
-// return MSG_UNKNOWN;
|
|
|
-// }
|
|
|
-//
|
|
|
-// char infer_buf[POSTGRE_INFER_BUF_SIZE];
|
|
|
-// bpf_probe_read(infer_buf, sizeof(infer_buf), buf);
|
|
|
-//
|
|
|
-// if (is_socket_info_valid(conn_info->socket_info_ptr)) {
|
|
|
-// if (conn_info->socket_info_ptr->l7_proto != PROTO_POSTGRESQL)
|
|
|
-// return MSG_UNKNOWN;
|
|
|
-// char tag = infer_buf[0];
|
|
|
-// switch (tag) {
|
|
|
-// // req, common, can not infer msg type, return MSG_REQUEST
|
|
|
-// case 'Q': case 'P': case 'B': case 'F': case 'X': case 'f':
|
|
|
-// case 'C': case 'E': case 'S': case 'D': case 'H': case 'd':
|
|
|
-// case 'c':
|
|
|
-// return MSG_REQUEST;
|
|
|
-// case 'Z': case 'I': case '1': case '2': case '3': case 'K':
|
|
|
-// case 'T': case 'n': case 'N': case 't': case 'G': case 'W':
|
|
|
-// case 'R':
|
|
|
-// return MSG_RESPONSE;
|
|
|
-// default:
|
|
|
-// return MSG_UNKNOWN;
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// if (infer_pgsql_startup_message(infer_buf, count))
|
|
|
-// return MSG_REQUEST;
|
|
|
-//
|
|
|
-// return infer_pgsql_query_message(infer_buf, buf, count);
|
|
|
-//}
|
|
|
-
|
|
|
-///*
|
|
|
-// * Request command protocol for v1
|
|
|
-// * 0 1 2 4 6 8 10 12 14 16
|
|
|
-// * +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
|
|
|
-// * |proto| type| cmdcode |ver2 | requestId |codec| timeout | classLen |
|
|
|
-// * +-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
|
|
|
-// * |headerLen | contentLen | ... ... |
|
|
|
-// * +-----------+-----------+-----------+ +
|
|
|
-// * | className + header + content bytes |
|
|
|
-// * + +
|
|
|
-// * | ... ... |
|
|
|
-// * +-----------------------------------------------------------------------------------------------+
|
|
|
-// *
|
|
|
-// * Response command protocol for v1
|
|
|
-// * 0 1 2 3 4 6 8 10 12 14 16
|
|
|
-// * +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
|
|
|
-// * |proto| type| cmdcode |ver2 | requestId |codec|respstatus | classLen |headerLen |
|
|
|
-// * +-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
|
|
|
-// * | contentLen | ... ... |
|
|
|
-// * +-----------------------+ +
|
|
|
-// * | className + header + content bytes |
|
|
|
-// * + +
|
|
|
-// * | ... ... |
|
|
|
-// * +-----------------------------------------------------------------------------------------------+
|
|
|
-// *
|
|
|
-// * ref: https://github.com/sofastack/sofa-bolt/blob/42e4e3d756b7655c0d4a058989c66d9eb09591fa/plugins/wireshark/bolt.lua
|
|
|
-// */
|
|
|
-//static __inline enum message_type infer_sofarpc_message(const char *buf,
|
|
|
-// size_t count,
|
|
|
-// struct conn_info_t
|
|
|
-// *conn_info)
|
|
|
-//{
|
|
|
-// static const __u8 bolt_resp_header_len = 20;
|
|
|
-// static const __u8 bolt_req_header_len = 22;
|
|
|
-// static const __u8 bolt_ver_v1 = 0x01;
|
|
|
-// static const __u8 type_req = 0x01;
|
|
|
-// static const __u8 type_resp = 0x0;
|
|
|
-// static const __u16 cmd_code_req = 0x01;
|
|
|
-// static const __u16 cmd_code_resp = 0x02;
|
|
|
-// static const __u8 codec_hessian = 0;
|
|
|
-// static const __u8 codec_hessian2 = 1;
|
|
|
-// static const __u8 codec_protobuf = 11;
|
|
|
-// static const __u8 codec_json = 12;
|
|
|
-//
|
|
|
-// if (count < 20 || !is_protocol_enabled(PROTO_SOFARPC))
|
|
|
-// return MSG_UNKNOWN;
|
|
|
-//
|
|
|
-// const __u8 *infer_buf = (const __u8 *)buf;
|
|
|
-// __u8 ver = infer_buf[0]; //version for protocol
|
|
|
-// __u8 type = infer_buf[1]; // request/response/request oneway
|
|
|
-//
|
|
|
-// if (is_socket_info_valid(conn_info->socket_info_ptr)) {
|
|
|
-// if (conn_info->socket_info_ptr->l7_proto != PROTO_SOFARPC)
|
|
|
-// return MSG_UNKNOWN;
|
|
|
-// goto out;
|
|
|
-// }
|
|
|
-// // code for remoting command (Heartbeat, RpcRequest, RpcResponse)
|
|
|
-// __u16 cmdcode = __bpf_ntohs(*(__u16 *) & infer_buf[2]);
|
|
|
-//
|
|
|
-// // 0 -- "hessian", 1 -- "hessian2", 11 -- "protobuf", 12 -- "json"
|
|
|
-// __u8 codec = infer_buf[9];
|
|
|
-//
|
|
|
-// if (!((ver == bolt_ver_v1)
|
|
|
-// && (type == type_req || type == type_resp)
|
|
|
-// && (cmdcode == cmd_code_req || cmdcode == cmd_code_resp)
|
|
|
-// && (codec == codec_hessian || codec == codec_hessian2
|
|
|
-// || codec == codec_protobuf || codec == codec_json)))
|
|
|
-// return MSG_UNKNOWN;
|
|
|
-//
|
|
|
-// // length of request or response class name
|
|
|
-// // length of header
|
|
|
-// __u16 class_len, header_len;
|
|
|
-//
|
|
|
-// // bolt_ver_v1
|
|
|
-// if (type == type_req) {
|
|
|
-// class_len = __bpf_ntohs(*(__u16 *) & infer_buf[14]);
|
|
|
-// header_len = __bpf_ntohs(*(__u16 *) & infer_buf[16]);
|
|
|
-// if ((bolt_req_header_len + class_len + header_len) > count)
|
|
|
-// return MSG_UNKNOWN;
|
|
|
-// }
|
|
|
-//
|
|
|
-// if (cmdcode == cmd_code_resp) {
|
|
|
-// // (resp)respStatus: response status
|
|
|
-// __u16 resp_status = __bpf_ntohl(*(__u16 *) & infer_buf[10]);
|
|
|
-// if (!(resp_status >= 0 && resp_status <= 18))
|
|
|
-// return MSG_UNKNOWN;
|
|
|
-// class_len = __bpf_ntohs(*(__u16 *) & infer_buf[12]);
|
|
|
-// header_len = __bpf_ntohs(*(__u16 *) & infer_buf[14]);
|
|
|
-// //content_len = __bpf_ntohl(*(__u32 *)&infer_buf[16]);
|
|
|
-// if ((bolt_resp_header_len + class_len + header_len) > count)
|
|
|
-// return MSG_UNKNOWN;
|
|
|
-//
|
|
|
-// }
|
|
|
-//
|
|
|
-// out:
|
|
|
-// return type == type_req ? MSG_REQUEST : MSG_RESPONSE;
|
|
|
-//}
|
|
|
+/*
|
|
|
+ * ref: https://developer.aliyun.com/article/751984
|
|
|
+ * | char tag | int32 len | payload |
|
|
|
+ * tag 的取值参考 src/flow_generator/protocol_logs/sql/postgresql.rs
|
|
|
+ */
|
|
|
+static __inline enum message_type infer_pgsql_query_message(const char *buf,
|
|
|
+ const char *s_buf,
|
|
|
+ size_t count)
|
|
|
+{
|
|
|
+ // Only a judgement query.
|
|
|
+ static const char tag_q = 'Q';
|
|
|
+ // In the protocol format, the size of the "len" field is 4 bytes,
|
|
|
+ // and the minimum command length is 4 bytes for "COPY/MOVE",
|
|
|
+ // The minimal length is therefore 8.
|
|
|
+ static const __u32 min_payload_len = 8;
|
|
|
+ // Typical query message size is below an artificial limit.
|
|
|
+ // 30000 is copied from postgres code base:
|
|
|
+ // https://github.com/postgres/postgres/tree/master/src/interfaces/libpq/fe-protocol3.c#L94
|
|
|
+ static const __u32 max_payload_len = 30000;
|
|
|
+ // Minimum length = tag(char) + len(int32)
|
|
|
+ static const int min_msg_len = 1 + sizeof(__u32);
|
|
|
+
|
|
|
+ // Msg length check
|
|
|
+ if (count < min_msg_len) {
|
|
|
+ return MSG_UNKNOWN;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Tag check
|
|
|
+ if (buf[0] != tag_q) {
|
|
|
+ return MSG_UNKNOWN;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Payload length check
|
|
|
+ __u32 length;
|
|
|
+ bpf_probe_read(&length, sizeof(length), s_buf + 1);
|
|
|
+ length = __bpf_ntohl(length);
|
|
|
+ if (length < min_payload_len || length > max_payload_len) {
|
|
|
+ return MSG_UNKNOWN;
|
|
|
+ }
|
|
|
+
|
|
|
+ // If the input includes a whole message (1 byte tag + length),
|
|
|
+ // check the last character.
|
|
|
+ if (length + 1 <= (__u32)count) {
|
|
|
+ char last_char = ' '; //Non-zero initial value
|
|
|
+ bpf_probe_read(&last_char, sizeof(last_char), s_buf + length);
|
|
|
+ if (last_char != '\0')
|
|
|
+ return MSG_UNKNOWN;
|
|
|
+ }
|
|
|
+
|
|
|
+ return MSG_REQUEST;
|
|
|
+}
|
|
|
+
|
|
|
+static __inline enum message_type infer_postgre_message(const char *buf,
|
|
|
+ size_t count,
|
|
|
+ struct conn_info_t
|
|
|
+ *conn_info)
|
|
|
+{
|
|
|
+#define POSTGRE_INFER_BUF_SIZE 32
|
|
|
+
|
|
|
+ if (!is_protocol_enabled(PROTO_POSTGRESQL)) {
|
|
|
+ return MSG_UNKNOWN;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (conn_info->tuple.l4_protocol != IPPROTO_TCP){
|
|
|
+ return MSG_UNKNOWN;
|
|
|
+ }
|
|
|
+
|
|
|
+ char infer_buf[POSTGRE_INFER_BUF_SIZE];
|
|
|
+ bpf_probe_read(infer_buf, sizeof(infer_buf), buf);
|
|
|
+
|
|
|
+ if (is_socket_info_valid(conn_info->socket_info_ptr)) {
|
|
|
+ if (conn_info->socket_info_ptr->l7_proto != PROTO_POSTGRESQL)
|
|
|
+ return MSG_UNKNOWN;
|
|
|
+ char tag = infer_buf[0];
|
|
|
+ switch (tag) {
|
|
|
+ // req, common, can not infer msg type, return MSG_REQUEST
|
|
|
+ case 'Q': case 'P': case 'B': case 'F': case 'X': case 'f':
|
|
|
+ case 'C': case 'E': case 'S': case 'D': case 'H': case 'd':
|
|
|
+ case 'c':
|
|
|
+ return MSG_REQUEST;
|
|
|
+ case 'Z': case 'I': case '1': case '2': case '3': case 'K':
|
|
|
+ case 'T': case 'n': case 'N': case 't': case 'G': case 'W':
|
|
|
+ case 'R':
|
|
|
+ return MSG_RESPONSE;
|
|
|
+ default:
|
|
|
+ return MSG_UNKNOWN;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (infer_pgsql_startup_message(infer_buf, count))
|
|
|
+ return MSG_REQUEST;
|
|
|
+
|
|
|
+ return infer_pgsql_query_message(infer_buf, buf, count);
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * Request command protocol for v1
|
|
|
+ * 0 1 2 4 6 8 10 12 14 16
|
|
|
+ * +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
|
|
|
+ * |proto| type| cmdcode |ver2 | requestId |codec| timeout | classLen |
|
|
|
+ * +-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
|
|
|
+ * |headerLen | contentLen | ... ... |
|
|
|
+ * +-----------+-----------+-----------+ +
|
|
|
+ * | className + header + content bytes |
|
|
|
+ * + +
|
|
|
+ * | ... ... |
|
|
|
+ * +-----------------------------------------------------------------------------------------------+
|
|
|
+ *
|
|
|
+ * Response command protocol for v1
|
|
|
+ * 0 1 2 3 4 6 8 10 12 14 16
|
|
|
+ * +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
|
|
|
+ * |proto| type| cmdcode |ver2 | requestId |codec|respstatus | classLen |headerLen |
|
|
|
+ * +-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
|
|
|
+ * | contentLen | ... ... |
|
|
|
+ * +-----------------------+ +
|
|
|
+ * | className + header + content bytes |
|
|
|
+ * + +
|
|
|
+ * | ... ... |
|
|
|
+ * +-----------------------------------------------------------------------------------------------+
|
|
|
+ *
|
|
|
+ * ref: https://github.com/sofastack/sofa-bolt/blob/42e4e3d756b7655c0d4a058989c66d9eb09591fa/plugins/wireshark/bolt.lua
|
|
|
+ */
|
|
|
+static __inline enum message_type infer_sofarpc_message(const char *buf,
|
|
|
+ size_t count,
|
|
|
+ struct conn_info_t
|
|
|
+ *conn_info)
|
|
|
+{
|
|
|
+ static const __u8 bolt_resp_header_len = 20;
|
|
|
+ static const __u8 bolt_req_header_len = 22;
|
|
|
+ static const __u8 bolt_ver_v1 = 0x01;
|
|
|
+ static const __u8 type_req = 0x01;
|
|
|
+ static const __u8 type_resp = 0x0;
|
|
|
+ static const __u16 cmd_code_req = 0x01;
|
|
|
+ static const __u16 cmd_code_resp = 0x02;
|
|
|
+ static const __u8 codec_hessian = 0;
|
|
|
+ static const __u8 codec_hessian2 = 1;
|
|
|
+ static const __u8 codec_protobuf = 11;
|
|
|
+ static const __u8 codec_json = 12;
|
|
|
+
|
|
|
+ if (count < 20 || !is_protocol_enabled(PROTO_SOFARPC))
|
|
|
+ return MSG_UNKNOWN;
|
|
|
+
|
|
|
+ const __u8 *infer_buf = (const __u8 *)buf;
|
|
|
+ __u8 ver = infer_buf[0]; //version for protocol
|
|
|
+ __u8 type = infer_buf[1]; // request/response/request oneway
|
|
|
+
|
|
|
+ if (is_socket_info_valid(conn_info->socket_info_ptr)) {
|
|
|
+ if (conn_info->socket_info_ptr->l7_proto != PROTO_SOFARPC)
|
|
|
+ return MSG_UNKNOWN;
|
|
|
+ goto out;
|
|
|
+ }
|
|
|
+ // code for remoting command (Heartbeat, RpcRequest, RpcResponse)
|
|
|
+ __u16 cmdcode = __bpf_ntohs(*(__u16 *) & infer_buf[2]);
|
|
|
+
|
|
|
+ // 0 -- "hessian", 1 -- "hessian2", 11 -- "protobuf", 12 -- "json"
|
|
|
+ __u8 codec = infer_buf[9];
|
|
|
+
|
|
|
+ if (!((ver == bolt_ver_v1)
|
|
|
+ && (type == type_req || type == type_resp)
|
|
|
+ && (cmdcode == cmd_code_req || cmdcode == cmd_code_resp)
|
|
|
+ && (codec == codec_hessian || codec == codec_hessian2
|
|
|
+ || codec == codec_protobuf || codec == codec_json)))
|
|
|
+ return MSG_UNKNOWN;
|
|
|
+
|
|
|
+ // length of request or response class name
|
|
|
+ // length of header
|
|
|
+ __u16 class_len, header_len;
|
|
|
+
|
|
|
+ // bolt_ver_v1
|
|
|
+ if (type == type_req) {
|
|
|
+ class_len = __bpf_ntohs(*(__u16 *) & infer_buf[14]);
|
|
|
+ header_len = __bpf_ntohs(*(__u16 *) & infer_buf[16]);
|
|
|
+ if ((bolt_req_header_len + class_len + header_len) > count)
|
|
|
+ return MSG_UNKNOWN;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (cmdcode == cmd_code_resp) {
|
|
|
+ // (resp)respStatus: response status
|
|
|
+ __u16 resp_status = __bpf_ntohl(*(__u16 *) & infer_buf[10]);
|
|
|
+ if (!(resp_status >= 0 && resp_status <= 18))
|
|
|
+ return MSG_UNKNOWN;
|
|
|
+ class_len = __bpf_ntohs(*(__u16 *) & infer_buf[12]);
|
|
|
+ header_len = __bpf_ntohs(*(__u16 *) & infer_buf[14]);
|
|
|
+ //content_len = __bpf_ntohl(*(__u32 *)&infer_buf[16]);
|
|
|
+ if ((bolt_resp_header_len + class_len + header_len) > count)
|
|
|
+ return MSG_UNKNOWN;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ out:
|
|
|
+ return type == type_req ? MSG_REQUEST : MSG_RESPONSE;
|
|
|
+}
|
|
|
|
|
|
/*
|
|
|
0 15 16 31
|
|
|
@@ -868,7 +868,7 @@ static __inline enum message_type infer_dns_message(const char *buf,
|
|
|
// if (!is_protocol_enabled(PROTO_DNS)) {
|
|
|
// return MSG_UNKNOWN;
|
|
|
// }
|
|
|
-
|
|
|
+bpf_printk("dns msg");
|
|
|
if (is_socket_info_valid(conn_info->socket_info_ptr)) {
|
|
|
if (conn_info->socket_info_ptr->l7_proto != PROTO_DNS)
|
|
|
return MSG_UNKNOWN;
|
|
|
@@ -904,6 +904,23 @@ static __inline enum message_type infer_dns_message(const char *buf,
|
|
|
bool qr = dns->qr; // QR(Response):查询请求/响应的标志信息。查询请求时,值为 0;响应时,值为 1。
|
|
|
__u8 opcode = dns->opcode; // 操作码。其中,0 表示标准查询;1 表示反向查询;2 表示服务器状态请求。
|
|
|
__u8 zero = dns->z; // Z:保留字段,在所有的请求和应答报文中,它的值必须为 0。
|
|
|
+
|
|
|
+// 打印每个字段
|
|
|
+// bpf_printk("id: %x", dns->id);
|
|
|
+// bpf_printk("rd: %hhu", dns->rd);
|
|
|
+// bpf_printk("tc: %hhu", dns->tc);
|
|
|
+// bpf_printk("aa: %hhu", dns->aa);
|
|
|
+// bpf_printk("opcode: %hhu", dns->opcode);
|
|
|
+// bpf_printk("qr: %hhu", dns->qr);
|
|
|
+// bpf_printk("rcode: %hhu", dns->rcode);
|
|
|
+// bpf_printk("cd: %hhu", dns->cd);
|
|
|
+// bpf_printk("ad: %hhu", dns->ad);
|
|
|
+// bpf_printk("z: %hhu", dns->z);
|
|
|
+// bpf_printk("ra: %hhu", dns->ra);
|
|
|
+// bpf_printk("q_count: %hu", dns->q_count);
|
|
|
+// bpf_printk("ans_count: %hu", dns->ans_count);
|
|
|
+// bpf_printk("auth_count: %hu", dns->auth_count);
|
|
|
+// bpf_printk("add_count: %hu", dns->add_count);
|
|
|
if (zero != 0) {
|
|
|
return MSG_UNKNOWN;
|
|
|
}
|
|
|
@@ -933,6 +950,11 @@ static __inline enum message_type infer_dns_message(const char *buf,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if (conn_info->dns_q_type == 0x1c) {
|
|
|
+
|
|
|
+ bpf_printk("[dns] conn_info->dns_q_type %x AAAA",conn_info->dns_q_type);
|
|
|
+ }
|
|
|
+
|
|
|
return (qr == 0) ? MSG_REQUEST : MSG_RESPONSE;
|
|
|
}
|
|
|
|
|
|
@@ -1321,94 +1343,94 @@ static __inline bool kafka_data_check_len(size_t count,
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-//static __inline enum message_type infer_kafka_message(const char *buf,
|
|
|
-// size_t count,
|
|
|
-// struct conn_info_t
|
|
|
-// *conn_info)
|
|
|
-//{
|
|
|
-// if (!is_protocol_enabled(PROTO_KAFKA)) {
|
|
|
-// return MSG_UNKNOWN;
|
|
|
-// }
|
|
|
-//
|
|
|
-// if (count == 4) {
|
|
|
-// save_prev_data(buf, conn_info);
|
|
|
-// return MSG_PRESTORE;
|
|
|
-// }
|
|
|
-//
|
|
|
-// bool is_first = true, use_prev_buf;
|
|
|
-// if (!kafka_data_check_len(count, buf, conn_info, &use_prev_buf))
|
|
|
-// return MSG_UNKNOWN;
|
|
|
-//
|
|
|
-// if (is_socket_info_valid(conn_info->socket_info_ptr)) {
|
|
|
-// if (conn_info->socket_info_ptr->l7_proto != PROTO_KAFKA)
|
|
|
-// return MSG_UNKNOWN;
|
|
|
-//
|
|
|
-// conn_info->need_reconfirm =
|
|
|
-// conn_info->socket_info_ptr->need_reconfirm;
|
|
|
-//
|
|
|
-// if (!conn_info->need_reconfirm) {
|
|
|
-// if ((conn_info->role == ROLE_CLIENT
|
|
|
-// && conn_info->direction == T_EGRESS)
|
|
|
-// || (conn_info->role == ROLE_SERVER
|
|
|
-// && conn_info->direction == T_INGRESS)) {
|
|
|
-// return MSG_REQUEST;
|
|
|
-// }
|
|
|
-//
|
|
|
-// return MSG_RESPONSE;
|
|
|
-// }
|
|
|
-//
|
|
|
-// conn_info->correlation_id =
|
|
|
-// conn_info->socket_info_ptr->correlation_id;
|
|
|
-// conn_info->role = conn_info->socket_info_ptr->role;
|
|
|
-// is_first = false;
|
|
|
-// } else
|
|
|
-// conn_info->need_reconfirm = true;
|
|
|
-//
|
|
|
-// const char *msg_buf = use_prev_buf ? buf : buf + 4;
|
|
|
-// enum message_type msg_type =
|
|
|
-// infer_kafka_request(msg_buf, is_first, conn_info);
|
|
|
-// if (msg_type == MSG_REQUEST) {
|
|
|
-// // 首次需要在socket_info_map新建socket
|
|
|
-// if (is_first) {
|
|
|
-// return MSG_RECONFIRM;
|
|
|
-// }
|
|
|
-//
|
|
|
-// /*
|
|
|
-// * socket_info_map已经存在并且需要确认(需要response的数据进一步),
|
|
|
-// * 这里的request的数据直接丢弃。
|
|
|
-// */
|
|
|
-// return MSG_UNKNOWN;
|
|
|
-// }
|
|
|
-// // 推断的第一个包必须是请求包,否则直接丢弃
|
|
|
-// if (is_first)
|
|
|
-// return MSG_UNKNOWN;
|
|
|
-//
|
|
|
-// // is response ?
|
|
|
-// // Response Header v0 => correlation_id
|
|
|
-// // correlation_id => INT32
|
|
|
-// const __s32 correlation_id = __bpf_ntohl(*(__s32 *) msg_buf);
|
|
|
-// if (correlation_id < 0)
|
|
|
-// return MSG_UNKNOWN;
|
|
|
-//
|
|
|
-// if (correlation_id == conn_info->correlation_id) {
|
|
|
-// // 完成确认
|
|
|
-// if (is_socket_info_valid(conn_info->socket_info_ptr)) {
|
|
|
-// conn_info->socket_info_ptr->need_reconfirm = false;
|
|
|
-// // 角色确认
|
|
|
-// if (conn_info->direction == T_EGRESS)
|
|
|
-// conn_info->socket_info_ptr->role = ROLE_SERVER;
|
|
|
-// else
|
|
|
-// conn_info->socket_info_ptr->role = ROLE_CLIENT;
|
|
|
-// }
|
|
|
-// } else {
|
|
|
-// // 再次确认失败直接删除socket记录。
|
|
|
-// return MSG_CLEAR;
|
|
|
-// }
|
|
|
-//
|
|
|
-// // kafka长连接的形式存在,数据开始捕获从类型推断完成开始进行。
|
|
|
-// // 此处数据(用于确认协议类型)丢弃不要,避免发给用户产生混乱。
|
|
|
-// return MSG_UNKNOWN;
|
|
|
-//}
|
|
|
+static __inline enum message_type infer_kafka_message(const char *buf,
|
|
|
+ size_t count,
|
|
|
+ struct conn_info_t
|
|
|
+ *conn_info)
|
|
|
+{
|
|
|
+ if (!is_protocol_enabled(PROTO_KAFKA)) {
|
|
|
+ return MSG_UNKNOWN;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (count == 4) {
|
|
|
+ save_prev_data(buf, conn_info);
|
|
|
+ return MSG_PRESTORE;
|
|
|
+ }
|
|
|
+
|
|
|
+ bool is_first = true, use_prev_buf;
|
|
|
+ if (!kafka_data_check_len(count, buf, conn_info, &use_prev_buf))
|
|
|
+ return MSG_UNKNOWN;
|
|
|
+
|
|
|
+ if (is_socket_info_valid(conn_info->socket_info_ptr)) {
|
|
|
+ if (conn_info->socket_info_ptr->l7_proto != PROTO_KAFKA)
|
|
|
+ return MSG_UNKNOWN;
|
|
|
+
|
|
|
+ conn_info->need_reconfirm =
|
|
|
+ conn_info->socket_info_ptr->need_reconfirm;
|
|
|
+
|
|
|
+ if (!conn_info->need_reconfirm) {
|
|
|
+ if ((conn_info->role == ROLE_CLIENT
|
|
|
+ && conn_info->direction == T_EGRESS)
|
|
|
+ || (conn_info->role == ROLE_SERVER
|
|
|
+ && conn_info->direction == T_INGRESS)) {
|
|
|
+ return MSG_REQUEST;
|
|
|
+ }
|
|
|
+
|
|
|
+ return MSG_RESPONSE;
|
|
|
+ }
|
|
|
+
|
|
|
+ conn_info->correlation_id =
|
|
|
+ conn_info->socket_info_ptr->correlation_id;
|
|
|
+ conn_info->role = conn_info->socket_info_ptr->role;
|
|
|
+ is_first = false;
|
|
|
+ } else
|
|
|
+ conn_info->need_reconfirm = true;
|
|
|
+
|
|
|
+ const char *msg_buf = use_prev_buf ? buf : buf + 4;
|
|
|
+ enum message_type msg_type =
|
|
|
+ infer_kafka_request(msg_buf, is_first, conn_info);
|
|
|
+ if (msg_type == MSG_REQUEST) {
|
|
|
+ // 首次需要在socket_info_map新建socket
|
|
|
+ if (is_first) {
|
|
|
+ return MSG_RECONFIRM;
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ * socket_info_map已经存在并且需要确认(需要response的数据进一步),
|
|
|
+ * 这里的request的数据直接丢弃。
|
|
|
+ */
|
|
|
+ return MSG_UNKNOWN;
|
|
|
+ }
|
|
|
+ // 推断的第一个包必须是请求包,否则直接丢弃
|
|
|
+ if (is_first)
|
|
|
+ return MSG_UNKNOWN;
|
|
|
+
|
|
|
+ // is response ?
|
|
|
+ // Response Header v0 => correlation_id
|
|
|
+ // correlation_id => INT32
|
|
|
+ const __s32 correlation_id = __bpf_ntohl(*(__s32 *) msg_buf);
|
|
|
+ if (correlation_id < 0)
|
|
|
+ return MSG_UNKNOWN;
|
|
|
+
|
|
|
+ if (correlation_id == conn_info->correlation_id) {
|
|
|
+ // 完成确认
|
|
|
+ if (is_socket_info_valid(conn_info->socket_info_ptr)) {
|
|
|
+ conn_info->socket_info_ptr->need_reconfirm = false;
|
|
|
+ // 角色确认
|
|
|
+ if (conn_info->direction == T_EGRESS)
|
|
|
+ conn_info->socket_info_ptr->role = ROLE_SERVER;
|
|
|
+ else
|
|
|
+ conn_info->socket_info_ptr->role = ROLE_CLIENT;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 再次确认失败直接删除socket记录。
|
|
|
+ return MSG_CLEAR;
|
|
|
+ }
|
|
|
+
|
|
|
+ // kafka长连接的形式存在,数据开始捕获从类型推断完成开始进行。
|
|
|
+ // 此处数据(用于确认协议类型)丢弃不要,避免发给用户产生混乱。
|
|
|
+ return MSG_UNKNOWN;
|
|
|
+}
|
|
|
|
|
|
static __inline bool drop_msg_by_comm(void)
|
|
|
{
|
|
|
@@ -1649,97 +1671,12 @@ infer_protocol(struct ctx_info_s *ctx,
|
|
|
* ... ...
|
|
|
* 进行快速判断。
|
|
|
*/
|
|
|
-#ifdef LINUX_VER_5_2_PLUS
|
|
|
- if (skip_proto != PROTO_HTTP1 && (inferred_message.type =
|
|
|
-#else
|
|
|
- if ((inferred_message.type =
|
|
|
-#endif
|
|
|
- infer_http_message(infer_buf, count, conn_info)) != MSG_UNKNOWN) {
|
|
|
- conn_info->infer_reliable = 1;
|
|
|
- inferred_message.protocol = PROTO_HTTP1;
|
|
|
-#ifdef LINUX_VER_5_2_PLUS
|
|
|
- } else if (skip_proto != PROTO_REDIS && (inferred_message.type =
|
|
|
-#else
|
|
|
- } else if ((inferred_message.type =
|
|
|
-#endif
|
|
|
- infer_redis_message(infer_buf, count,
|
|
|
- conn_info)) != MSG_UNKNOWN) {
|
|
|
- inferred_message.protocol = PROTO_REDIS;
|
|
|
-#ifdef LINUX_VER_5_2_PLUS
|
|
|
- } else if (skip_proto != PROTO_MQTT && (inferred_message.type =
|
|
|
-#else
|
|
|
- } else if ((inferred_message.type =
|
|
|
-#endif
|
|
|
- infer_mqtt_message(infer_buf, count,
|
|
|
- conn_info)) != MSG_UNKNOWN) {
|
|
|
- inferred_message.protocol = PROTO_MQTT;
|
|
|
-#ifdef LINUX_VER_5_2_PLUS
|
|
|
- } else if (skip_proto != PROTO_DUBBO && (inferred_message.type =
|
|
|
-#else
|
|
|
- } else if ((inferred_message.type =
|
|
|
-#endif
|
|
|
- infer_dubbo_message(infer_buf, count,
|
|
|
- conn_info)) != MSG_UNKNOWN) {
|
|
|
- inferred_message.protocol = PROTO_DUBBO;
|
|
|
-#ifdef LINUX_VER_5_2_PLUS
|
|
|
- } else if (skip_proto != PROTO_DNS && (inferred_message.type =
|
|
|
-#else
|
|
|
- } else if ((inferred_message.type =
|
|
|
-#endif
|
|
|
- infer_dns_message(infer_buf, count,
|
|
|
+ if ((inferred_message.type = infer_dns_message(infer_buf, count,
|
|
|
conn_info)) != MSG_UNKNOWN) {
|
|
|
inferred_message.protocol = PROTO_DNS;
|
|
|
}
|
|
|
-
|
|
|
if (inferred_message.protocol != MSG_UNKNOWN)
|
|
|
return inferred_message;
|
|
|
-
|
|
|
-#ifdef LINUX_VER_5_2_PLUS
|
|
|
- if (skip_proto != PROTO_MYSQL && (inferred_message.type =
|
|
|
-#else
|
|
|
- if ((inferred_message.type =
|
|
|
-#endif
|
|
|
- infer_mysql_message(infer_buf, count,
|
|
|
- conn_info)) != MSG_UNKNOWN) {
|
|
|
- if (inferred_message.type == MSG_PRESTORE)
|
|
|
- return inferred_message;
|
|
|
- inferred_message.protocol = PROTO_MYSQL;
|
|
|
-#ifdef LINUX_VER_5_2_PLUS
|
|
|
- } else if (skip_proto != PROTO_KAFKA && (inferred_message.type =
|
|
|
-#else
|
|
|
-// } else if ((inferred_message.type =
|
|
|
-#endif
|
|
|
-// infer_kafka_message(infer_buf, count,
|
|
|
-// conn_info)) != MSG_UNKNOWN) {
|
|
|
-// if (inferred_message.type == MSG_PRESTORE)
|
|
|
-// return inferred_message;
|
|
|
-// inferred_message.protocol = PROTO_KAFKA;
|
|
|
-#ifdef LINUX_VER_5_2_PLUS
|
|
|
- } else if (skip_proto != PROTO_SOFARPC && (inferred_message.type =
|
|
|
-#else
|
|
|
-// } else if ((inferred_message.type =
|
|
|
-#endif
|
|
|
-// infer_sofarpc_message(infer_buf, count,
|
|
|
-// conn_info)) != MSG_UNKNOWN){
|
|
|
-// inferred_message.protocol = PROTO_SOFARPC;
|
|
|
-#ifdef LINUX_VER_5_2_PLUS
|
|
|
- } else if (skip_proto != PROTO_HTTP2 && (inferred_message.type =
|
|
|
-#else
|
|
|
-// } else if ((inferred_message.type =
|
|
|
-#endif
|
|
|
-// infer_http2_message(syscall_infer_buf, syscall_infer_len,
|
|
|
-// conn_info)) != MSG_UNKNOWN) {
|
|
|
-// inferred_message.protocol = PROTO_HTTP2;
|
|
|
-#ifdef LINUX_VER_5_2_PLUS
|
|
|
- } else if (skip_proto != PROTO_POSTGRESQL && (inferred_message.type =
|
|
|
-#else
|
|
|
-// } else if ((inferred_message.type =
|
|
|
-#endif
|
|
|
-// infer_postgre_message(syscall_infer_buf, syscall_infer_len,
|
|
|
-// conn_info)) != MSG_UNKNOWN){
|
|
|
-// inferred_message.protocol = PROTO_POSTGRESQL;
|
|
|
- }
|
|
|
-
|
|
|
return inferred_message;
|
|
|
}
|
|
|
|