TSG-23072 Change the Policies-Manipulation log field from proxy_rule_list to proxy_rule_uuid_list
TSG-23090 Change the action field in the Metric structure proxy_rule_hits to the string type
This commit is contained in:
@@ -110,7 +110,7 @@ int tfe_fieldstat_intercept_incrby(struct fieldstat_easy_intercept *metrics, voi
|
|||||||
nr_tags++;
|
nr_tags++;
|
||||||
}
|
}
|
||||||
// action : 2 Intercept; 3 No Intercept
|
// action : 2 Intercept; 3 No Intercept
|
||||||
FIELDSTAT_TAG_INIT(tags, nr_tags, "action", FIELD_VALUE_INTEGER, (hit_no_intercept == 1 ? 3 : 2));
|
FIELDSTAT_TAG_STR(tags, nr_tags, "action", FIELD_VALUE_CSTRING, (hit_no_intercept == 1 ? "no_intercept" : "intercept"));
|
||||||
nr_tags++;
|
nr_tags++;
|
||||||
|
|
||||||
if (hit_count > 0)
|
if (hit_count > 0)
|
||||||
@@ -216,7 +216,7 @@ struct fieldstat_easy_intercept *tfe_fieldstat_easy_intercept_create(char *app_n
|
|||||||
struct filedstat_easy_manipulation *tfe_fieldstat_easy_manipulation_create(char *app_name, char *outpath, int cycle, int max_thread, void *local_logger)
|
struct filedstat_easy_manipulation *tfe_fieldstat_easy_manipulation_create(char *app_name, char *outpath, int cycle, int max_thread, void *local_logger)
|
||||||
{
|
{
|
||||||
const char *counter_field[COLUMN_MAX] = {"hit_count", "in_bytes", "out_bytes", "in_pkts", "out_pkts"};
|
const char *counter_field[COLUMN_MAX] = {"hit_count", "in_bytes", "out_bytes", "in_pkts", "out_pkts"};
|
||||||
struct field metric_tags[TAG_MAX - 1] = {{"vsys_id", FIELD_VALUE_INTEGER, -1}, {"rule_uuid", FIELD_VALUE_CSTRING, -1}, {"action", FIELD_VALUE_INTEGER, -1}, {"sub_action", FIELD_VALUE_CSTRING, -1}};
|
struct field metric_tags[TAG_MAX - 1] = {{"vsys_id", FIELD_VALUE_INTEGER, -1}, {"rule_uuid", FIELD_VALUE_CSTRING, -1}, {"action", FIELD_VALUE_CSTRING, -1}, {"sub_action", FIELD_VALUE_CSTRING, -1}};
|
||||||
|
|
||||||
struct filedstat_easy_manipulation *fieldstat = ALLOC(struct filedstat_easy_manipulation, 1);
|
struct filedstat_easy_manipulation *fieldstat = ALLOC(struct filedstat_easy_manipulation, 1);
|
||||||
|
|
||||||
|
|||||||
@@ -813,7 +813,7 @@ void doh_send_metric_log(const struct tfe_stream * stream, struct doh_ctx *ctx,
|
|||||||
|
|
||||||
fieldstat->tags[thread_id][TAG_VSYS_ID].value_longlong = ctx->result->vsys_id;
|
fieldstat->tags[thread_id][TAG_VSYS_ID].value_longlong = ctx->result->vsys_id;
|
||||||
fieldstat->tags[thread_id][TAG_RULE_ID].value_str = ctx->result->config_uuid_string;
|
fieldstat->tags[thread_id][TAG_RULE_ID].value_str = ctx->result->config_uuid_string;
|
||||||
fieldstat->tags[thread_id][TAG_ACTION].value_longlong = 48;
|
fieldstat->tags[thread_id][TAG_ACTION].value_str = "manipulate";
|
||||||
fieldstat->tags[thread_id][TAG_SUB_ACTION].value_str = "redirect";
|
fieldstat->tags[thread_id][TAG_SUB_ACTION].value_str = "redirect";
|
||||||
|
|
||||||
tfe_stream_info_get(stream, INFO_FROM_DOWNSTREAM_RX_OFFSET, &c2s_byte_num, sizeof(c2s_byte_num));
|
tfe_stream_info_get(stream, INFO_FROM_DOWNSTREAM_RX_OFFSET, &c2s_byte_num, sizeof(c2s_byte_num));
|
||||||
|
|||||||
@@ -476,7 +476,7 @@ int doh_send_log(struct doh_conf *handle, const struct tfe_http_session *http, c
|
|||||||
per_hit_obj = cJSON_Duplicate(common_obj, 1);
|
per_hit_obj = cJSON_Duplicate(common_obj, 1);
|
||||||
config_id[0]=result[i].config_uuid_string;
|
config_id[0]=result[i].config_uuid_string;
|
||||||
proxy_rule_list = cJSON_CreateStringArray((const char **)config_id, 1);
|
proxy_rule_list = cJSON_CreateStringArray((const char **)config_id, 1);
|
||||||
cJSON_AddItemToObject(per_hit_obj, "proxy_rule_list", proxy_rule_list);
|
cJSON_AddItemToObject(per_hit_obj, "proxy_rule_uuid_list", proxy_rule_list);
|
||||||
cJSON_AddStringToObject(per_hit_obj, "proxy_action", "redirect");
|
cJSON_AddStringToObject(per_hit_obj, "proxy_action", "redirect");
|
||||||
|
|
||||||
log_payload = cJSON_PrintUnformatted(per_hit_obj);
|
log_payload = cJSON_PrintUnformatted(per_hit_obj);
|
||||||
|
|||||||
@@ -461,57 +461,9 @@ unsigned char log_option_type_str2idx(const char *log_option)
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
void policy_action_param_new(const char *table_name, const char* key, const char* table_line, void **ad, long argl, void* argp)
|
void policy_set_param_by_action(struct policy_action_param* param, cJSON *action_parameter)
|
||||||
{
|
{
|
||||||
cJSON* pxy_ctrl_rule = cJSON_Parse(table_line);
|
cJSON *item=NULL;
|
||||||
if(pxy_ctrl_rule == NULL)
|
|
||||||
{
|
|
||||||
TFE_LOG_ERROR(g_proxy_rt->local_logger, "PXY_CTRL_RULE parse table_line failed. table_line:%s", table_line);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct policy_action_param* param=ALLOC(struct policy_action_param, 1);
|
|
||||||
|
|
||||||
cJSON *uuid = cJSON_GetObjectItem(pxy_ctrl_rule, "uuid");
|
|
||||||
if(uuid && uuid->type==cJSON_String)
|
|
||||||
{
|
|
||||||
param->hit_rule.config_uuid_string = strdup(uuid->valuestring);
|
|
||||||
uuid_parse(uuid->valuestring, param->hit_rule.config_uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
cJSON *action = cJSON_GetObjectItem(pxy_ctrl_rule, "action");
|
|
||||||
if(action && action->type==cJSON_String)
|
|
||||||
{
|
|
||||||
param->hit_rule.action=action_type_str2idx(action->valuestring);
|
|
||||||
}
|
|
||||||
|
|
||||||
cJSON *blacklist_option = cJSON_GetObjectItem(pxy_ctrl_rule, "blacklist_option");
|
|
||||||
if(blacklist_option && blacklist_option->type==cJSON_Number)
|
|
||||||
{
|
|
||||||
param->hit_rule.do_blacklist=blacklist_option->valueint;
|
|
||||||
}
|
|
||||||
|
|
||||||
cJSON *log_option = cJSON_GetObjectItem(pxy_ctrl_rule, "log_option");
|
|
||||||
if(log_option && log_option->type==cJSON_String)
|
|
||||||
{
|
|
||||||
param->hit_rule.do_log=log_option_type_str2idx(log_option->valuestring);
|
|
||||||
}
|
|
||||||
|
|
||||||
cJSON *action_parameter = cJSON_GetObjectItem(pxy_ctrl_rule, "action_parameter");
|
|
||||||
if(action_parameter == NULL || action_parameter->type!=cJSON_Object)
|
|
||||||
{
|
|
||||||
FREE(¶m);
|
|
||||||
TFE_LOG_ERROR(g_proxy_rt->local_logger, "invalid policy parameter: id = %s", param->hit_rule.config_uuid_string);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
param->ref_cnt=1;
|
|
||||||
pthread_mutex_init(&(param->lock), NULL);
|
|
||||||
param->hit_rule.action_parameter = cJSON_PrintUnformatted(action_parameter);
|
|
||||||
|
|
||||||
int rule_id=0;
|
|
||||||
cJSON *rules=NULL, *item=NULL, *sub_item=NULL;
|
|
||||||
|
|
||||||
switch(param->hit_rule.action)
|
switch(param->hit_rule.action)
|
||||||
{
|
{
|
||||||
case PX_ACTION_REDIRECT:
|
case PX_ACTION_REDIRECT:
|
||||||
@@ -586,13 +538,13 @@ void policy_action_param_new(const char *table_name, const char* key, const char
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
cJSON *method=cJSON_GetObjectItem(action_parameter, "sub_action");
|
void policy_set_param_by_sub_action(struct policy_action_param* param, cJSON *action_parameter)
|
||||||
if(method && method->type==cJSON_String)
|
{
|
||||||
{
|
int rule_id=0;
|
||||||
param->action=manipulate_action_str2idx(method->valuestring);
|
cJSON *rules=NULL, *item=NULL, *sub_item=NULL;
|
||||||
}
|
|
||||||
|
|
||||||
switch(param->action)
|
switch(param->action)
|
||||||
{
|
{
|
||||||
case MA_ACTION_REPLACE_TEXT:
|
case MA_ACTION_REPLACE_TEXT:
|
||||||
@@ -748,6 +700,66 @@ void policy_action_param_new(const char *table_name, const char* key, const char
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void policy_action_param_new(const char *table_name, const char* key, const char* table_line, void **ad, long argl, void* argp)
|
||||||
|
{
|
||||||
|
cJSON* pxy_ctrl_rule = cJSON_Parse(table_line);
|
||||||
|
if(pxy_ctrl_rule == NULL)
|
||||||
|
{
|
||||||
|
TFE_LOG_ERROR(g_proxy_rt->local_logger, "PXY_CTRL_RULE parse table_line failed. table_line:%s", table_line);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct policy_action_param* param=ALLOC(struct policy_action_param, 1);
|
||||||
|
|
||||||
|
cJSON *uuid = cJSON_GetObjectItem(pxy_ctrl_rule, "uuid");
|
||||||
|
if(uuid && uuid->type==cJSON_String)
|
||||||
|
{
|
||||||
|
param->hit_rule.config_uuid_string = strdup(uuid->valuestring);
|
||||||
|
uuid_parse(uuid->valuestring, param->hit_rule.config_uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
cJSON *action = cJSON_GetObjectItem(pxy_ctrl_rule, "action");
|
||||||
|
if(action && action->type==cJSON_String)
|
||||||
|
{
|
||||||
|
param->hit_rule.action=action_type_str2idx(action->valuestring);
|
||||||
|
}
|
||||||
|
|
||||||
|
cJSON *blacklist_option = cJSON_GetObjectItem(pxy_ctrl_rule, "blacklist_option");
|
||||||
|
if(blacklist_option && blacklist_option->type==cJSON_Number)
|
||||||
|
{
|
||||||
|
param->hit_rule.do_blacklist=blacklist_option->valueint;
|
||||||
|
}
|
||||||
|
|
||||||
|
cJSON *log_option = cJSON_GetObjectItem(pxy_ctrl_rule, "log_option");
|
||||||
|
if(log_option && log_option->type==cJSON_String)
|
||||||
|
{
|
||||||
|
param->hit_rule.do_log=log_option_type_str2idx(log_option->valuestring);
|
||||||
|
}
|
||||||
|
|
||||||
|
cJSON *action_parameter = cJSON_GetObjectItem(pxy_ctrl_rule, "action_parameter");
|
||||||
|
if(action_parameter == NULL || action_parameter->type!=cJSON_Object)
|
||||||
|
{
|
||||||
|
FREE(¶m);
|
||||||
|
TFE_LOG_ERROR(g_proxy_rt->local_logger, "invalid policy parameter: id = %s", param->hit_rule.config_uuid_string);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
param->ref_cnt=1;
|
||||||
|
pthread_mutex_init(&(param->lock), NULL);
|
||||||
|
param->hit_rule.action_parameter = cJSON_PrintUnformatted(action_parameter);
|
||||||
|
policy_set_param_by_action(param, action_parameter);
|
||||||
|
|
||||||
|
cJSON *method=cJSON_GetObjectItem(action_parameter, "sub_action");
|
||||||
|
if(method && method->type==cJSON_String)
|
||||||
|
{
|
||||||
|
param->action=manipulate_action_str2idx(method->valuestring);
|
||||||
|
}
|
||||||
|
policy_set_param_by_sub_action(param, action_parameter);
|
||||||
|
|
||||||
*ad=param;
|
*ad=param;
|
||||||
TFE_LOG_INFO(g_proxy_rt->local_logger, "Add ctrl policy: %s", param->hit_rule.config_uuid_string);
|
TFE_LOG_INFO(g_proxy_rt->local_logger, "Add ctrl policy: %s", param->hit_rule.config_uuid_string);
|
||||||
cJSON_Delete(pxy_ctrl_rule);
|
cJSON_Delete(pxy_ctrl_rule);
|
||||||
@@ -1519,7 +1531,7 @@ void proxy_send_metric_log(const struct tfe_stream * stream, struct proxy_http_c
|
|||||||
{
|
{
|
||||||
fieldstat->tags[thread_id][TAG_VSYS_ID].value_longlong = ctx->enforce_rules[i].vsys_id;
|
fieldstat->tags[thread_id][TAG_VSYS_ID].value_longlong = ctx->enforce_rules[i].vsys_id;
|
||||||
fieldstat->tags[thread_id][TAG_RULE_ID].value_str = ctx->enforce_rules[i].config_uuid_string;
|
fieldstat->tags[thread_id][TAG_RULE_ID].value_str = ctx->enforce_rules[i].config_uuid_string;
|
||||||
fieldstat->tags[thread_id][TAG_ACTION].value_longlong = PX_ACTION_MANIPULATE;
|
fieldstat->tags[thread_id][TAG_ACTION].value_str = "manipulate";
|
||||||
if(ctx->enforce_rules[i].action == PX_ACTION_MANIPULATE)
|
if(ctx->enforce_rules[i].action == PX_ACTION_MANIPULATE)
|
||||||
{
|
{
|
||||||
fieldstat->tags[thread_id][TAG_SUB_ACTION].value_str = manipulate_action_map[ctx->param->action];
|
fieldstat->tags[thread_id][TAG_SUB_ACTION].value_str = manipulate_action_map[ctx->param->action];
|
||||||
|
|||||||
@@ -391,7 +391,7 @@ int proxy_send_log(struct proxy_logger* handle, const struct proxy_log* log_msg)
|
|||||||
config_id[0]=log_msg->result[i].config_uuid_string;
|
config_id[0]=log_msg->result[i].config_uuid_string;
|
||||||
proxy_rule_list = cJSON_CreateStringArray((const char **)config_id, 1);
|
proxy_rule_list = cJSON_CreateStringArray((const char **)config_id, 1);
|
||||||
}
|
}
|
||||||
cJSON_AddItemToObject(per_hit_obj, "proxy_rule_list", proxy_rule_list);
|
cJSON_AddItemToObject(per_hit_obj, "proxy_rule_uuid_list", proxy_rule_list);
|
||||||
cJSON_AddNumberToObject(per_hit_obj, "vsys_id", log_msg->result[i].vsys_id);
|
cJSON_AddNumberToObject(per_hit_obj, "vsys_id", log_msg->result[i].vsys_id);
|
||||||
if(log_msg->result[i].action == LG_ACTION_MANIPULATE)
|
if(log_msg->result[i].action == LG_ACTION_MANIPULATE)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user