TSG-16126 修复Proxy Events日志中存在c2s和s2c有字节数为0的问题
This commit is contained in:
4
cache/src/tango_cache_client.cpp
vendored
4
cache/src/tango_cache_client.cpp
vendored
@@ -63,7 +63,7 @@ static int wired_load_balancer_lookup(WLB_handle_t wiredlb, const char *key, int
|
|||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
snprintf(host, hostsize, "%s:%u", chosen.ip_addr, chosen.data_port);
|
snprintf(host, hostsize, "%s:%hu", chosen.ip_addr, chosen.data_port);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -714,7 +714,7 @@ int tango_cache_delete_object(struct tango_cache_instance *instance, struct futu
|
|||||||
struct tango_cache_ctx *tango_cache_multi_delete_prepare(struct tango_cache_instance *instance, struct future* f, char *objlist[], u_int32_t num)
|
struct tango_cache_ctx *tango_cache_multi_delete_prepare(struct tango_cache_instance *instance, struct future* f, char *objlist[], u_int32_t num)
|
||||||
{
|
{
|
||||||
struct tango_cache_ctx *ctx;
|
struct tango_cache_ctx *ctx;
|
||||||
char md5[48]={0}, content_md5[48];
|
char md5[48]={0}, content_md5[64];
|
||||||
|
|
||||||
if(sessions_exceeds_limit(instance, OBJECT_IN_HOS))
|
if(sessions_exceeds_limit(instance, OBJECT_IN_HOS))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ tfe_kafka_logger_t *tfe_kafka_logger_create(int enable, const char *nic_name, co
|
|||||||
override_sled_ip = getenv("OVERRIDE_SLED_IP");
|
override_sled_ip = getenv("OVERRIDE_SLED_IP");
|
||||||
if(override_sled_ip != NULL)
|
if(override_sled_ip != NULL)
|
||||||
{
|
{
|
||||||
strncpy(logger->local_ip_str, override_sled_ip, strlen(override_sled_ip));
|
strncpy(logger->local_ip_str, override_sled_ip, sizeof(logger->local_ip_str)-1);
|
||||||
goto create_kafka;
|
goto create_kafka;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,7 +132,7 @@ tfe_kafka_logger_t *tfe_kafka_logger_create(int enable, const char *nic_name, co
|
|||||||
inet_ntop(AF_INET, &(logger->local_ip_num), logger->local_ip_str, sizeof(logger->local_ip_str));
|
inet_ntop(AF_INET, &(logger->local_ip_num), logger->local_ip_str, sizeof(logger->local_ip_str));
|
||||||
|
|
||||||
create_kafka:
|
create_kafka:
|
||||||
strncpy(logger->broker_list, brokerlist, strlen(brokerlist));
|
strncpy(logger->broker_list, brokerlist, sizeof(logger->broker_list)-1);
|
||||||
logger->kafka_handle = create_kafka_handle(logger->broker_list, sasl_username, sasl_passwd, local_logger);
|
logger->kafka_handle = create_kafka_handle(logger->broker_list, sasl_username, sasl_passwd, local_logger);
|
||||||
if (logger->kafka_handle == NULL)
|
if (logger->kafka_handle == NULL)
|
||||||
{
|
{
|
||||||
@@ -141,7 +141,7 @@ create_kafka:
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(logger->topic_name, topic_name, strlen(topic_name));
|
strncpy(logger->topic_name, topic_name, sizeof(logger->topic_name)-1);
|
||||||
logger->kafka_topic = rd_kafka_topic_new(logger->kafka_handle, logger->topic_name, NULL);
|
logger->kafka_topic = rd_kafka_topic_new(logger->kafka_handle, logger->topic_name, NULL);
|
||||||
if (logger->kafka_topic == NULL)
|
if (logger->kafka_topic == NULL)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ struct proxy_log
|
|||||||
char *asn_server;
|
char *asn_server;
|
||||||
char *location_client;
|
char *location_client;
|
||||||
char *location_server;
|
char *location_server;
|
||||||
|
size_t c2s_byte_num;
|
||||||
|
size_t s2c_byte_num;
|
||||||
};
|
};
|
||||||
struct proxy_logger;
|
struct proxy_logger;
|
||||||
struct proxy_logger* proxy_log_handle_create(const char* profile, const char* section, void* local_logger);
|
struct proxy_logger* proxy_log_handle_create(const char* profile, const char* section, void* local_logger);
|
||||||
|
|||||||
@@ -462,7 +462,7 @@ static int http_lua_get_5tuple(struct elua_vm *vm)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char ip_addr[64]={0};
|
char ip_addr[128]={0};
|
||||||
unsigned int source=0,dest=0,protocol;
|
unsigned int source=0,dest=0,protocol;
|
||||||
char src_ip_str[MAX(INET6_ADDRSTRLEN,INET_ADDRSTRLEN)] = {0};
|
char src_ip_str[MAX(INET6_ADDRSTRLEN,INET_ADDRSTRLEN)] = {0};
|
||||||
char dst_ip_str[MAX(INET6_ADDRSTRLEN,INET_ADDRSTRLEN)] = {0};
|
char dst_ip_str[MAX(INET6_ADDRSTRLEN,INET_ADDRSTRLEN)] = {0};
|
||||||
|
|||||||
@@ -1272,6 +1272,8 @@ struct proxy_http_ctx
|
|||||||
struct cache_write_context* cache_write_ctx;
|
struct cache_write_context* cache_write_ctx;
|
||||||
int cache_wirte_result;
|
int cache_wirte_result;
|
||||||
|
|
||||||
|
size_t c2s_byte_num;
|
||||||
|
size_t s2c_byte_num;
|
||||||
int thread_id;
|
int thread_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2027,7 +2029,7 @@ static void http_get_subscriber_id(const struct tfe_stream * stream, char *repla
|
|||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
uint16_t opt_out_size;
|
uint16_t opt_out_size;
|
||||||
char source_subscribe_id[TFE_STRING_MAX] = {0};
|
char source_subscribe_id[TFE_SYMBOL_MAX] = {0};
|
||||||
struct tfe_cmsg *cmsg = tfe_stream_get0_cmsg(stream);
|
struct tfe_cmsg *cmsg = tfe_stream_get0_cmsg(stream);
|
||||||
if (cmsg != NULL)
|
if (cmsg != NULL)
|
||||||
{
|
{
|
||||||
@@ -2070,7 +2072,7 @@ static int http_regex_replace(const struct tfe_stream * stream, char *message, i
|
|||||||
}
|
}
|
||||||
if(strcasestr(message,"tsg_subscriber_id") != NULL)
|
if(strcasestr(message,"tsg_subscriber_id") != NULL)
|
||||||
{
|
{
|
||||||
memset(replace_with, TFE_SYMBOL_MAX, 0);
|
memset(replace_with, 0, TFE_SYMBOL_MAX);
|
||||||
rule[n_rule].zone = kZoneRequestUri;
|
rule[n_rule].zone = kZoneRequestUri;
|
||||||
rule[n_rule].find = tfe_strdup("{{tsg_subscriber_id}}");
|
rule[n_rule].find = tfe_strdup("{{tsg_subscriber_id}}");
|
||||||
http_get_subscriber_id(stream, replace_with);
|
http_get_subscriber_id(stream, replace_with);
|
||||||
@@ -2079,7 +2081,7 @@ static int http_regex_replace(const struct tfe_stream * stream, char *message, i
|
|||||||
}
|
}
|
||||||
if(strcasestr(message,"tsg_client_ip") != NULL)
|
if(strcasestr(message,"tsg_client_ip") != NULL)
|
||||||
{
|
{
|
||||||
memset(replace_with, TFE_SYMBOL_MAX, 0);
|
memset(replace_with, 0, TFE_SYMBOL_MAX);
|
||||||
rule[n_rule].zone = kZoneRequestUri;
|
rule[n_rule].zone = kZoneRequestUri;
|
||||||
rule[n_rule].find = tfe_strdup("{{tsg_client_ip}}");
|
rule[n_rule].find = tfe_strdup("{{tsg_client_ip}}");
|
||||||
http_get_client_id(stream, replace_with);
|
http_get_client_id(stream, replace_with);
|
||||||
@@ -2840,6 +2842,9 @@ void enforce_control_policy(const struct tfe_stream * stream, const struct tfe_h
|
|||||||
evbuffer_add(ctx->log_resp_body, body_frag, frag_size);
|
evbuffer_add(ctx->log_resp_body, body_frag, frag_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tfe_stream_info_get(stream, INFO_FROM_DOWNSTREAM_RX_OFFSET, &(ctx->c2s_byte_num), sizeof(ctx->c2s_byte_num));
|
||||||
|
tfe_stream_info_get(stream, INFO_FROM_UPSTREAM_RX_OFFSET, &(ctx->s2c_byte_num), sizeof(ctx->s2c_byte_num));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#define RESUMED_CB_NO_MORE_CALLS 0
|
#define RESUMED_CB_NO_MORE_CALLS 0
|
||||||
@@ -3341,7 +3346,7 @@ void proxy_on_http_end(const struct tfe_stream * stream,
|
|||||||
struct proxy_log log_msg = {.stream=stream, .http=session, .result=(struct log_rule_t *)ctx->enforce_rules, .result_num=ctx->n_enforce,
|
struct proxy_log log_msg = {.stream=stream, .http=session, .result=(struct log_rule_t *)ctx->enforce_rules, .result_num=ctx->n_enforce,
|
||||||
.req_body=ctx->log_req_body, .resp_body=ctx->log_resp_body, .action=0, .inject_sz=ctx->inject_sz,
|
.req_body=ctx->log_req_body, .resp_body=ctx->log_resp_body, .action=0, .inject_sz=ctx->inject_sz,
|
||||||
.asn_client=ctx->ip_ctx.asn_client, .asn_server=ctx->ip_ctx.asn_server, .location_client=ctx->ip_ctx.location_client,
|
.asn_client=ctx->ip_ctx.asn_client, .asn_server=ctx->ip_ctx.asn_server, .location_client=ctx->ip_ctx.location_client,
|
||||||
.location_server=ctx->ip_ctx.location_server};
|
.location_server=ctx->ip_ctx.location_server, .c2s_byte_num=ctx->c2s_byte_num, .s2c_byte_num=ctx->s2c_byte_num};
|
||||||
if(ctx->action == PX_ACTION_MANIPULATE)
|
if(ctx->action == PX_ACTION_MANIPULATE)
|
||||||
{
|
{
|
||||||
log_msg.action = ctx->param->action;
|
log_msg.action = ctx->param->action;
|
||||||
|
|||||||
@@ -217,9 +217,18 @@ int proxy_send_log(struct proxy_logger* handle, const struct proxy_log* log_msg)
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
size_t c2s_byte_num = 0, s2c_byte_num =0;
|
|
||||||
tfe_stream_info_get(log_msg->stream, INFO_FROM_DOWNSTREAM_RX_OFFSET, &c2s_byte_num, sizeof(c2s_byte_num));
|
size_t ret=0, c2s_byte_num = 0, s2c_byte_num =0;
|
||||||
tfe_stream_info_get(log_msg->stream, INFO_FROM_UPSTREAM_RX_OFFSET, &s2c_byte_num, sizeof(s2c_byte_num));
|
ret = tfe_stream_info_get(log_msg->stream, INFO_FROM_DOWNSTREAM_RX_OFFSET, &c2s_byte_num, sizeof(c2s_byte_num));
|
||||||
|
if(ret != 0)
|
||||||
|
{
|
||||||
|
c2s_byte_num = log_msg->c2s_byte_num;
|
||||||
|
}
|
||||||
|
ret = tfe_stream_info_get(log_msg->stream, INFO_FROM_UPSTREAM_RX_OFFSET, &s2c_byte_num, sizeof(s2c_byte_num));
|
||||||
|
if(ret !=0)
|
||||||
|
{
|
||||||
|
s2c_byte_num = log_msg->s2c_byte_num;
|
||||||
|
}
|
||||||
|
|
||||||
cJSON_AddNumberToObject(common_obj, "common_link_id", 0);
|
cJSON_AddNumberToObject(common_obj, "common_link_id", 0);
|
||||||
cJSON_AddNumberToObject(common_obj, "common_stream_dir", 3); //1:c2s, 2:s2c, 3:double
|
cJSON_AddNumberToObject(common_obj, "common_stream_dir", 3); //1:c2s, 2:s2c, 3:double
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ TEST(PatternReplace, UrlReplace)
|
|||||||
}
|
}
|
||||||
if(strcasestr(rd_url,"tsg_subscriber_id") != NULL)
|
if(strcasestr(rd_url,"tsg_subscriber_id") != NULL)
|
||||||
{
|
{
|
||||||
memset(replace_with, TFE_SYMBOL_MAX, 0);
|
memset(replace_with, 0, TFE_SYMBOL_MAX);
|
||||||
rule[n_rule].zone = kZoneRequestUri;
|
rule[n_rule].zone = kZoneRequestUri;
|
||||||
rule[n_rule].find = tfe_strdup("{{tsg_subscriber_id}}");
|
rule[n_rule].find = tfe_strdup("{{tsg_subscriber_id}}");
|
||||||
rule[n_rule].replace_with = tfe_strdup(" ");
|
rule[n_rule].replace_with = tfe_strdup(" ");
|
||||||
@@ -206,7 +206,7 @@ TEST(PatternReplace, UrlReplace)
|
|||||||
}
|
}
|
||||||
if(strcasestr(rd_url,"tsg_client_ip") != NULL)
|
if(strcasestr(rd_url,"tsg_client_ip") != NULL)
|
||||||
{
|
{
|
||||||
memset(replace_with, TFE_SYMBOL_MAX, 0);
|
memset(replace_with, 0, TFE_SYMBOL_MAX);
|
||||||
rule[n_rule].zone = kZoneRequestUri;
|
rule[n_rule].zone = kZoneRequestUri;
|
||||||
rule[n_rule].find = tfe_strdup("{{tsg_client_ip}}");
|
rule[n_rule].find = tfe_strdup("{{tsg_client_ip}}");
|
||||||
rule[n_rule].replace_with = tfe_strdup("192.168.50.71");
|
rule[n_rule].replace_with = tfe_strdup("192.168.50.71");
|
||||||
|
|||||||
@@ -139,7 +139,6 @@ search_up_stream_data(const unsigned char * data, size_t len)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static enum tfe_stream_action
|
static enum tfe_stream_action
|
||||||
http2_stream_data(const struct tfe_stream * stream, unsigned int thread_id,
|
http2_stream_data(const struct tfe_stream * stream, unsigned int thread_id,
|
||||||
enum tfe_conn_dir dir, const unsigned char * data, size_t len, void ** pme)
|
enum tfe_conn_dir dir, const unsigned char * data, size_t len, void ** pme)
|
||||||
|
|||||||
@@ -1928,7 +1928,9 @@ static int http2_on_stream_close(nghttp2_session *session, const nghttp2_frame *
|
|||||||
|
|
||||||
h2_session = TAILQ_LIST_FIND(h2_stream_info, stream_id);
|
h2_session = TAILQ_LIST_FIND(h2_stream_info, stream_id);
|
||||||
if (!h2_session)
|
if (!h2_session)
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
if (error_code != 0){
|
if (error_code != 0){
|
||||||
const char *str = (dir == CONN_DIR_UPSTREAM) ? "Simulation s" : "Simulation c";
|
const char *str = (dir == CONN_DIR_UPSTREAM) ? "Simulation s" : "Simulation c";
|
||||||
TFE_LOG_DEBUG(logger()->handle, "%s close, id = %d, error_code = %d", str,
|
TFE_LOG_DEBUG(logger()->handle, "%s close, id = %d, error_code = %d", str,
|
||||||
|
|||||||
Reference in New Issue
Block a user