summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluwenpeng <[email protected]>2022-12-29 17:24:00 +0800
committerluwenpeng <[email protected]>2022-12-29 17:24:06 +0800
commitf2856eaa0b134876400bebf6f4d7f543e57f2e94 (patch)
treee0ce2e2dfcbc31e49a1fa6c03e8018e0148fcec4
parentcd93796cce9f5e23af18aa521f1b3da6a0c0b0bb (diff)
TSG-13196 Decrypted Traffic Steering增加FieldStat字段
* stee_c_err * stee_s_err * stee_c_eof * stee_s_eof
-rw-r--r--platform/include/internal/platform.h2
-rw-r--r--platform/src/tcp_stream.cpp56
2 files changed, 50 insertions, 8 deletions
diff --git a/platform/include/internal/platform.h b/platform/include/internal/platform.h
index 446683e..9248009 100644
--- a/platform/include/internal/platform.h
+++ b/platform/include/internal/platform.h
@@ -59,6 +59,8 @@ enum tfe_stream_event_log_type
EVENT_LOG_CLOSE_BY_FD_EOF,
EVENT_LOG_CLOSE_BY_FD_ERROR,
EVENT_LOG_CLOSE_BY_SSL_ERROR,
+ EVENT_LOG_CLOSE_BY_FACKFD_EOF,
+ EVENT_LOG_CLOSE_BY_FACKFD_ERROR,
__EVENT_LOG_CLOSE_MAX
};
diff --git a/platform/src/tcp_stream.cpp b/platform/src/tcp_stream.cpp
index 15a22be..c60500c 100644
--- a/platform/src/tcp_stream.cpp
+++ b/platform/src/tcp_stream.cpp
@@ -68,7 +68,9 @@ static const char * __str_stream_log_type(enum tfe_stream_event_log_type type)
[EVENT_LOG_CLOSE_BY_FD_PEER] = "FD/PEER",
[EVENT_LOG_CLOSE_BY_FD_EOF] = "FD/EOF",
[EVENT_LOG_CLOSE_BY_FD_ERROR] = "FD/ERR",
- [EVENT_LOG_CLOSE_BY_SSL_ERROR] = "SSL/ERR"
+ [EVENT_LOG_CLOSE_BY_SSL_ERROR] = "SSL/ERR",
+ [EVENT_LOG_CLOSE_BY_FACKFD_EOF] = "FACKFD/EOF",
+ [EVENT_LOG_CLOSE_BY_FACKFD_ERROR] = "FACKFD/ERR",
};
return map_event_log_type[type];
}
@@ -157,6 +159,18 @@ static const char *bev_event_to_string(short events)
}
}
+static const char *errno_to_string(int err_num)
+{
+ if (err_num == 0)
+ {
+ return "";
+ }
+ else
+ {
+ return strerror(err_num);
+ }
+}
+
/* ====================================================================================================================
* INTERFACE
* ===================================================================================================================*/
@@ -903,13 +917,20 @@ static void __stream_bev_eventcb(struct bufferevent * bev, short events, void *
(STREAM_PROTO_PLAIN == _stream->session_type && _stream->proxy_ref->traffic_steering_options.enable_steering_http) ||
(STREAM_PROTO_SSL == _stream->session_type &&_stream->proxy_ref->traffic_steering_options.enable_steering_ssl)))
{
- // TODO 增加计数
TFE_LOG_DEBUG(__STREAM_LOGGER(_stream), "decrypted traffic steering, %s %s run eventcb, %s %s",
_stream->str_stream_addr,
bev == _stream->conn_downstream->bev ? "conn_downstream" : "conn_upstream",
bev_event_to_string(events),
- errno == 0 ? "" : strerror(errno)
+ errno_to_string(errno)
);
+ if (events & BEV_EVENT_ERROR)
+ {
+ __stream_log_event(_stream, EVENT_LOG_CLOSE_BY_FD_ERROR, conn_dir, errno, errno_to_string(errno));
+ }
+ if (events & BEV_EVENT_EOF)
+ {
+ __stream_log_event(_stream, EVENT_LOG_CLOSE_BY_FD_EOF, conn_dir, errno, errno_to_string(errno));
+ }
tfe_stream_destory(_stream);
return;
}
@@ -1158,8 +1179,18 @@ static void __steering_stream_bev_eventcb(struct bufferevent *bev, short events,
_stream->str_stream_addr,
bev == _stream->conn_fake_c->bev ? "conn_fake_c" : "conn_fake_s",
bev_event_to_string(events),
- errno == 0 ? "" : strerror(errno)
+ errno_to_string(errno)
);
+
+ enum tfe_conn_dir conn_dir = (bev == _stream->conn_fake_c->bev) ? CONN_DIR_DOWNSTREAM : CONN_DIR_UPSTREAM;
+ if (events & BEV_EVENT_ERROR)
+ {
+ __stream_log_event(_stream, EVENT_LOG_CLOSE_BY_FACKFD_ERROR, conn_dir, errno, errno_to_string(errno));
+ }
+ if (events & BEV_EVENT_EOF)
+ {
+ __stream_log_event(_stream, EVENT_LOG_CLOSE_BY_FACKFD_EOF, conn_dir, errno, errno_to_string(errno));
+ }
tfe_stream_destory(_stream);
}
@@ -1332,7 +1363,7 @@ void __stream_access_log_write(struct tfe_stream_private * stream)
struct tfe_stream_event_log * ev_log = &stream->log_event[i];
const char * str_dir = ev_log->dir == CONN_DIR_DOWNSTREAM ? "DOWN" : "UP";
offset += snprintf(str_log_event + offset, sizeof(str_log_event) - offset,
- "%s/%s ", __str_stream_log_type(ev_log->type), str_dir);
+ "%s/%s/%s ", __str_stream_log_type(ev_log->type), str_dir, ev_log->str_error);
}
MESA_handle_runtime_log(stream->stream_logger, RLOG_LV_INFO, "access",
@@ -1346,13 +1377,22 @@ void __ev_log_to_stat_map_init() __attribute__((constructor, used));
void __ev_log_to_stat_map_init()
{
ev_log_to_stat_map[EVENT_LOG_CLOSE_BY_FD_PEER][CONN_DIR_DOWNSTREAM] = -1;
- ev_log_to_stat_map[EVENT_LOG_CLOSE_BY_FD_EOF][CONN_DIR_DOWNSTREAM] = STAT_STREAM_CLS_DOWN_EOF;
- ev_log_to_stat_map[EVENT_LOG_CLOSE_BY_FD_ERROR][CONN_DIR_DOWNSTREAM] = STAT_STREAM_CLS_DOWN_ERR;
- ev_log_to_stat_map[EVENT_LOG_CLOSE_BY_SSL_ERROR][CONN_DIR_DOWNSTREAM] = STAT_STREAM_CLS_DOWN_ERR;
ev_log_to_stat_map[EVENT_LOG_CLOSE_BY_FD_PEER][CONN_DIR_UPSTREAM] = -1;
+
+ ev_log_to_stat_map[EVENT_LOG_CLOSE_BY_FD_EOF][CONN_DIR_DOWNSTREAM] = STAT_STREAM_CLS_DOWN_EOF;
ev_log_to_stat_map[EVENT_LOG_CLOSE_BY_FD_EOF][CONN_DIR_UPSTREAM] = STAT_STREAM_CLS_UP_EOF;
+
+ ev_log_to_stat_map[EVENT_LOG_CLOSE_BY_FD_ERROR][CONN_DIR_DOWNSTREAM] = STAT_STREAM_CLS_DOWN_ERR;
ev_log_to_stat_map[EVENT_LOG_CLOSE_BY_FD_ERROR][CONN_DIR_UPSTREAM] = STAT_STREAM_CLS_UP_ERR;
+
+ ev_log_to_stat_map[EVENT_LOG_CLOSE_BY_SSL_ERROR][CONN_DIR_DOWNSTREAM] = STAT_STREAM_CLS_DOWN_ERR;
ev_log_to_stat_map[EVENT_LOG_CLOSE_BY_SSL_ERROR][CONN_DIR_UPSTREAM] = STAT_STREAM_CLS_UP_ERR;
+
+ ev_log_to_stat_map[EVENT_LOG_CLOSE_BY_FACKFD_EOF][CONN_DIR_DOWNSTREAM] = STAT_STEERING_CLIENT_EOF;
+ ev_log_to_stat_map[EVENT_LOG_CLOSE_BY_FACKFD_EOF][CONN_DIR_UPSTREAM] = STAT_STEERING_SERVER_EOF;
+
+ ev_log_to_stat_map[EVENT_LOG_CLOSE_BY_FACKFD_ERROR][CONN_DIR_DOWNSTREAM] = STAT_STEERING_CLIENT_ERR;
+ ev_log_to_stat_map[EVENT_LOG_CLOSE_BY_FACKFD_ERROR][CONN_DIR_UPSTREAM] = STAT_STEERING_SERVER_ERR;
}
void __stream_close_stat(struct tfe_stream_private * stream)