TSG-13031: 没有原始数据包时获取direction可能存在异常,调整获取direction的时机,即在第一个数据包时获取direction
This commit is contained in:
@@ -265,6 +265,41 @@ static int get_deploy_mode(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char get_direction(const struct streaminfo *a_stream)
|
||||||
|
{
|
||||||
|
int i_or_e=0;
|
||||||
|
char direction=0;
|
||||||
|
|
||||||
|
i_or_e=MESA_dir_link_to_human(a_stream->routedir);
|
||||||
|
switch(a_stream->curdir)
|
||||||
|
{
|
||||||
|
case DIR_C2S:
|
||||||
|
if(i_or_e=='E' || i_or_e=='e')
|
||||||
|
{
|
||||||
|
direction='E';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
direction='I';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case DIR_S2C:
|
||||||
|
if(i_or_e=='E' || i_or_e=='e')
|
||||||
|
{
|
||||||
|
direction='I';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
direction='E';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return direction;
|
||||||
|
}
|
||||||
|
|
||||||
static int print_hit_path(const struct streaminfo *a_stream, struct master_context *context)
|
static int print_hit_path(const struct streaminfo *a_stream, struct master_context *context)
|
||||||
{
|
{
|
||||||
if(g_tsg_para.hit_path_switch==0)
|
if(g_tsg_para.hit_path_switch==0)
|
||||||
@@ -1378,6 +1413,18 @@ int set_bucket_to_tcpall(const struct streaminfo *a_stream, struct leaky_bucket
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char get_direction_from_tcpall(const struct streaminfo *a_stream)
|
||||||
|
{
|
||||||
|
struct tcpall_context *context=(struct tcpall_context *)get_struct_project(a_stream, g_tsg_para.tcpall_project_id);
|
||||||
|
if(context!=NULL)
|
||||||
|
{
|
||||||
|
return context->direction;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void set_session_attribute_label(const struct streaminfo *a_stream, enum TSG_ATTRIBUTE_TYPE type, void *value, int value_len, int thread_seq)
|
void set_session_attribute_label(const struct streaminfo *a_stream, enum TSG_ATTRIBUTE_TYPE type, void *value, int value_len, int thread_seq)
|
||||||
{
|
{
|
||||||
unsigned long long create_time=0;
|
unsigned long long create_time=0;
|
||||||
@@ -2427,6 +2474,8 @@ extern "C" unsigned char TSG_MASTER_UDP_ENTRY(const struct streaminfo *a_udp, vo
|
|||||||
context->all_entry=(struct tcpall_context *)dictator_malloc(thread_seq, sizeof(struct tcpall_context));
|
context->all_entry=(struct tcpall_context *)dictator_malloc(thread_seq, sizeof(struct tcpall_context));
|
||||||
memset(context->all_entry, 0, sizeof(struct tcpall_context));
|
memset(context->all_entry, 0, sizeof(struct tcpall_context));
|
||||||
set_struct_project(a_udp, g_tsg_para.tcpall_project_id, (void *)(context->all_entry));
|
set_struct_project(a_udp, g_tsg_para.tcpall_project_id, (void *)(context->all_entry));
|
||||||
|
|
||||||
|
context->all_entry->direction=get_direction(a_udp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(context->all_entry->udp_data_dropme==0)
|
if(context->all_entry->udp_data_dropme==0)
|
||||||
@@ -2456,6 +2505,8 @@ extern "C" unsigned char TSG_MASTER_UDP_ENTRY(const struct streaminfo *a_udp, vo
|
|||||||
|
|
||||||
extern "C" unsigned char TSG_MASTER_TCPALL_ENTRY(const struct streaminfo *a_tcp, void **pme, int thread_seq, const void *a_packet)
|
extern "C" unsigned char TSG_MASTER_TCPALL_ENTRY(const struct streaminfo *a_tcp, void **pme, int thread_seq, const void *a_packet)
|
||||||
{
|
{
|
||||||
|
struct tcpall_context *_context=(struct tcpall_context *)(*pme);
|
||||||
|
|
||||||
if(*pme==NULL)
|
if(*pme==NULL)
|
||||||
{
|
{
|
||||||
*pme=(void *)get_struct_project(a_tcp, g_tsg_para.tcpall_project_id);
|
*pme=(void *)get_struct_project(a_tcp, g_tsg_para.tcpall_project_id);
|
||||||
@@ -2465,9 +2516,10 @@ extern "C" unsigned char TSG_MASTER_TCPALL_ENTRY(const struct streaminfo *a_tcp,
|
|||||||
memset(*pme, 0, sizeof(struct tcpall_context));
|
memset(*pme, 0, sizeof(struct tcpall_context));
|
||||||
set_struct_project(a_tcp, g_tsg_para.tcpall_project_id, (void *)(*pme));
|
set_struct_project(a_tcp, g_tsg_para.tcpall_project_id, (void *)(*pme));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
struct tcpall_context *_context=(struct tcpall_context *)(*pme);
|
_context=(struct tcpall_context *)(*pme);
|
||||||
|
_context->direction=get_direction(a_tcp);
|
||||||
|
}
|
||||||
|
|
||||||
if(_context->set_latency_flag==0)
|
if(_context->set_latency_flag==0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -287,7 +287,8 @@ struct tcpall_context
|
|||||||
{
|
{
|
||||||
char udp_data_dropme;
|
char udp_data_dropme;
|
||||||
char set_latency_flag;
|
char set_latency_flag;
|
||||||
char padding[6];
|
char direction;
|
||||||
|
char padding[5];
|
||||||
enum TSG_METHOD_TYPE method_type;
|
enum TSG_METHOD_TYPE method_type;
|
||||||
tsg_protocol_t protocol;
|
tsg_protocol_t protocol;
|
||||||
union
|
union
|
||||||
@@ -487,6 +488,9 @@ int set_method_to_tcpall(const struct streaminfo *a_stream, enum TSG_METHOD_TYPE
|
|||||||
int set_protocol_to_tcpall(const struct streaminfo *a_stream, tsg_protocol_t protocol, int thread_seq);
|
int set_protocol_to_tcpall(const struct streaminfo *a_stream, tsg_protocol_t protocol, int thread_seq);
|
||||||
int set_bucket_to_tcpall(const struct streaminfo *a_stream, struct leaky_bucket *bucket, int thread_seq);
|
int set_bucket_to_tcpall(const struct streaminfo *a_stream, struct leaky_bucket *bucket, int thread_seq);
|
||||||
int set_after_n_packet_to_tcpall(const struct streaminfo *a_stream, int after_n_packets, int thread_seq);
|
int set_after_n_packet_to_tcpall(const struct streaminfo *a_stream, int after_n_packets, int thread_seq);
|
||||||
|
|
||||||
|
char get_direction_from_tcpall(const struct streaminfo *a_stream);
|
||||||
|
|
||||||
void security_compile_free(int idx, const struct Maat_rule_t* rule, const char* srv_def_large, MAAT_RULE_EX_DATA* ad, long argl, void *argp);
|
void security_compile_free(int idx, const struct Maat_rule_t* rule, const char* srv_def_large, MAAT_RULE_EX_DATA* ad, long argl, void *argp);
|
||||||
|
|
||||||
struct Maat_rule_t *tsg_policy_decision_criteria(struct streaminfo *a_stream, Maat_rule_t *result, int result_num, int thread_seq);
|
struct Maat_rule_t *tsg_policy_decision_criteria(struct streaminfo *a_stream, Maat_rule_t *result, int result_num, int thread_seq);
|
||||||
|
|||||||
@@ -382,41 +382,16 @@ static int set_location(struct TLD_handle_t *_handle, struct streaminfo *a_strea
|
|||||||
|
|
||||||
static int set_direction(struct tsg_log_instance_t *_instance, struct TLD_handle_t *_handle, struct streaminfo *a_stream)
|
static int set_direction(struct tsg_log_instance_t *_instance, struct TLD_handle_t *_handle, struct streaminfo *a_stream)
|
||||||
{
|
{
|
||||||
int direction=0,i_or_e=0;
|
char direction=get_direction_from_tcpall(a_stream);
|
||||||
|
if(direction>0)
|
||||||
i_or_e=MESA_dir_link_to_human(a_stream->routedir);
|
|
||||||
switch(a_stream->curdir)
|
|
||||||
{
|
{
|
||||||
case DIR_C2S:
|
|
||||||
if(i_or_e=='E' || i_or_e=='e')
|
|
||||||
{
|
|
||||||
direction='E';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
direction='I';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case DIR_S2C:
|
|
||||||
if(i_or_e=='E' || i_or_e=='e')
|
|
||||||
{
|
|
||||||
direction='I';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
direction='E';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
TLD_append(_handle, _instance->id2field[LOG_COMMON_DIRECTION].name, (void *)(long)direction, TLD_TYPE_LONG);
|
TLD_append(_handle, _instance->id2field[LOG_COMMON_DIRECTION].name, (void *)(long)direction, TLD_TYPE_LONG);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int set_address_list(struct tsg_log_instance_t *_instance, struct TLD_handle_t *_handle, struct streaminfo *a_stream)
|
static int set_address_list(struct tsg_log_instance_t *_instance, struct TLD_handle_t *_handle, struct streaminfo *a_stream)
|
||||||
{
|
{
|
||||||
unsigned short tunnel_type=0;
|
unsigned short tunnel_type=0;
|
||||||
|
|||||||
Reference in New Issue
Block a user