[FEATURE]support maat_scan_not_logic & maat_scan_group

This commit is contained in:
刘文坛
2023-11-10 08:26:48 +00:00
parent 98d4fb34ed
commit 91937cdbfb
35 changed files with 2724 additions and 947 deletions

9
deps/log/log.h vendored
View File

@@ -22,7 +22,14 @@ extern "C"
struct log_handle; struct log_handle;
enum { LOG_TRACE, LOG_DEBUG, LOG_INFO, LOG_WARN, LOG_ERROR, LOG_FATAL }; enum {
LOG_TRACE,
LOG_DEBUG,
LOG_INFO,
LOG_WARN,
LOG_ERROR,
LOG_FATAL
};
#define log_debug(handle, module, fmt, ...) log_print(handle, LOG_DEBUG, module, fmt, ##__VA_ARGS__) #define log_debug(handle, module, fmt, ...) log_print(handle, LOG_DEBUG, module, fmt, ##__VA_ARGS__)
#define log_trace(handle, module, fmt, ...) log_print(handle, LOG_TRACE, module, fmt, ##__VA_ARGS__) #define log_trace(handle, module, fmt, ...) log_print(handle, LOG_TRACE, module, fmt, ##__VA_ARGS__)

View File

@@ -4,7 +4,7 @@
多命中情况下按包含分组数由多到少返回分组数相同时按编译配置ID由大到小的顺序返回。 多命中情况下按包含分组数由多到少返回分组数相同时按编译配置ID由大到小的顺序返回。
多命中扫描的最大命中次数受MAX_SCANNER_HIT_NUM宏控制当前为4096条。 多命中扫描的最大命中次数受MAX_HIT_NUM宏控制当前为4096条。
如果命中条数超出4096则按照配置在IRIS库表文件出现的顺序返回。 如果命中条数超出4096则按照配置在IRIS库表文件出现的顺序返回。
@@ -18,7 +18,7 @@
## 结果缓存复用 ## 结果缓存复用
另外为了提高系统的性能为每个scanner分配了一个region_rslt_buff用以缓存域扫描命中的中间结果。通过malloc分配长度为sizeof(scan_result_t)*MAX_SCANNER_HIT_NUM*scan_thread_num当外部调用扫描时根据thread_num参数分配region_rslt_buff+MAX_SCANNER_HIT_NUM*thread_num供当前线程保存域中间扫描结果。 另外为了提高系统的性能为每个scanner分配了一个region_rslt_buff用以缓存域扫描命中的中间结果。通过malloc分配长度为sizeof(scan_result_t)*MAX_HIT_NUM*scan_thread_num当外部调用扫描时根据thread_num参数分配region_rslt_buff+MAX_HIT_NUM*thread_num供当前线程保存域中间扫描结果。
### 命中结果返回条件 ### 命中结果返回条件

View File

@@ -265,9 +265,18 @@ int maat_scan_ipv6(struct maat *instance, int table_id,
size_t *n_hit_result, struct maat_state *state); size_t *n_hit_result, struct maat_state *state);
int maat_scan_string(struct maat *instance, int table_id, int maat_scan_string(struct maat *instance, int table_id,
const char *data, size_t data_len, long long *results, const char *data, size_t data_len,
size_t n_result, size_t *n_hit_result, long long *results, size_t n_result,
struct maat_state *state); size_t *n_hit_result, struct maat_state *state);
int maat_scan_group(struct maat *instance, int table_id,
long long *group_ids, size_t n_group_id,
long long *results, size_t n_result,
size_t *n_hit_result, struct maat_state *state);
int maat_scan_not_logic(struct maat *instance, int table_id,
long long *results, size_t n_result,
size_t *n_hit_result, struct maat_state *state);
struct maat_stream; struct maat_stream;
struct maat_stream *maat_stream_new(struct maat *instance, int table_id, struct maat_stream *maat_stream_new(struct maat *instance, int table_id,
@@ -286,10 +295,6 @@ void maat_state_reset(struct maat_state *state);
void maat_state_free(struct maat_state *state); void maat_state_free(struct maat_state *state);
void maat_state_set_logic_not_disabled(struct maat_state *state);
void maat_state_set_logic_not_enabled(struct maat_state *state);
int maat_state_set_scan_district(struct maat_state *state, int table_id, int maat_state_set_scan_district(struct maat_state *state, int table_id,
const char *district, size_t district_len); const char *district, size_t district_len);

View File

@@ -107,7 +107,7 @@ static int _hs_alloc_scratch(hs_database_t *db, hs_scratch_t **scratches,
size_t scratch_size = 0; size_t scratch_size = 0;
if (hs_alloc_scratch(db, &scratches[0]) != HS_SUCCESS) { if (hs_alloc_scratch(db, &scratches[0]) != HS_SUCCESS) {
log_error(logger, MODULE_ADAPTER_HS, log_fatal(logger, MODULE_ADAPTER_HS,
"[%s:%d] Unable to allocate scratch space. Exiting.", "[%s:%d] Unable to allocate scratch space. Exiting.",
__FUNCTION__, __LINE__); __FUNCTION__, __LINE__);
return -1; return -1;
@@ -116,7 +116,7 @@ static int _hs_alloc_scratch(hs_database_t *db, hs_scratch_t **scratches,
for (size_t i = 1; i < n_worker_thread; i++) { for (size_t i = 1; i < n_worker_thread; i++) {
hs_error_t err = hs_clone_scratch(scratches[0], &scratches[i]); hs_error_t err = hs_clone_scratch(scratches[0], &scratches[i]);
if (err != HS_SUCCESS) { if (err != HS_SUCCESS) {
log_error(logger, MODULE_ADAPTER_HS, log_fatal(logger, MODULE_ADAPTER_HS,
"[%s:%d] Unable to clone scratch", "[%s:%d] Unable to clone scratch",
__FUNCTION__, __LINE__); __FUNCTION__, __LINE__);
return -1; return -1;
@@ -124,7 +124,7 @@ static int _hs_alloc_scratch(hs_database_t *db, hs_scratch_t **scratches,
err = hs_scratch_size(scratches[i], &scratch_size); err = hs_scratch_size(scratches[i], &scratch_size);
if (err != HS_SUCCESS) { if (err != HS_SUCCESS) {
log_error(logger, MODULE_ADAPTER_HS, log_fatal(logger, MODULE_ADAPTER_HS,
"[%s:%d] Unable to query scratch size", "[%s:%d] Unable to query scratch size",
__FUNCTION__, __LINE__); __FUNCTION__, __LINE__);
return -1; return -1;
@@ -187,7 +187,7 @@ static int adpt_hs_build_database(struct adapter_hs_runtime *hs_rt,
&hs_rt->literal_db, &compile_err); &hs_rt->literal_db, &compile_err);
if (err != HS_SUCCESS) { if (err != HS_SUCCESS) {
if (compile_err) { if (compile_err) {
log_error(logger, MODULE_ADAPTER_HS, "[%s:%d] compile error: %s", log_fatal(logger, MODULE_ADAPTER_HS, "[%s:%d] compile error: %s",
__FUNCTION__, __LINE__, compile_err->message); __FUNCTION__, __LINE__, compile_err->message);
} }
@@ -203,7 +203,7 @@ static int adpt_hs_build_database(struct adapter_hs_runtime *hs_rt,
NULL, &hs_rt->regex_db, &compile_err); NULL, &hs_rt->regex_db, &compile_err);
if (err != HS_SUCCESS) { if (err != HS_SUCCESS) {
if (compile_err) { if (compile_err) {
log_error(logger, MODULE_ADAPTER_HS, "[%s:%d] compile error: %s", log_fatal(logger, MODULE_ADAPTER_HS, "[%s:%d] compile error: %s",
__FUNCTION__, __LINE__, compile_err->message); __FUNCTION__, __LINE__, compile_err->message);
} }
hs_free_compile_error(compile_err); hs_free_compile_error(compile_err);
@@ -342,7 +342,7 @@ static int verify_regex_expression(const char *regex_str, struct log_handle *log
if (err != HS_SUCCESS) { if (err != HS_SUCCESS) {
// Expression will fail compilation and report error elsewhere. // Expression will fail compilation and report error elsewhere.
if (logger != NULL) { if (logger != NULL) {
log_error(logger, MODULE_ADAPTER_HS, log_fatal(logger, MODULE_ADAPTER_HS,
"[%s:%d] illegal regex expression: \"%s\": %s", "[%s:%d] illegal regex expression: \"%s\": %s",
__FUNCTION__, __LINE__, regex_str, error->message); __FUNCTION__, __LINE__, regex_str, error->message);
} }
@@ -412,7 +412,7 @@ void *adapter_hs_new(struct expr_rule *rules, size_t n_rule,
"Adapter_hs module: build bool matcher of %zu expressions" "Adapter_hs module: build bool matcher of %zu expressions"
" with %zu bytes memory", n_rule, mem_size); " with %zu bytes memory", n_rule, mem_size);
} else { } else {
log_error(logger, MODULE_ADAPTER_HS, log_fatal(logger, MODULE_ADAPTER_HS,
"[%s:%d] Adapter_hs module: build bool matcher failed", "[%s:%d] Adapter_hs module: build bool matcher failed",
__FUNCTION__, __LINE__); __FUNCTION__, __LINE__);
@@ -667,7 +667,7 @@ void *adapter_hs_stream_open(void *hs_instance, int thread_id)
err = hs_open_stream(hs_inst->hs_rt->literal_db, 0, err = hs_open_stream(hs_inst->hs_rt->literal_db, 0,
&hs_stream->literal_stream); &hs_stream->literal_stream);
if (err != HS_SUCCESS) { if (err != HS_SUCCESS) {
log_error(hs_inst->logger, MODULE_ADAPTER_HS, log_fatal(hs_inst->logger, MODULE_ADAPTER_HS,
"hs_open_stream failed, hs err:%d", err); "hs_open_stream failed, hs err:%d", err);
err_count++; err_count++;
} }
@@ -677,7 +677,7 @@ void *adapter_hs_stream_open(void *hs_instance, int thread_id)
err = hs_open_stream(hs_inst->hs_rt->regex_db, 0, err = hs_open_stream(hs_inst->hs_rt->regex_db, 0,
&hs_stream->regex_stream); &hs_stream->regex_stream);
if (err != HS_SUCCESS) { if (err != HS_SUCCESS) {
log_error(hs_inst->logger, MODULE_ADAPTER_HS, log_fatal(hs_inst->logger, MODULE_ADAPTER_HS,
"hs_open_stream failed, hs err:%d", err); "hs_open_stream failed, hs err:%d", err);
err_count++; err_count++;
} }
@@ -843,7 +843,7 @@ int adapter_hs_scan_stream(void *hs_stream, const char *data, size_t data_len,
err_count++; err_count++;
} }
} else { } else {
log_error(stream->logger, MODULE_ADAPTER_HS, log_fatal(stream->logger, MODULE_ADAPTER_HS,
"literal_scratches is null, thread_id:%d", thread_id); "literal_scratches is null, thread_id:%d", thread_id);
err_scratch_flag++; err_scratch_flag++;
} }
@@ -858,7 +858,7 @@ int adapter_hs_scan_stream(void *hs_stream, const char *data, size_t data_len,
err_count++; err_count++;
} }
} else { } else {
log_error(stream->logger, MODULE_ADAPTER_HS, log_fatal(stream->logger, MODULE_ADAPTER_HS,
"regex_scratches is null, thread_id:%d", thread_id); "regex_scratches is null, thread_id:%d", thread_id);
err_scratch_flag++; err_scratch_flag++;
} }

View File

@@ -98,7 +98,7 @@ int adapter_rs_verify_regex_expression(const char *regex_expr,
{ {
int ret = rs_verify_regex(regex_expr); int ret = rs_verify_regex(regex_expr);
if (ret == 0) { if (ret == 0) {
log_error(logger, MODULE_ADAPTER_RS, log_fatal(logger, MODULE_ADAPTER_RS,
"[%s:%d] illegal regex expression: \"%s\"", "[%s:%d] illegal regex expression: \"%s\"",
__FUNCTION__, __LINE__, regex_expr); __FUNCTION__, __LINE__, regex_expr);
} }
@@ -125,7 +125,7 @@ static int adpt_rs_build_database(struct adapter_rs_runtime *rs_rt,
ret = rs_compile_lit(literal_cd->patterns, literal_cd->n_patterns, ret = rs_compile_lit(literal_cd->patterns, literal_cd->n_patterns,
&rs_rt->literal_db); &rs_rt->literal_db);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_ADAPTER_RS, "[%s:%d] compile error", log_fatal(logger, MODULE_ADAPTER_RS, "[%s:%d] compile error",
__FUNCTION__, __LINE__); __FUNCTION__, __LINE__);
return -1; return -1;
} }
@@ -136,7 +136,7 @@ static int adpt_rs_build_database(struct adapter_rs_runtime *rs_rt,
ret = rs_compile_regex(regex_cd->patterns, regex_cd->n_patterns, ret = rs_compile_regex(regex_cd->patterns, regex_cd->n_patterns,
n_worker_thread, &rs_rt->regex_db, &n_failed_pats); n_worker_thread, &rs_rt->regex_db, &n_failed_pats);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_ADAPTER_RS, "[%s:%d] compile error", log_fatal(logger, MODULE_ADAPTER_RS, "[%s:%d] compile error",
__FUNCTION__, __LINE__); __FUNCTION__, __LINE__);
return -1; return -1;
} }
@@ -283,7 +283,7 @@ void *adapter_rs_new(struct expr_rule *rules, size_t n_rule,
"Adapter_rs module: build bool matcher of %zu expressions" "Adapter_rs module: build bool matcher of %zu expressions"
" with %zu bytes memory", n_rule, mem_size); " with %zu bytes memory", n_rule, mem_size);
} else { } else {
log_error(logger, MODULE_ADAPTER_RS, log_fatal(logger, MODULE_ADAPTER_RS,
"[%s:%d] Adapter_rs module: build bool matcher failed", "[%s:%d] Adapter_rs module: build bool matcher failed",
__FUNCTION__, __LINE__); __FUNCTION__, __LINE__);
@@ -507,7 +507,7 @@ void *adapter_rs_stream_open(void *rs_instance, int thread_id)
if (rs_inst->rs_rt->literal_db != NULL) { if (rs_inst->rs_rt->literal_db != NULL) {
rs_stream->literal_stream = rs_open_stream(rs_inst->rs_rt->literal_db, 0, 128); rs_stream->literal_stream = rs_open_stream(rs_inst->rs_rt->literal_db, 0, 128);
if (NULL == rs_stream->literal_stream) { if (NULL == rs_stream->literal_stream) {
log_error(rs_inst->logger, MODULE_ADAPTER_RS, "rs_open_stream failed"); log_fatal(rs_inst->logger, MODULE_ADAPTER_RS, "rs_open_stream failed");
err_count++; err_count++;
} }
} }
@@ -515,7 +515,7 @@ void *adapter_rs_stream_open(void *rs_instance, int thread_id)
if (rs_inst->rs_rt->regex_db != NULL) { if (rs_inst->rs_rt->regex_db != NULL) {
rs_stream->regex_stream = rs_open_stream(rs_inst->rs_rt->regex_db, 0, 128); rs_stream->regex_stream = rs_open_stream(rs_inst->rs_rt->regex_db, 0, 128);
if (NULL == rs_stream->regex_stream) { if (NULL == rs_stream->regex_stream) {
log_error(rs_inst->logger, MODULE_ADAPTER_RS, "rs_open_stream failed"); log_fatal(rs_inst->logger, MODULE_ADAPTER_RS, "rs_open_stream failed");
err_count++; err_count++;
} }
} }

View File

@@ -98,7 +98,7 @@ expr_matcher_new(struct expr_rule *rules, size_t n_rule, enum expr_engine_type e
{ {
if (NULL == rules || 0 == n_rule || 0 == n_worker_thread || if (NULL == rules || 0 == n_rule || 0 == n_worker_thread ||
(engine_type != EXPR_ENGINE_TYPE_HS && engine_type != EXPR_ENGINE_TYPE_RS)) { (engine_type != EXPR_ENGINE_TYPE_HS && engine_type != EXPR_ENGINE_TYPE_RS)) {
log_error(logger, MODULE_EXPR_MATCHER, "[%s:%d]engine type:%d is illegal", log_fatal(logger, MODULE_EXPR_MATCHER, "[%s:%d]engine type:%d is illegal",
__FUNCTION__, __LINE__, engine_type); __FUNCTION__, __LINE__, engine_type);
return NULL; return NULL;
} }
@@ -109,7 +109,7 @@ expr_matcher_new(struct expr_rule *rules, size_t n_rule, enum expr_engine_type e
for (i = 0; i < n_rule; i++) { for (i = 0; i < n_rule; i++) {
if (rules[i].n_patterns > MAX_EXPR_PATTERN_NUM) { if (rules[i].n_patterns > MAX_EXPR_PATTERN_NUM) {
log_error(logger, MODULE_EXPR_MATCHER, log_fatal(logger, MODULE_EXPR_MATCHER,
"[%s:%d] the number of patterns in one expression should less than" "[%s:%d] the number of patterns in one expression should less than"
" %d", __FUNCTION__, __LINE__, MAX_EXPR_PATTERN_NUM); " %d", __FUNCTION__, __LINE__, MAX_EXPR_PATTERN_NUM);
return NULL; return NULL;
@@ -118,7 +118,7 @@ expr_matcher_new(struct expr_rule *rules, size_t n_rule, enum expr_engine_type e
for (j = 0; j < rules[i].n_patterns; j++) { for (j = 0; j < rules[i].n_patterns; j++) {
/* pat_len should not 0 */ /* pat_len should not 0 */
if (0 == rules[i].patterns[j].pat_len) { if (0 == rules[i].patterns[j].pat_len) {
log_error(logger, MODULE_EXPR_MATCHER, log_fatal(logger, MODULE_EXPR_MATCHER,
"[%s:%d] expr pattern length should not 0", "[%s:%d] expr pattern length should not 0",
__FUNCTION__, __LINE__); __FUNCTION__, __LINE__);
return NULL; return NULL;
@@ -133,7 +133,7 @@ expr_matcher_new(struct expr_rule *rules, size_t n_rule, enum expr_engine_type e
} }
if (0 == literal_pat_num && 0 == regex_pat_num) { if (0 == literal_pat_num && 0 == regex_pat_num) {
log_error(logger, MODULE_EXPR_MATCHER, log_fatal(logger, MODULE_EXPR_MATCHER,
"[%s:%d] exprs has no valid pattern", __FUNCTION__, __LINE__); "[%s:%d] exprs has no valid pattern", __FUNCTION__, __LINE__);
return NULL; return NULL;
} }
@@ -142,7 +142,7 @@ expr_matcher_new(struct expr_rule *rules, size_t n_rule, enum expr_engine_type e
regex_pat_num, n_worker_thread, regex_pat_num, n_worker_thread,
logger); logger);
if (NULL == engine) { if (NULL == engine) {
log_error(logger, MODULE_EXPR_MATCHER, log_fatal(logger, MODULE_EXPR_MATCHER,
"[%s:%d]expr_matcher engine_new failed.", __FUNCTION__, __LINE__); "[%s:%d]expr_matcher engine_new failed.", __FUNCTION__, __LINE__);
return NULL; return NULL;
} }
@@ -193,7 +193,7 @@ expr_matcher_stream_open(struct expr_matcher *matcher, int thread_id)
void *s_handle = expr_engine_ops[matcher->engine_type].engine_stream_open(matcher->engine, void *s_handle = expr_engine_ops[matcher->engine_type].engine_stream_open(matcher->engine,
thread_id); thread_id);
if (NULL == s_handle) { if (NULL == s_handle) {
log_error(matcher->logger, MODULE_EXPR_MATCHER, log_fatal(matcher->logger, MODULE_EXPR_MATCHER,
"[%s:%d] expr_matcher engine_stream_open failed.", "[%s:%d] expr_matcher engine_stream_open failed.",
__FUNCTION__, __LINE__); __FUNCTION__, __LINE__);
return NULL; return NULL;

View File

@@ -92,8 +92,14 @@ void compile_state_reset(struct compile_state *compile_state);
void compile_state_free(struct compile_state *compile_state, void compile_state_free(struct compile_state *compile_state,
struct maat *maat_instance, int thread_id); struct maat *maat_instance, int thread_id);
int compile_state_update(int vtable_id, struct maat_item *hit_items, int compile_state_update(struct compile_state *compile_state, struct maat *maat_inst,
size_t n_hit_item, struct maat_state *state); int vtable_id, int custom_compile_tbl_id, int Nth_scan,
struct maat_item *hit_items, size_t n_hit_item);
void compile_state_not_logic_update(struct compile_state *compile_state,
struct compile_runtime *compile_rt,
struct maat *maat_inst, int vtable_id,
int Nth_scan);
size_t compile_state_get_internal_hit_paths(struct compile_state *compile_state, size_t compile_state_get_internal_hit_paths(struct compile_state *compile_state,
struct compile_runtime *compile_rt, struct compile_runtime *compile_rt,

View File

@@ -53,9 +53,9 @@ extern "C"
#endif #endif
#define MAX_HIT_PATH_NUM 4096 #define MAX_HIT_PATH_NUM 4096
#define MAX_SCANNER_HIT_COMPILE_NUM 4096 #define MAX_HIT_COMPILE_NUM 4096
#define MAX_SCANNER_HIT_GROUP_NUM 4096 #define MAX_HIT_GROUP_NUM 4096
#define MAX_SCANNER_HIT_ITEM_NUM 4096 #define MAX_HIT_ITEM_NUM 4096
#define IPV4 4 #define IPV4 4
#define IPV6 6 #define IPV6 6

View File

@@ -30,6 +30,7 @@
const int json_version = 1; const int json_version = 1;
const char *untitled_group_name="Untitled"; const char *untitled_group_name="Untitled";
long long untitled_group_id = 123456789;
enum maat_group_relation { enum maat_group_relation {
PARENT_TYPE_COMPILE = 0, PARENT_TYPE_COMPILE = 0,
@@ -242,7 +243,7 @@ static int write_plugin_line(cJSON *plug_table_json, int sequence,
{ {
cJSON *item = cJSON_GetObjectItem(plug_table_json, "table_name"); cJSON *item = cJSON_GetObjectItem(plug_table_json, "table_name");
if (NULL == item || item->type != cJSON_String) { if (NULL == item || item->type != cJSON_String) {
log_error(logger, MODULE_JSON2IRIS, log_fatal(logger, MODULE_JSON2IRIS,
"[%s:%d] The %d plugin_table's table_name " "[%s:%d] The %d plugin_table's table_name "
"not defined or format error", __FUNCTION__, "not defined or format error", __FUNCTION__,
__LINE__, sequence); __LINE__, sequence);
@@ -252,7 +253,7 @@ static int write_plugin_line(cJSON *plug_table_json, int sequence,
cJSON *table_content = cJSON_GetObjectItem(plug_table_json, "table_content"); cJSON *table_content = cJSON_GetObjectItem(plug_table_json, "table_content");
if (NULL == table_content || table_content->type != cJSON_Array) { if (NULL == table_content || table_content->type != cJSON_Array) {
log_error(logger, MODULE_JSON2IRIS, log_fatal(logger, MODULE_JSON2IRIS,
"[%s:%d] %d plugin_table's table_content not defined or format error", "[%s:%d] %d plugin_table's table_content not defined or format error",
__FUNCTION__, __LINE__, sequence); __FUNCTION__, __LINE__, sequence);
return -1; return -1;
@@ -266,7 +267,7 @@ static int write_plugin_line(cJSON *plug_table_json, int sequence,
for (int i = 0; i < line_cnt; i++) { for (int i = 0; i < line_cnt; i++) {
each_line = cJSON_GetArrayItem(table_content, i); each_line = cJSON_GetArrayItem(table_content, i);
if (NULL == each_line || each_line->type != cJSON_String) { if (NULL == each_line || each_line->type != cJSON_String) {
log_error(logger, MODULE_JSON2IRIS, log_fatal(logger, MODULE_JSON2IRIS,
"[%s:%d] plugin_table %s's line %d format error", "[%s:%d] plugin_table %s's line %d format error",
__FUNCTION__, __LINE__, table_info->table_name, i + 1); __FUNCTION__, __LINE__, table_info->table_name, i + 1);
continue; continue;
@@ -293,41 +294,17 @@ static struct group_info *group_info_read(struct group_info *group_name_map,
return node; return node;
} }
static int get_group_seq(struct iris_description *iris_cfg) static struct group_info *
group_info_add_unsafe(struct iris_description *p_iris, const char *group_name,
long long group_id)
{ {
redisReply *data_reply=NULL; struct group_info *group_info = ALLOC(struct group_info, 1);
int sequence = 0; group_info->group_id = group_id;
if (NULL == iris_cfg->redis_write_ctx) {
sequence = iris_cfg->group_cnt;
} else {
data_reply = maat_wrap_redis_command(iris_cfg->redis_write_ctx,
"INCRBY %s 1", mr_group_id_var);
sequence = (int)data_reply->integer - 1;
freeReplyObject(data_reply);
data_reply = NULL;
}
iris_cfg->group_cnt++;
return sequence;
}
static struct group_info *group_info_add_unsafe(struct iris_description *p_iris,
const char *group_name)
{
static struct group_info untitled_group;
struct group_info *group_info = NULL;
if (0 == strncasecmp(group_name, untitled_group_name, strlen(untitled_group_name))) {
group_info = &untitled_group;
group_info->group_id = get_group_seq(p_iris);
} else {
group_info = ALLOC(struct group_info, 1);
group_info->group_id = get_group_seq(p_iris);
strncpy(group_info->group_name, group_name, sizeof(group_info->group_name)); strncpy(group_info->group_name, group_name, sizeof(group_info->group_name));
HASH_ADD_KEYPTR(hh, p_iris->group_name_map, group_info->group_name, HASH_ADD_KEYPTR(hh, p_iris->group_name_map, group_info->group_name,
strlen(group_name), group_info); strlen(group_name), group_info);
}
return group_info; return group_info;
} }
@@ -367,7 +344,7 @@ static int direct_write_rule(cJSON *json, struct maat_kv_store *str2int,
} }
if (NULL == item || item->type != cmd[i].json_type) { if (NULL == item || item->type != cmd[i].json_type) {
log_error(logger, MODULE_JSON2IRIS, log_fatal(logger, MODULE_JSON2IRIS,
"[%s:%d] %s not defined or wrong format", "[%s:%d] %s not defined or wrong format",
__FUNCTION__, __LINE__, cmd[i].json_string); __FUNCTION__, __LINE__, cmd[i].json_string);
ret = -1; ret = -1;
@@ -379,7 +356,7 @@ static int direct_write_rule(cJSON *json, struct maat_kv_store *str2int,
char *p = item->valuestring; char *p = item->valuestring;
ret = maat_kv_read(str2int, p, &int_value, 1); ret = maat_kv_read(str2int, p, &int_value, 1);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_JSON2IRIS, log_fatal(logger, MODULE_JSON2IRIS,
"[%s:%d] %s's value %s is not valid format", "[%s:%d] %s's value %s is not valid format",
__FUNCTION__, __LINE__, cmd[i].json_string, p); __FUNCTION__, __LINE__, cmd[i].json_string, p);
FREE(p); FREE(p);
@@ -618,7 +595,7 @@ static int write_region_rule(cJSON *region_json, int compile_id, int group_id,
{ {
cJSON *item = cJSON_GetObjectItem(region_json, "table_name"); cJSON *item = cJSON_GetObjectItem(region_json, "table_name");
if (NULL == item || item->type != cJSON_String) { if (NULL == item || item->type != cJSON_String) {
log_error(logger, MODULE_JSON2IRIS, log_fatal(logger, MODULE_JSON2IRIS,
"[%s:%d] compile rule %d's table_name not defined " "[%s:%d] compile rule %d's table_name not defined "
"or format error", __FUNCTION__, __LINE__, compile_id); "or format error", __FUNCTION__, __LINE__, compile_id);
return -1; return -1;
@@ -627,7 +604,7 @@ static int write_region_rule(cJSON *region_json, int compile_id, int group_id,
item = cJSON_GetObjectItem(region_json, "table_type"); item = cJSON_GetObjectItem(region_json, "table_type");
if (NULL == item || item->type != cJSON_String) { if (NULL == item || item->type != cJSON_String) {
log_error(logger, MODULE_JSON2IRIS, log_fatal(logger, MODULE_JSON2IRIS,
"[%s:%d] compile rule %d's table name %s's table_type " "[%s:%d] compile rule %d's table name %s's table_type "
"not defined or format error", __FUNCTION__, __LINE__, "not defined or format error", __FUNCTION__, __LINE__,
compile_id, table_name); compile_id, table_name);
@@ -638,7 +615,7 @@ static int write_region_rule(cJSON *region_json, int compile_id, int group_id,
long long table_type_int; long long table_type_int;
int ret = maat_kv_read(p_iris->str2int_map, table_type_str, &table_type_int, 1); int ret = maat_kv_read(p_iris->str2int_map, table_type_str, &table_type_int, 1);
if (ret != 1) { if (ret != 1) {
log_error(logger, MODULE_JSON2IRIS, log_fatal(logger, MODULE_JSON2IRIS,
"[%s:%d] compile rule %d table name %s's table_type %s invalid", "[%s:%d] compile rule %d table name %s's table_type %s invalid",
__FUNCTION__, __LINE__, compile_id, table_name, table_type_str); __FUNCTION__, __LINE__, compile_id, table_name, table_type_str);
return -1; return -1;
@@ -646,7 +623,7 @@ static int write_region_rule(cJSON *region_json, int compile_id, int group_id,
cJSON *table_content = cJSON_GetObjectItem(region_json, "table_content"); cJSON *table_content = cJSON_GetObjectItem(region_json, "table_content");
if (NULL == table_content || table_content->type != cJSON_Object) { if (NULL == table_content || table_content->type != cJSON_Object) {
log_error(logger, MODULE_JSON2IRIS, log_fatal(logger, MODULE_JSON2IRIS,
"[%s:%d] compile rule %d table name %s's table_content " "[%s:%d] compile rule %d table name %s's table_content "
"not defined or format error", __FUNCTION__, __LINE__, "not defined or format error", __FUNCTION__, __LINE__,
compile_id, table_name); compile_id, table_name);
@@ -737,6 +714,7 @@ static int write_group_rule(cJSON *group_json, int parent_id,
int clause_index = 0, is_exclude = 0; int clause_index = 0, is_exclude = 0;
const char *str_parent_type[2] = {"compile", "group"}; const char *str_parent_type[2] = {"compile", "group"};
const char *group_name = NULL; const char *group_name = NULL;
long long group_id = -1;
const char *virtual_table = NULL; const char *virtual_table = NULL;
struct iris_table *g2c_table = NULL; struct iris_table *g2c_table = NULL;
@@ -747,6 +725,11 @@ static int write_group_rule(cJSON *group_json, int parent_id,
group_name = item->valuestring; group_name = item->valuestring;
} }
item = cJSON_GetObjectItem(group_json, "group_id");
if (item != NULL && item->type == cJSON_Number) {
group_id = item->valueint;
}
item = cJSON_GetObjectItem(group_json, "is_exclude"); item = cJSON_GetObjectItem(group_json, "is_exclude");
if (NULL == item || item->type != cJSON_Number) { if (NULL == item || item->type != cJSON_Number) {
is_exclude = 0; is_exclude = 0;
@@ -788,7 +771,18 @@ static int write_group_rule(cJSON *group_json, int parent_id,
struct group_info *group_info = group_info_read(p_iris->group_name_map, group_name); struct group_info *group_info = group_info_read(p_iris->group_name_map, group_name);
//exist group name, regions and sub groups will be ommit. //exist group name, regions and sub groups will be ommit.
if (NULL == group_info) { if (NULL == group_info) {
group_info = group_info_add_unsafe(p_iris, group_name); if (0 == strncasecmp(group_name, untitled_group_name, strlen(untitled_group_name))) {
group_id = untitled_group_id;
}
if (-1 == group_id) {
log_fatal(logger, MODULE_JSON2IRIS,
"[%s:%d] group_name:<%s> has no group_id",
__FUNCTION__, __LINE__, group_name);
return -1;
}
group_info = group_info_add_unsafe(p_iris, group_name, group_id);
cJSON *region_json = cJSON_GetObjectItem(group_json, "regions"); cJSON *region_json = cJSON_GetObjectItem(group_json, "regions");
if (region_json != NULL) { if (region_json != NULL) {
cJSON *region_rule = NULL; cJSON *region_rule = NULL;
@@ -796,7 +790,7 @@ static int write_group_rule(cJSON *group_json, int parent_id,
ret = write_region_rule(region_rule, tracking_compile_id, ret = write_region_rule(region_rule, tracking_compile_id,
group_info->group_id, p_iris, logger); group_info->group_id, p_iris, logger);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_JSON2IRIS, log_fatal(logger, MODULE_JSON2IRIS,
"[%s:%d] compile rule %d write region error", "[%s:%d] compile rule %d write region error",
__FUNCTION__, __LINE__, tracking_compile_id); __FUNCTION__, __LINE__, tracking_compile_id);
return -1; return -1;
@@ -834,7 +828,7 @@ static int write_group_rule(cJSON *group_json, int parent_id,
} }
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_JSON2IRIS, log_fatal(logger, MODULE_JSON2IRIS,
"[%s:%d] %s rule %d write group error", "[%s:%d] %s rule %d write group error",
__FUNCTION__, __LINE__, str_parent_type[parent_type], parent_id); __FUNCTION__, __LINE__, str_parent_type[parent_type], parent_id);
return -1; return -1;
@@ -848,7 +842,7 @@ static int write_compile_line(cJSON *compile, struct iris_description *p_iris,
{ {
cJSON *item=cJSON_GetObjectItem(compile, "compile_id"); cJSON *item=cJSON_GetObjectItem(compile, "compile_id");
if (item->type != cJSON_Number) { if (item->type != cJSON_Number) {
log_error(logger, MODULE_JSON2IRIS, log_fatal(logger, MODULE_JSON2IRIS,
"[%s:%d] compile_id format not number", __FUNCTION__, __LINE__); "[%s:%d] compile_id format not number", __FUNCTION__, __LINE__);
return -1; return -1;
} }
@@ -990,7 +984,7 @@ static int write_index_file(struct iris_description *p_iris,
{ {
p_iris->idx_fp = fopen(p_iris->index_path, "w"); p_iris->idx_fp = fopen(p_iris->index_path, "w");
if (NULL == p_iris->idx_fp) { if (NULL == p_iris->idx_fp) {
log_error(logger, MODULE_JSON2IRIS, log_fatal(logger, MODULE_JSON2IRIS,
"[%s:%d] index file %s fopen error %s", "[%s:%d] index file %s fopen error %s",
__FUNCTION__, __LINE__, p_iris->index_path, strerror(errno)); __FUNCTION__, __LINE__, p_iris->index_path, strerror(errno));
return -1; return -1;
@@ -1038,11 +1032,12 @@ static int write_iris(cJSON *json, struct iris_description *p_iris,
parent_group = group_info_read(p_iris->group_name_map, parent_group_name); parent_group = group_info_read(p_iris->group_name_map, parent_group_name);
if(NULL == parent_group) { if(NULL == parent_group) {
parent_group = group_info_add_unsafe(p_iris, parent_group_name); parent_group = group_info_add_unsafe(p_iris, parent_group_name,
untitled_group_id);
} }
ret = write_group_rule(group_obj, parent_group->group_id, PARENT_TYPE_GROUP, ret = write_group_rule(group_obj, parent_group->group_id,
0, 0, p_iris, logger); PARENT_TYPE_GROUP, 0, 0, p_iris, logger);
if (ret < 0) { if (ret < 0) {
return -1; return -1;
} }
@@ -1060,14 +1055,14 @@ static int write_iris(cJSON *json, struct iris_description *p_iris,
cJSON_ArrayForEach(compile_obj, compile_array) { cJSON_ArrayForEach(compile_obj, compile_array) {
int compile_id = write_compile_line(compile_obj, p_iris, logger); int compile_id = write_compile_line(compile_obj, p_iris, logger);
if (compile_id < 0) { if (compile_id < 0) {
log_error(logger, MODULE_JSON2IRIS, "[%s:%d] In %d compile rule", log_fatal(logger, MODULE_JSON2IRIS, "[%s:%d] In %d compile rule",
__FUNCTION__, __LINE__, i); __FUNCTION__, __LINE__, i);
return -1; return -1;
} }
group_array = cJSON_GetObjectItem(compile_obj, "groups"); group_array = cJSON_GetObjectItem(compile_obj, "groups");
if (NULL == group_array) { if (NULL == group_array) {
log_error(logger, MODULE_JSON2IRIS, log_fatal(logger, MODULE_JSON2IRIS,
"[%s:%d] compile rule %d have no group", "[%s:%d] compile rule %d have no group",
__FUNCTION__, __LINE__, compile_id); __FUNCTION__, __LINE__, compile_id);
return -1; return -1;
@@ -1075,7 +1070,7 @@ static int write_iris(cJSON *json, struct iris_description *p_iris,
int group_cnt = cJSON_GetArraySize(group_array); int group_cnt = cJSON_GetArraySize(group_array);
if (group_cnt <= 0) { if (group_cnt <= 0) {
log_error(logger, MODULE_JSON2IRIS, log_fatal(logger, MODULE_JSON2IRIS,
"[%s:%d] compile rule %d have no groups", "[%s:%d] compile rule %d have no groups",
__FUNCTION__, __LINE__, compile_id); __FUNCTION__, __LINE__, compile_id);
return -1; return -1;
@@ -1117,7 +1112,7 @@ int json2iris(const char *json_buff, const char *json_filename,
cJSON *json = cJSON_Parse(json_buff); cJSON *json = cJSON_Parse(json_buff);
if (!json) { if (!json) {
log_error(logger, MODULE_JSON2IRIS, log_fatal(logger, MODULE_JSON2IRIS,
"[%s:%d] error message: %-200.200s", "[%s:%d] error message: %-200.200s",
__FUNCTION__, __LINE__, cJSON_GetErrorPtr()); __FUNCTION__, __LINE__, cJSON_GetErrorPtr());
goto error_out; goto error_out;
@@ -1147,7 +1142,7 @@ int json2iris(const char *json_buff, const char *json_filename,
ret = create_tmp_dir(&iris_cfg); ret = create_tmp_dir(&iris_cfg);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_JSON2IRIS, log_fatal(logger, MODULE_JSON2IRIS,
"[%s:%d] create tmp folder %s error", "[%s:%d] create tmp folder %s error",
__FUNCTION__, __LINE__, iris_cfg.tmp_iris_dir); __FUNCTION__, __LINE__, iris_cfg.tmp_iris_dir);
goto error_out; goto error_out;

View File

@@ -385,7 +385,7 @@ struct maat *maat_new(struct maat_options *opts, const char *table_info_path)
if (maat_inst->opts.input_mode != DATA_SOURCE_IRIS_FILE && if (maat_inst->opts.input_mode != DATA_SOURCE_IRIS_FILE &&
maat_inst->opts.input_mode != DATA_SOURCE_JSON_FILE && maat_inst->opts.input_mode != DATA_SOURCE_JSON_FILE &&
maat_inst->opts.input_mode != DATA_SOURCE_REDIS) { maat_inst->opts.input_mode != DATA_SOURCE_REDIS) {
log_error(maat_inst->logger, MODULE_MAAT_API, log_fatal(maat_inst->logger, MODULE_MAAT_API,
"[%s:%d] data source(%d) unsupported", "[%s:%d] data source(%d) unsupported",
__FUNCTION__, __LINE__, maat_inst->opts.input_mode); __FUNCTION__, __LINE__, maat_inst->opts.input_mode);
goto failed; goto failed;
@@ -412,7 +412,7 @@ struct maat *maat_new(struct maat_options *opts, const char *table_info_path)
if (1 == maat_inst->opts.stat_on) { if (1 == maat_inst->opts.stat_on) {
int ret = maat_stat_init(maat_inst->stat, maat_inst->tbl_mgr, maat_inst->garbage_bin); int ret = maat_stat_init(maat_inst->stat, maat_inst->tbl_mgr, maat_inst->garbage_bin);
if (ret < 0) { if (ret < 0) {
log_error(maat_inst->logger, MODULE_MAAT_API, log_fatal(maat_inst->logger, MODULE_MAAT_API,
"[%s:%d] maat_stat_init failed.", __FUNCTION__, __LINE__); "[%s:%d] maat_stat_init failed.", __FUNCTION__, __LINE__);
goto failed; goto failed;
} }
@@ -516,7 +516,7 @@ int maat_table_callback_register(struct maat *maat_inst, int table_id,
void *schema = table_manager_get_schema(maat_inst->tbl_mgr, table_id); void *schema = table_manager_get_schema(maat_inst->tbl_mgr, table_id);
if (NULL == schema) { if (NULL == schema) {
pthread_mutex_unlock(&(maat_inst->background_update_mutex)); pthread_mutex_unlock(&(maat_inst->background_update_mutex));
log_error(maat_inst->logger, MODULE_MAAT_API, log_fatal(maat_inst->logger, MODULE_MAAT_API,
"[%s:%d] table(table_id:%d) schema is NULL, register callback failed", "[%s:%d] table(table_id:%d) schema is NULL, register callback failed",
__FUNCTION__, __LINE__, table_id); __FUNCTION__, __LINE__, table_id);
return -1; return -1;
@@ -539,7 +539,7 @@ int maat_table_callback_register(struct maat *maat_inst, int table_id,
enum table_type table_type = table_manager_get_table_type(maat_inst->tbl_mgr, table_id); enum table_type table_type = table_manager_get_table_type(maat_inst->tbl_mgr, table_id);
if (table_type != TABLE_TYPE_PLUGIN) { if (table_type != TABLE_TYPE_PLUGIN) {
pthread_mutex_unlock(&(maat_inst->background_update_mutex)); pthread_mutex_unlock(&(maat_inst->background_update_mutex));
log_error(maat_inst->logger, MODULE_MAAT_API, log_fatal(maat_inst->logger, MODULE_MAAT_API,
"[%s:%d] table type:%d illegal", __FUNCTION__, __LINE__, table_type); "[%s:%d] table type:%d illegal", __FUNCTION__, __LINE__, table_type);
return -1; return -1;
} }
@@ -578,7 +578,7 @@ static int generic_plugin_table_set_ex_schema(struct table_manager *tbl_mgr, int
{ {
void *schema = table_manager_get_schema(tbl_mgr, table_id); void *schema = table_manager_get_schema(tbl_mgr, table_id);
if (NULL == schema) { if (NULL == schema) {
log_error(logger, MODULE_MAAT_API, log_fatal(logger, MODULE_MAAT_API,
"[%s:%d], table(table_id:%d) is not registered, can't " "[%s:%d], table(table_id:%d) is not registered, can't "
"register ex_container_schema", __FUNCTION__, __LINE__, table_id); "register ex_container_schema", __FUNCTION__, __LINE__, table_id);
return -1; return -1;
@@ -614,7 +614,7 @@ static int generic_plugin_table_set_ex_schema(struct table_manager *tbl_mgr, int
free, argl, argp); free, argl, argp);
break; break;
default: default:
log_error(logger, MODULE_MAAT_API, log_fatal(logger, MODULE_MAAT_API,
"[%s:%d], table(table_id:%d) is not plugin table, can't set ex schema", "[%s:%d], table(table_id:%d) is not plugin table, can't set ex schema",
__FUNCTION__, __LINE__, table_id); __FUNCTION__, __LINE__, table_id);
return -1; return -1;
@@ -735,7 +735,7 @@ static int generic_plugin_runtime_commit_ex_schema(void *runtime, void *schema,
struct log_handle *logger) struct log_handle *logger)
{ {
if (NULL == runtime || NULL == schema || valid_column < 0) { if (NULL == runtime || NULL == schema || valid_column < 0) {
log_error(logger, MODULE_MAAT_API, log_fatal(logger, MODULE_MAAT_API,
"[%s:%d] input parameter invalid, runtime:%p, schema:%p, valid_column:%d", "[%s:%d] input parameter invalid, runtime:%p, schema:%p, valid_column:%d",
__FUNCTION__, __LINE__, runtime, schema, valid_column); __FUNCTION__, __LINE__, runtime, schema, valid_column);
return -1; return -1;
@@ -758,7 +758,7 @@ static int generic_plugin_runtime_commit_ex_schema(void *runtime, void *schema,
bool_plugin_runtime_commit_ex_schema(runtime, schema, table_name, valid_column); bool_plugin_runtime_commit_ex_schema(runtime, schema, table_name, valid_column);
break; break;
default: default:
log_error(logger, MODULE_MAAT_API, log_fatal(logger, MODULE_MAAT_API,
"[%s:%d] table_type:%d invalid", __FUNCTION__, __LINE__, table_type); "[%s:%d] table_type:%d invalid", __FUNCTION__, __LINE__, table_type);
return -1; return -1;
} }
@@ -790,7 +790,7 @@ static int generic_plugin_table_ex_schema_register(struct maat *maat_inst,
table_type = table_manager_get_table_type(maat_inst->tbl_mgr, table_id); table_type = table_manager_get_table_type(maat_inst->tbl_mgr, table_id);
valid_column = table_manager_get_valid_column(maat_inst->tbl_mgr, table_id); valid_column = table_manager_get_valid_column(maat_inst->tbl_mgr, table_id);
if (table_type == TABLE_TYPE_INVALID || valid_column < 0) { if (table_type == TABLE_TYPE_INVALID || valid_column < 0) {
log_error(maat_inst->logger, MODULE_MAAT_API, log_fatal(maat_inst->logger, MODULE_MAAT_API,
"[%s:%d] table_type:%d or valid_column:%d invalid", "[%s:%d] table_type:%d or valid_column:%d invalid",
__FUNCTION__, __LINE__, table_type, valid_column); __FUNCTION__, __LINE__, table_type, valid_column);
return -1; return -1;
@@ -812,7 +812,7 @@ int maat_plugin_table_ex_schema_register(struct maat *maat_inst,
long argl, void *argp) long argl, void *argp)
{ {
if (NULL == maat_inst || NULL == table_name) { if (NULL == maat_inst || NULL == table_name) {
log_error(maat_inst->logger, MODULE_MAAT_API, log_fatal(maat_inst->logger, MODULE_MAAT_API,
"[%s:%d] [table:%s] ex_schema register input parameter is invalid.", "[%s:%d] [table:%s] ex_schema register input parameter is invalid.",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
return -1; return -1;
@@ -820,7 +820,7 @@ int maat_plugin_table_ex_schema_register(struct maat *maat_inst,
int table_id = maat_get_table_id(maat_inst, table_name); int table_id = maat_get_table_id(maat_inst, table_name);
if (table_id < 0) { if (table_id < 0) {
log_error(maat_inst->logger, MODULE_MAAT_API, log_fatal(maat_inst->logger, MODULE_MAAT_API,
"[%s:%d] [table:%s] is not registered before.", "[%s:%d] [table:%s] is not registered before.",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
return -1; return -1;
@@ -992,14 +992,6 @@ int maat_bool_plugin_table_get_ex_data(struct maat *maat_inst, int table_id,
ex_data_array, array_size); ex_data_array, array_size);
} }
static size_t hit_group_to_compile(void *compile_runtime, long long *compile_ids,
size_t compile_ids_size, struct maat_state *state)
{
size_t n_hit_compile = compile_runtime_match((struct compile_runtime *)compile_runtime,
compile_ids, compile_ids_size, state);
return n_hit_compile;
}
static int flag_scan(struct table_manager *tbl_mgr, int thread_id, long long flag, static int flag_scan(struct table_manager *tbl_mgr, int thread_id, long long flag,
int phy_table_id, int vtable_id, struct maat_state *state) int phy_table_id, int vtable_id, struct maat_state *state)
{ {
@@ -1192,18 +1184,17 @@ static size_t group_to_compile(struct maat *maat_inst, long long *results,
return 0; return 0;
} }
size_t n_hit_compile = hit_group_to_compile(compile_rt, results, n_result, state); return compile_runtime_match((struct compile_runtime *)compile_rt,
results, n_result, state);
return n_hit_compile;
} }
int maat_scan_flag(struct maat *maat_inst, int table_id, int maat_scan_flag(struct maat *maat_inst, int table_id,
long long flag, long long *results, size_t n_result, long long flag, long long *results, size_t n_result,
size_t *n_hit_result, struct maat_state *state) size_t *n_hit_result, struct maat_state *state)
{ {
if ((NULL == maat_inst) || table_id < 0 || table_id >= MAX_TABLE_NUM if ((NULL == maat_inst) || table_id < 0 || table_id >= MAX_TABLE_NUM ||
|| (NULL == results) || (0 == n_result) || (NULL == state) || (NULL == results) || (0 == n_result) || (NULL == n_hit_result) ||
(state->thread_id < 0)) { (NULL == state) || (state->thread_id < 0)) {
return MAAT_SCAN_ERR; return MAAT_SCAN_ERR;
} }
@@ -1285,9 +1276,9 @@ int maat_scan_integer(struct maat *maat_inst, int table_id,
long long integer, long long *results, size_t n_result, long long integer, long long *results, size_t n_result,
size_t *n_hit_result, struct maat_state *state) size_t *n_hit_result, struct maat_state *state)
{ {
if ((NULL == maat_inst) || table_id < 0 || table_id >= MAX_TABLE_NUM if ((NULL == maat_inst) || table_id < 0 || table_id >= MAX_TABLE_NUM ||
|| (NULL == results) || (0 == n_result) || (NULL == state) || (NULL == results) || (0 == n_result) || (NULL == n_hit_result) ||
(state->thread_id < 0)) { (NULL == state) || (state->thread_id < 0)) {
return MAAT_SCAN_ERR; return MAAT_SCAN_ERR;
} }
@@ -1369,9 +1360,9 @@ int maat_scan_ipv4(struct maat *maat_inst, int table_id, uint32_t ip_addr,
uint16_t port, int protocol, long long *results, size_t n_result, uint16_t port, int protocol, long long *results, size_t n_result,
size_t *n_hit_result, struct maat_state *state) size_t *n_hit_result, struct maat_state *state)
{ {
if ((NULL == maat_inst) || table_id < 0 || table_id >= MAX_TABLE_NUM if ((NULL == maat_inst) || table_id < 0 || table_id >= MAX_TABLE_NUM ||
|| (protocol < -1) || (NULL == results) || (0 == n_result) (protocol < -1) || (NULL == results) || (0 == n_result) ||
|| (NULL == state) || (state->thread_id < 0)) { (NULL == n_hit_result) || (NULL == state) || (state->thread_id < 0)) {
return MAAT_SCAN_ERR; return MAAT_SCAN_ERR;
} }
@@ -1454,9 +1445,10 @@ int maat_scan_ipv6(struct maat *maat_inst, int table_id,
long long *results, size_t n_result, long long *results, size_t n_result,
size_t *n_hit_result, struct maat_state *state) size_t *n_hit_result, struct maat_state *state)
{ {
if ((NULL == maat_inst) || table_id < 0 || table_id >= MAX_TABLE_NUM if ((NULL == maat_inst) || table_id < 0 || table_id >= MAX_TABLE_NUM ||
|| (protocol < -1) || (NULL == ip_addr) || (NULL == results) (protocol < -1) || (NULL == ip_addr) || (NULL == results) ||
|| (0 == n_result) || (NULL == state) || (state->thread_id < 0)) { (0 == n_result) || (NULL == n_hit_result) || (NULL == state) ||
(state->thread_id < 0)) {
return MAAT_SCAN_ERR; return MAAT_SCAN_ERR;
} }
@@ -1534,13 +1526,15 @@ int maat_scan_ipv6(struct maat *maat_inst, int table_id,
} }
} }
int maat_scan_string(struct maat *maat_inst, int table_id, const char *data, int maat_scan_string(struct maat *maat_inst, int table_id,
size_t data_len, long long *results, size_t n_result, const char *data, size_t data_len,
long long *results, size_t n_result,
size_t *n_hit_result, struct maat_state *state) size_t *n_hit_result, struct maat_state *state)
{ {
if ((NULL == maat_inst) || table_id < 0 || table_id >= MAX_TABLE_NUM if ((NULL == maat_inst) || table_id < 0 || table_id >= MAX_TABLE_NUM ||
|| (NULL == data) || (0 == data_len) || (NULL == results) (NULL == data) || (0 == data_len) || (NULL == results) ||
|| (0 == n_result) || (NULL == state) || (state->thread_id < 0)) { (0 == n_result) || (NULL == n_hit_result) || (NULL == state) ||
(state->thread_id < 0)) {
return MAAT_SCAN_ERR; return MAAT_SCAN_ERR;
} }
@@ -1618,11 +1612,130 @@ int maat_scan_string(struct maat *maat_inst, int table_id, const char *data,
} }
} }
static void maat_state_add_hit_group(struct maat_state *state, int table_id,
long long *group_ids, size_t n_group_id)
{
struct maat *maat_inst = state->maat_inst;
if (NULL == state->compile_state) {
state->compile_state = compile_state_new();
alignment_int64_array_add(maat_inst->stat->compile_state_cnt,
state->thread_id, 1);
}
size_t n_hit_item = n_group_id;
if (n_group_id >= MAX_HIT_GROUP_NUM) {
n_hit_item = MAX_HIT_GROUP_NUM;
}
struct maat_item hit_items[n_hit_item];
for (size_t i = 0; i < n_hit_item; i++) {
hit_items[i].item_id = 0;
hit_items[i].group_id = group_ids[i];
}
compile_state_update(state->compile_state, maat_inst, table_id,
state->compile_table_id, state->scan_cnt,
hit_items, n_hit_item);
}
static void maat_state_activate_hit_not_group(struct maat_state *state, int table_id)
{
if (NULL == state) {
return;
}
struct maat *maat_inst = state->maat_inst;
int compile_table_id = table_manager_get_default_compile_table_id(maat_inst->tbl_mgr);
if (state->compile_table_id > 0) {
compile_table_id = state->compile_table_id;
}
struct compile_runtime *compile_rt = table_manager_get_runtime(maat_inst->tbl_mgr,
compile_table_id);
if (NULL == compile_rt) {
return;
}
compile_state_not_logic_update(state->compile_state, compile_rt, maat_inst,
table_id, state->scan_cnt);
}
int maat_scan_group(struct maat *maat_inst, int table_id,
long long *group_ids, size_t n_group_id,
long long *results, size_t n_result,
size_t *n_hit_result, struct maat_state *state)
{
if ((NULL == maat_inst) || table_id < 0 || table_id >= MAX_TABLE_NUM ||
(NULL == group_ids) || (0 == n_group_id) || (NULL == results) ||
(0 == n_result) || (NULL == n_hit_result) || (NULL == state) ||
(state->thread_id < 0)) {
return -1;
}
state->scan_cnt++;
struct maat_runtime *maat_rt = maat_inst->maat_rt;
if (NULL == maat_rt) {
return MAAT_SCAN_OK;
}
maat_runtime_ref_inc(maat_rt, state->thread_id);
alignment_int64_array_add(maat_inst->stat->thread_call_cnt, state->thread_id, 1);
maat_state_add_hit_group(state, table_id, group_ids, n_group_id);
size_t hit_compile_cnt = group_to_compile(maat_inst, results, n_result, state);
*n_hit_result = hit_compile_cnt;
maat_runtime_ref_dec(maat_rt, state->thread_id);
if (hit_compile_cnt > 0) {
alignment_int64_array_add(maat_inst->stat->hit_cnt, state->thread_id, 1);
return MAAT_SCAN_HIT;
}
return MAAT_SCAN_OK;
}
int maat_scan_not_logic(struct maat *maat_inst, int table_id,
long long *results, size_t n_result,
size_t *n_hit_result, struct maat_state *state)
{
if ((NULL == maat_inst) || table_id < 0 || table_id >= MAX_TABLE_NUM ||
(NULL == results) || (0 == n_result) || (NULL == n_hit_result) ||
(NULL == state) || (state->thread_id < 0)) {
return -1;
}
if (NULL == state->compile_state) {
return 0;
}
struct maat_runtime *maat_rt = maat_inst->maat_rt;
if (NULL == maat_rt) {
return MAAT_SCAN_OK;
}
maat_runtime_ref_inc(maat_rt, state->thread_id);
alignment_int64_array_add(maat_inst->stat->thread_call_cnt, state->thread_id, 1);
maat_state_activate_hit_not_group(state, table_id);
size_t hit_compile_cnt = group_to_compile(maat_inst, results, n_result, state);
*n_hit_result = hit_compile_cnt;
maat_runtime_ref_dec(maat_rt, state->thread_id);
if (hit_compile_cnt > 0) {
alignment_int64_array_add(maat_inst->stat->hit_cnt, state->thread_id, 1);
return MAAT_SCAN_HIT;
}
return MAAT_SCAN_OK;
}
struct maat_stream *maat_stream_new(struct maat *maat_inst, int table_id, struct maat_stream *maat_stream_new(struct maat *maat_inst, int table_id,
struct maat_state *state) struct maat_state *state)
{ {
if (NULL == maat_inst || table_id < 0 || table_id > MAX_TABLE_NUM if ((NULL == maat_inst) || table_id < 0 || table_id >= MAX_TABLE_NUM ||
|| NULL == state || state->thread_id < 0) { (NULL == state) || (state->thread_id < 0)) {
return NULL; return NULL;
} }
@@ -1825,16 +1938,6 @@ void maat_state_free(struct maat_state *state)
thread_id, sizeof(struct maat_state)); thread_id, sizeof(struct maat_state));
} }
void maat_state_set_logic_not_disabled(struct maat_state *state)
{
}
void maat_state_set_logic_not_enabled(struct maat_state *state)
{
}
int maat_state_set_scan_district(struct maat_state *state, int table_id, int maat_state_set_scan_district(struct maat_state *state, int table_id,
const char *district, size_t district_len) const char *district, size_t district_len)
{ {
@@ -1846,7 +1949,7 @@ int maat_state_set_scan_district(struct maat_state *state, int table_id,
assert(maat_inst != NULL); assert(maat_inst != NULL);
if (NULL == maat_inst->maat_rt) { if (NULL == maat_inst->maat_rt) {
log_error(maat_inst->logger, MODULE_MAAT_API, log_fatal(maat_inst->logger, MODULE_MAAT_API,
"maat runtime is NULL, can't set district"); "maat runtime is NULL, can't set district");
return -1; return -1;
} }
@@ -1855,7 +1958,7 @@ int maat_state_set_scan_district(struct maat_state *state, int table_id,
table_type = table_manager_get_table_type(maat_inst->tbl_mgr, table_id); table_type = table_manager_get_table_type(maat_inst->tbl_mgr, table_id);
if (table_type != TABLE_TYPE_FLAG_PLUS && table_type != TABLE_TYPE_EXPR_PLUS && if (table_type != TABLE_TYPE_FLAG_PLUS && table_type != TABLE_TYPE_EXPR_PLUS &&
table_type != TABLE_TYPE_INTERVAL_PLUS && table_type != TABLE_TYPE_VIRTUAL) { table_type != TABLE_TYPE_INTERVAL_PLUS && table_type != TABLE_TYPE_VIRTUAL) {
log_error(maat_inst->logger, MODULE_MAAT_API, log_fatal(maat_inst->logger, MODULE_MAAT_API,
"table_type:%d is invalid, can't set district", table_type); "table_type:%d is invalid, can't set district", table_type);
return -1; return -1;
} }
@@ -1886,7 +1989,7 @@ int maat_state_set_scan_district(struct maat_state *state, int table_id,
district, district_len, &district_id); district, district_len, &district_id);
break; break;
default: default:
log_error(maat_inst->logger, MODULE_MAAT_API, log_fatal(maat_inst->logger, MODULE_MAAT_API,
"[%s:%d] table_type:%d can't set district", "[%s:%d] table_type:%d can't set district",
__FUNCTION__, __LINE__, table_type); __FUNCTION__, __LINE__, table_type);
break; break;

View File

@@ -54,7 +54,7 @@ void *bool_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (item != NULL && item->type == cJSON_Number) { if (item != NULL && item->type == cJSON_Number) {
schema->table_id = item->valueint; schema->table_id = item->valueint;
} else { } else {
log_error(logger, MODULE_BOOL_PLUGIN, log_fatal(logger, MODULE_BOOL_PLUGIN,
"[%s:%d] bool_plugin table:<%s> schema has no table_id column", "[%s:%d] bool_plugin table:<%s> schema has no table_id column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -62,7 +62,7 @@ void *bool_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
item = cJSON_GetObjectItem(json, "custom"); item = cJSON_GetObjectItem(json, "custom");
if (NULL == item || item->type != cJSON_Object) { if (NULL == item || item->type != cJSON_Object) {
log_error(logger, MODULE_BOOL_PLUGIN, log_fatal(logger, MODULE_BOOL_PLUGIN,
"[%s:%d] bool_plugin table:<%s> schema has no custom column", "[%s:%d] bool_plugin table:<%s> schema has no custom column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -72,7 +72,7 @@ void *bool_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->item_id_column = custom_item->valueint; schema->item_id_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_BOOL_PLUGIN, log_fatal(logger, MODULE_BOOL_PLUGIN,
"[%s:%d] bool_plugin table:<%s> schema has no item_id column", "[%s:%d] bool_plugin table:<%s> schema has no item_id column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -82,7 +82,7 @@ void *bool_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->bool_expr_column = custom_item->valueint; schema->bool_expr_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_BOOL_PLUGIN, log_fatal(logger, MODULE_BOOL_PLUGIN,
"[%s:%d] bool_plugin table:<%s> schema has no bool_expr column", "[%s:%d] bool_plugin table:<%s> schema has no bool_expr column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -126,7 +126,7 @@ int bool_plugin_table_set_ex_container_schema(void *bool_plugin_schema, int tabl
struct bool_plugin_schema *schema = (struct bool_plugin_schema *)bool_plugin_schema; struct bool_plugin_schema *schema = (struct bool_plugin_schema *)bool_plugin_schema;
if (1 == schema->container_schema.set_flag) { if (1 == schema->container_schema.set_flag) {
log_error(schema->logger, MODULE_BOOL_PLUGIN, log_fatal(schema->logger, MODULE_BOOL_PLUGIN,
"[%s:%d] bool_plugin table(table_id:%d) ex_container_schema" "[%s:%d] bool_plugin table(table_id:%d) ex_container_schema"
" has been set, can't set again", __FUNCTION__, __LINE__, table_id); " has been set, can't set again", __FUNCTION__, __LINE__, table_id);
return -1; return -1;
@@ -270,7 +270,7 @@ static int bool_plugin_accept_tag_match(struct bool_plugin_schema *schema,
int ret = get_column_pos(line, schema->rule_tag_column, int ret = get_column_pos(line, schema->rule_tag_column,
&column_offset, &column_len); &column_offset, &column_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_BOOL_PLUGIN, log_fatal(logger, MODULE_BOOL_PLUGIN,
"[%s:%d] bool_plugin table:<%s> has no rule_tag in line:%s", "[%s:%d] bool_plugin table:<%s> has no rule_tag in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
return TAG_MATCH_ERR; return TAG_MATCH_ERR;
@@ -282,14 +282,14 @@ static int bool_plugin_accept_tag_match(struct bool_plugin_schema *schema,
ret = table_manager_accept_tags_match(schema->ref_tbl_mgr, tag_str); ret = table_manager_accept_tags_match(schema->ref_tbl_mgr, tag_str);
FREE(tag_str); FREE(tag_str);
if (TAG_MATCH_ERR == ret) { if (TAG_MATCH_ERR == ret) {
log_error(logger, MODULE_BOOL_PLUGIN, log_fatal(logger, MODULE_BOOL_PLUGIN,
"[%s:%d] bool_plugin table:<%s> has invalid tag format in line:%s", "[%s:%d] bool_plugin table:<%s> has invalid tag format in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
return TAG_MATCH_ERR; return TAG_MATCH_ERR;
} }
if (TAG_MATCH_UNMATCHED == ret) { if (TAG_MATCH_UNMATCHED == ret) {
log_error(logger, MODULE_BOOL_PLUGIN, log_fatal(logger, MODULE_BOOL_PLUGIN,
"[%s:%d] bool_plugin table:<%s> has unmatched tag in line:%s", "[%s:%d] bool_plugin table:<%s> has unmatched tag in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
return TAG_MATCH_UNMATCHED; return TAG_MATCH_UNMATCHED;
@@ -319,7 +319,7 @@ bool_plugin_expr_new(struct bool_plugin_schema *schema, const char *table_name,
ret = get_column_pos(line, schema->item_id_column, &column_offset, &column_len); ret = get_column_pos(line, schema->item_id_column, &column_offset, &column_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_BOOL_PLUGIN, log_fatal(logger, MODULE_BOOL_PLUGIN,
"[%s:%d] bool_plugin table:<%s> has no item_id in line:%s", "[%s:%d] bool_plugin table:<%s> has no item_id in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -328,7 +328,7 @@ bool_plugin_expr_new(struct bool_plugin_schema *schema, const char *table_name,
ret = get_column_pos(line, schema->bool_expr_column, &column_offset, &column_len); ret = get_column_pos(line, schema->bool_expr_column, &column_offset, &column_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_BOOL_PLUGIN, log_fatal(logger, MODULE_BOOL_PLUGIN,
"[%s:%d] bool_plugin table:<%s> has no bool_expr in line:%s", "[%s:%d] bool_plugin table:<%s> has no bool_expr in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -345,7 +345,7 @@ bool_plugin_expr_new(struct bool_plugin_schema *schema, const char *table_name,
ret = sscanf(sub_token, "%llu", items + n_item); ret = sscanf(sub_token, "%llu", items + n_item);
n_item++; n_item++;
if (ret != 1 || n_item > MAX_ITEMS_PER_BOOL_EXPR) { if (ret != 1 || n_item > MAX_ITEMS_PER_BOOL_EXPR) {
log_error(logger, MODULE_BOOL_PLUGIN, log_fatal(logger, MODULE_BOOL_PLUGIN,
"[%s:%d] bool_plugin table:<%s> has invalid format of " "[%s:%d] bool_plugin table:<%s> has invalid format of "
"bool_expr in line:%s", __FUNCTION__, __LINE__, table_name, line); "bool_expr in line:%s", __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -386,7 +386,7 @@ int bool_plugin_runtime_update(void *bool_plugin_runtime, void *bool_plugin_sche
int is_valid = get_column_value(line, valid_column); int is_valid = get_column_value(line, valid_column);
if (is_valid < 0) { if (is_valid < 0) {
log_error(bool_plugin_rt->logger, MODULE_BOOL_PLUGIN, log_fatal(bool_plugin_rt->logger, MODULE_BOOL_PLUGIN,
"[%s:%d] bool_plugin table:<%s> has no is_valid(column seq:%d)" "[%s:%d] bool_plugin table:<%s> has no is_valid(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name, " in table_line:%s", __FUNCTION__, __LINE__, table_name,
valid_column, line); valid_column, line);
@@ -396,7 +396,7 @@ int bool_plugin_runtime_update(void *bool_plugin_runtime, void *bool_plugin_sche
int ret = get_column_pos(line, schema->item_id_column, &item_id_offset, &item_id_len); int ret = get_column_pos(line, schema->item_id_column, &item_id_offset, &item_id_len);
if (ret < 0) { if (ret < 0) {
log_error(bool_plugin_rt->logger, MODULE_BOOL_PLUGIN, log_fatal(bool_plugin_rt->logger, MODULE_BOOL_PLUGIN,
"[%s:%d] bool_plugin table:<%s> has no item_id(column seq:%d)" "[%s:%d] bool_plugin table:<%s> has no item_id(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name, " in table_line:%s", __FUNCTION__, __LINE__, table_name,
schema->item_id_column, line); schema->item_id_column, line);
@@ -488,7 +488,7 @@ int bool_plugin_runtime_commit(void *bool_plugin_runtime, const char *table_name
(end.tv_nsec - start.tv_nsec) / 1000000; (end.tv_nsec - start.tv_nsec) / 1000000;
if (NULL == new_bool_matcher) { if (NULL == new_bool_matcher) {
log_error(bool_plugin_rt->logger, MODULE_BOOL_PLUGIN, log_fatal(bool_plugin_rt->logger, MODULE_BOOL_PLUGIN,
"[%s:%d] table[%s] rebuild bool_matcher engine failed when " "[%s:%d] table[%s] rebuild bool_matcher engine failed when "
"update %zu bool_plugin rules", __FUNCTION__, __LINE__, "update %zu bool_plugin rules", __FUNCTION__, __LINE__,
table_name, rule_cnt); table_name, rule_cnt);

View File

@@ -68,7 +68,7 @@ redisContext *maat_connect_redis(const char *redis_ip, int redis_port,
printf("Unable to connect redis server %s:%d db%d, error: %s", printf("Unable to connect redis server %s:%d db%d, error: %s",
redis_ip, redis_port, redis_db, c == NULL ? "Unknown" : c->errstr); redis_ip, redis_port, redis_db, c == NULL ? "Unknown" : c->errstr);
} else { } else {
log_error(logger, MODULE_MAAT_COMMAND, log_fatal(logger, MODULE_MAAT_COMMAND,
"[%s:%d] Unable to connect redis server %s:%d db%d, error: %s", "[%s:%d] Unable to connect redis server %s:%d db%d, error: %s",
__FUNCTION__, __LINE__, redis_ip, redis_port, redis_db, __FUNCTION__, __LINE__, redis_ip, redis_port, redis_db,
c == NULL ? "Unknown" : c->errstr); c == NULL ? "Unknown" : c->errstr);
@@ -268,7 +268,7 @@ int maat_cmd_set_line(struct maat *maat_inst, const struct maat_cmd_line *line_r
int table_id = table_manager_get_table_id(maat_inst->tbl_mgr, line_rule->table_name); int table_id = table_manager_get_table_id(maat_inst->tbl_mgr, line_rule->table_name);
if (table_id < 0) { if (table_id < 0) {
log_error(maat_inst->logger, MODULE_MAAT_COMMAND, log_fatal(maat_inst->logger, MODULE_MAAT_COMMAND,
"[%s:%d] Command set line id %lld failed: unknown table %s", "[%s:%d] Command set line id %lld failed: unknown table %s",
__FUNCTION__, __LINE__, line_rule->rule_id, line_rule->table_name); __FUNCTION__, __LINE__, line_rule->rule_id, line_rule->table_name);
FREE(s_rule); FREE(s_rule);
@@ -277,7 +277,7 @@ int maat_cmd_set_line(struct maat *maat_inst, const struct maat_cmd_line *line_r
int valid_column = table_manager_get_valid_column(maat_inst->tbl_mgr, table_id); int valid_column = table_manager_get_valid_column(maat_inst->tbl_mgr, table_id);
if (valid_column < 0) { if (valid_column < 0) {
log_error(maat_inst->logger, MODULE_MAAT_COMMAND, log_fatal(maat_inst->logger, MODULE_MAAT_COMMAND,
"[%s:%d] Command set line id %lld failed: table %s is not a plugin or ip_plugin table", "[%s:%d] Command set line id %lld failed: table %s is not a plugin or ip_plugin table",
__FUNCTION__, __LINE__, line_rule->rule_id, line_rule->table_name); __FUNCTION__, __LINE__, line_rule->rule_id, line_rule->table_name);
FREE(s_rule); FREE(s_rule);
@@ -286,7 +286,7 @@ int maat_cmd_set_line(struct maat *maat_inst, const struct maat_cmd_line *line_r
int valid_offset = maat_get_valid_flag_offset(line_rule->table_line, valid_column); int valid_offset = maat_get_valid_flag_offset(line_rule->table_line, valid_column);
if (valid_offset < 0) { if (valid_offset < 0) {
log_error(maat_inst->logger, MODULE_MAAT_COMMAND, log_fatal(maat_inst->logger, MODULE_MAAT_COMMAND,
"[%s:%d] Command set line id %lld failed: table %s valid_offset error", "[%s:%d] Command set line id %lld failed: table %s valid_offset error",
__FUNCTION__, __LINE__, line_rule->rule_id, line_rule->table_name); __FUNCTION__, __LINE__, line_rule->rule_id, line_rule->table_name);
FREE(s_rule); FREE(s_rule);
@@ -322,7 +322,7 @@ int maat_cmd_set_file(struct maat *maat_inst, const char *key, const char *value
{ {
redisContext *ctx = maat_inst->opts.redis_ctx.write_ctx; redisContext *ctx = maat_inst->opts.redis_ctx.write_ctx;
if (NULL == ctx) { if (NULL == ctx) {
log_error(maat_inst->logger, MODULE_MAAT_COMMAND, log_fatal(maat_inst->logger, MODULE_MAAT_COMMAND,
"[%s:%d] failed: Redis is not connected.", "[%s:%d] failed: Redis is not connected.",
__FUNCTION__, __LINE__); __FUNCTION__, __LINE__);
return -1; return -1;
@@ -342,7 +342,7 @@ int maat_cmd_set_file(struct maat *maat_inst, const char *key, const char *value
redisReply *reply = NULL; redisReply *reply = NULL;
if (0 != strncmp(key, foreign_key_prefix, strlen(foreign_key_prefix))) { if (0 != strncmp(key, foreign_key_prefix, strlen(foreign_key_prefix))) {
log_error(maat_inst->logger, MODULE_MAAT_COMMAND, log_fatal(maat_inst->logger, MODULE_MAAT_COMMAND,
"Invalid File key, prefix %s is mandatory.", foreign_key_prefix); "Invalid File key, prefix %s is mandatory.", foreign_key_prefix);
return -1; return -1;
} }
@@ -361,7 +361,7 @@ int maat_cmd_set_file(struct maat *maat_inst, const char *key, const char *value
} }
if (NULL == reply || reply->type == REDIS_REPLY_NIL || reply->type == REDIS_REPLY_ERROR) { if (NULL == reply || reply->type == REDIS_REPLY_NIL || reply->type == REDIS_REPLY_ERROR) {
log_error(maat_inst->logger, MODULE_MAAT_COMMAND, log_fatal(maat_inst->logger, MODULE_MAAT_COMMAND,
"Set file failed, maybe Redis is busy."); "Set file failed, maybe Redis is busy.");
freeReplyObject(reply); freeReplyObject(reply);
reply = NULL; reply = NULL;

View File

@@ -30,7 +30,6 @@
#define MAX_SUPER_GROUP_CNT 128 #define MAX_SUPER_GROUP_CNT 128
#define MAX_NOT_CLAUSE_NUM 8 #define MAX_NOT_CLAUSE_NUM 8
#define VTABLE_MAX_NOT_GROUP_NUM 8
enum clause_not_flag { enum clause_not_flag {
CLAUSE_NOT_FLAG_UNSET = 0, CLAUSE_NOT_FLAG_UNSET = 0,
@@ -85,9 +84,17 @@ struct literal_clause {
UT_hash_handle hh; UT_hash_handle hh;
}; };
struct table_not_clause { struct table_clause {
int table_id; int vtable_id;
int not_clause_num; int actual_clause_num;
UT_array *clause_ids;
UT_array *group_ids;
UT_hash_handle hh;
};
struct table_group {
int vtable_id;
UT_array *group_ids;
UT_hash_handle hh; UT_hash_handle hh;
}; };
@@ -113,7 +120,7 @@ struct group2compile_runtime {
long long rule_num; long long rule_num;
long long update_err_cnt; long long update_err_cnt;
struct compile_runtime *ref_compile_rt; struct compile_runtime *ref_compile_rt;
struct table_not_clause *not_clause_hash; struct table_clause *tbl_not_clause_hash; //each virtual table's not clause number <= MAX_NOT_CLAUSE_NUM
}; };
struct maat_clause { struct maat_clause {
@@ -155,18 +162,22 @@ struct compile2table_id {
struct compile_state { struct compile_state {
int Nth_scan; int Nth_scan;
int this_scan_not_logic;
time_t compile_rt_version; time_t compile_rt_version;
UT_array *internal_hit_paths; UT_array *internal_hit_paths;
UT_array *all_hit_clauses; UT_array *all_hit_clauses;
UT_array *this_scan_hit_clauses; UT_array *this_scan_hit_clauses;
UT_array *this_scan_hit_not_clauses;
UT_array *direct_hit_groups; UT_array *direct_hit_groups;
UT_array *indirect_hit_groups; UT_array *indirect_hit_groups;
UT_array *hit_compile_table_ids; UT_array *hit_compile_table_ids;
struct table_group *hit_not_groups;
}; };
UT_icd ut_literal_id_icd = {sizeof(struct literal_id), NULL, NULL, NULL}; UT_icd ut_literal_id_icd = {sizeof(struct literal_id), NULL, NULL, NULL};
UT_icd ut_clause_id_icd = {sizeof(long long), NULL, NULL, NULL}; UT_icd ut_clause_id_icd = {sizeof(long long), NULL, NULL, NULL};
UT_icd ut_compile_group_id_icd = {sizeof(long long), NULL, NULL, NULL};
UT_icd ut_maat_hit_group_icd = {sizeof(struct maat_hit_group), NULL, NULL, NULL}; UT_icd ut_maat_hit_group_icd = {sizeof(struct maat_hit_group), NULL, NULL, NULL};
UT_icd ut_hit_path_icd = {sizeof(struct internal_hit_path), NULL, NULL, NULL}; UT_icd ut_hit_path_icd = {sizeof(struct internal_hit_path), NULL, NULL, NULL};
UT_icd ut_hit_compile_table_id_icd = {sizeof(struct compile2table_id), NULL, NULL, NULL}; UT_icd ut_hit_compile_table_id_icd = {sizeof(struct compile2table_id), NULL, NULL, NULL};
@@ -213,7 +224,7 @@ static int compile_accept_tag_match(struct compile_schema *schema, const char *l
int ret = get_column_pos(line, schema->rule_tag_column, int ret = get_column_pos(line, schema->rule_tag_column,
&column_offset, &column_len); &column_offset, &column_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_COMPILE, log_fatal(logger, MODULE_COMPILE,
"[%s:%d] table: <%s> has no rule_tag in line:%s", "[%s:%d] table: <%s> has no rule_tag in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
return TAG_MATCH_ERR; return TAG_MATCH_ERR;
@@ -225,14 +236,14 @@ static int compile_accept_tag_match(struct compile_schema *schema, const char *l
ret = table_manager_accept_tags_match(schema->ref_tbl_mgr, tag_str); ret = table_manager_accept_tags_match(schema->ref_tbl_mgr, tag_str);
FREE(tag_str); FREE(tag_str);
if (TAG_MATCH_ERR == ret) { if (TAG_MATCH_ERR == ret) {
log_error(logger, MODULE_COMPILE, log_fatal(logger, MODULE_COMPILE,
"[%s:%d] table: <%s> has invalid tag format in line:%s", "[%s:%d] table: <%s> has invalid tag format in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
return TAG_MATCH_ERR; return TAG_MATCH_ERR;
} }
if (TAG_MATCH_UNMATCHED == ret) { if (TAG_MATCH_UNMATCHED == ret) {
log_error(logger, MODULE_COMPILE, log_fatal(logger, MODULE_COMPILE,
"[%s:%d] table: <%s> has unmatched tag in line:%s", "[%s:%d] table: <%s> has unmatched tag in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
return TAG_MATCH_UNMATCHED; return TAG_MATCH_UNMATCHED;
@@ -259,7 +270,7 @@ compile_item_new(const char *table_line, struct compile_schema *schema,
ret = get_column_pos(table_line, schema->compile_id_column, ret = get_column_pos(table_line, schema->compile_id_column,
&column_offset, &column_len); &column_offset, &column_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_COMPILE, log_fatal(logger, MODULE_COMPILE,
"[%s:%d] table: <%s> has no compile_id in line:%s", "[%s:%d] table: <%s> has no compile_id in line:%s",
__FUNCTION__, __LINE__, table_name, table_line); __FUNCTION__, __LINE__, table_name, table_line);
goto error; goto error;
@@ -269,7 +280,7 @@ compile_item_new(const char *table_line, struct compile_schema *schema,
ret = get_column_pos(table_line, schema->declared_clause_num_column, ret = get_column_pos(table_line, schema->declared_clause_num_column,
&column_offset, &column_len); &column_offset, &column_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_COMPILE, log_fatal(logger, MODULE_COMPILE,
"[%s:%d] table: <%s> has no clause_num in line:%s", "[%s:%d] table: <%s> has no clause_num in line:%s",
__FUNCTION__, __LINE__, table_name, table_line); __FUNCTION__, __LINE__, table_name, table_line);
goto error; goto error;
@@ -278,7 +289,7 @@ compile_item_new(const char *table_line, struct compile_schema *schema,
compile_item->declared_clause_num = atoi(table_line + column_offset); compile_item->declared_clause_num = atoi(table_line + column_offset);
if (compile_item->declared_clause_num < 0 || if (compile_item->declared_clause_num < 0 ||
compile_item->declared_clause_num > MAX_NOT_CLAUSE_NUM) { compile_item->declared_clause_num > MAX_NOT_CLAUSE_NUM) {
log_error(logger, MODULE_COMPILE, log_fatal(logger, MODULE_COMPILE,
"[%s:%d] table: <%s> clause_num:%d exceed maximum:%d in line:%s", "[%s:%d] table: <%s> clause_num:%d exceed maximum:%d in line:%s",
__FUNCTION__, __LINE__, table_name, compile_item->declared_clause_num, __FUNCTION__, __LINE__, table_name, compile_item->declared_clause_num,
MAX_NOT_CLAUSE_NUM, table_line); MAX_NOT_CLAUSE_NUM, table_line);
@@ -355,7 +366,7 @@ void *compile_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (item != NULL && item->type == cJSON_Number) { if (item != NULL && item->type == cJSON_Number) {
schema->table_id = item->valueint; schema->table_id = item->valueint;
} else { } else {
log_error(logger, MODULE_COMPILE, log_fatal(logger, MODULE_COMPILE,
"[%s:%d] table: <%s> schema has no table_id column", "[%s:%d] table: <%s> schema has no table_id column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -363,7 +374,7 @@ void *compile_schema_new(cJSON *json, struct table_manager *tbl_mgr,
item = cJSON_GetObjectItem(json, "custom"); item = cJSON_GetObjectItem(json, "custom");
if (item == NULL || item->type != cJSON_Object) { if (item == NULL || item->type != cJSON_Object) {
log_error(logger, MODULE_COMPILE, log_fatal(logger, MODULE_COMPILE,
"[%s:%d] table: <%s> schema has no custom column", "[%s:%d] table: <%s> schema has no custom column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -373,7 +384,7 @@ void *compile_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->compile_id_column = custom_item->valueint; schema->compile_id_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_COMPILE, log_fatal(logger, MODULE_COMPILE,
"[%s:%d] table: <%s> schema has no compile_id column", "[%s:%d] table: <%s> schema has no compile_id column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -388,7 +399,7 @@ void *compile_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->declared_clause_num_column = custom_item->valueint; schema->declared_clause_num_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_COMPILE, log_fatal(logger, MODULE_COMPILE,
"[%s:%d] table: <%s> schema has no clause_num column", "[%s:%d] table: <%s> schema has no clause_num column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -416,7 +427,7 @@ void *group2compile_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (item != NULL && item->type == cJSON_Number) { if (item != NULL && item->type == cJSON_Number) {
g2c_schema->table_id = item->valueint; g2c_schema->table_id = item->valueint;
} else { } else {
log_error(logger, MODULE_COMPILE, log_fatal(logger, MODULE_COMPILE,
"[%s:%d] table: <%s> schema has no table_id column", "[%s:%d] table: <%s> schema has no table_id column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -426,7 +437,7 @@ void *group2compile_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (item != NULL && item->type == cJSON_Number) { if (item != NULL && item->type == cJSON_Number) {
g2c_schema->asso_compile_table_id = item->valueint; g2c_schema->asso_compile_table_id = item->valueint;
} else { } else {
log_error(logger, MODULE_COMPILE, log_fatal(logger, MODULE_COMPILE,
"[%s:%d] table: <%s> schema has no associated_compile_table_id column", "[%s:%d] table: <%s> schema has no associated_compile_table_id column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -434,7 +445,7 @@ void *group2compile_schema_new(cJSON *json, struct table_manager *tbl_mgr,
item = cJSON_GetObjectItem(json, "custom"); item = cJSON_GetObjectItem(json, "custom");
if (item == NULL || item->type != cJSON_Object) { if (item == NULL || item->type != cJSON_Object) {
log_error(logger, MODULE_COMPILE, log_fatal(logger, MODULE_COMPILE,
"[%s:%d] table: <%s> schema has no custom column", "[%s:%d] table: <%s> schema has no custom column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -444,7 +455,7 @@ void *group2compile_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
g2c_schema->group_id_column = custom_item->valueint; g2c_schema->group_id_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_COMPILE, log_fatal(logger, MODULE_COMPILE,
"[%s:%d] table: <%s> schema has no group_id column", "[%s:%d] table: <%s> schema has no group_id column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -454,7 +465,7 @@ void *group2compile_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
g2c_schema->compile_id_column = custom_item->valueint; g2c_schema->compile_id_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_COMPILE, log_fatal(logger, MODULE_COMPILE,
"[%s:%d] table: <%s> schema has no compile_id column", "[%s:%d] table: <%s> schema has no compile_id column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -464,7 +475,7 @@ void *group2compile_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
g2c_schema->not_flag_column = custom_item->valueint; g2c_schema->not_flag_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_COMPILE, log_fatal(logger, MODULE_COMPILE,
"[%s:%d] table: <%s> schema has no not_flag column", "[%s:%d] table: <%s> schema has no not_flag column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -474,7 +485,7 @@ void *group2compile_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
g2c_schema->vtable_name_column = custom_item->valueint; g2c_schema->vtable_name_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_COMPILE, log_fatal(logger, MODULE_COMPILE,
"[%s:%d] table: <%s> schema has no virtual_table_name column", "[%s:%d] table: <%s> schema has no virtual_table_name column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -484,7 +495,7 @@ void *group2compile_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
g2c_schema->clause_index_column = custom_item->valueint; g2c_schema->clause_index_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_COMPILE, log_fatal(logger, MODULE_COMPILE,
"[%s:%d] table: <%s> schema has no clause_index column", "[%s:%d] table: <%s> schema has no clause_index column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -520,7 +531,7 @@ void *compile_runtime_new(void *compile_schema, size_t max_thread_num,
struct compile_runtime *compile_rt = ALLOC(struct compile_runtime, 1); struct compile_runtime *compile_rt = ALLOC(struct compile_runtime, 1);
compile_rt->expr_match_buff = ALLOC(struct bool_expr_match, compile_rt->expr_match_buff = ALLOC(struct bool_expr_match,
max_thread_num * MAX_SCANNER_HIT_COMPILE_NUM); max_thread_num * MAX_HIT_COMPILE_NUM);
compile_rt->version = time(NULL); compile_rt->version = time(NULL);
compile_rt->cfg_hash = rcu_hash_new(rcu_compile_cfg_free, NULL, 0); compile_rt->cfg_hash = rcu_hash_new(rcu_compile_cfg_free, NULL, 0);
compile_rt->tbl_cfg_hash = rcu_hash_new(rcu_compile_table_cfg_free, NULL, 0); compile_rt->tbl_cfg_hash = rcu_hash_new(rcu_compile_table_cfg_free, NULL, 0);
@@ -612,7 +623,7 @@ void *group2compile_runtime_new(void *g2c_schema, size_t max_thread_num,
} }
struct group2compile_runtime *g2c_rt = ALLOC(struct group2compile_runtime, 1); struct group2compile_runtime *g2c_rt = ALLOC(struct group2compile_runtime, 1);
g2c_rt->not_clause_hash = NULL; g2c_rt->tbl_not_clause_hash = NULL;
return g2c_rt; return g2c_rt;
} }
@@ -631,14 +642,14 @@ void group2compile_runtime_free(void *g2c_runtime)
} }
struct group2compile_runtime *g2c_rt = (struct group2compile_runtime *)g2c_runtime; struct group2compile_runtime *g2c_rt = (struct group2compile_runtime *)g2c_runtime;
if (g2c_rt->not_clause_hash != NULL) { if (g2c_rt->tbl_not_clause_hash != NULL) {
struct table_not_clause *not_clause = NULL, *tmp_not_clause = NULL; struct table_clause *not_clause = NULL, *tmp_not_clause = NULL;
HASH_ITER(hh, g2c_rt->not_clause_hash, not_clause, tmp_not_clause) { HASH_ITER(hh, g2c_rt->tbl_not_clause_hash, not_clause, tmp_not_clause) {
HASH_DEL(g2c_rt->not_clause_hash, not_clause); HASH_DEL(g2c_rt->tbl_not_clause_hash, not_clause);
FREE(not_clause); FREE(not_clause);
} }
} }
assert(g2c_rt->not_clause_hash == NULL); assert(g2c_rt->tbl_not_clause_hash == NULL);
FREE(g2c_runtime); FREE(g2c_runtime);
} }
@@ -672,7 +683,7 @@ group2compile_item_new(const char *line, struct group2compile_schema *g2c_schema
int ret = get_column_pos(line, g2c_schema->group_id_column, &column_offset, int ret = get_column_pos(line, g2c_schema->group_id_column, &column_offset,
&column_len); &column_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_COMPILE, log_fatal(logger, MODULE_COMPILE,
"[%s:%d] g2c table:<%s> has no group_id in line:%s", "[%s:%d] g2c table:<%s> has no group_id in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -682,7 +693,7 @@ group2compile_item_new(const char *line, struct group2compile_schema *g2c_schema
ret = get_column_pos(line, g2c_schema->compile_id_column, &column_offset, ret = get_column_pos(line, g2c_schema->compile_id_column, &column_offset,
&column_len); &column_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_COMPILE, log_fatal(logger, MODULE_COMPILE,
"[%s:%d] g2c table:<%s> has no compile_id in line:%s", "[%s:%d] g2c table:<%s> has no compile_id in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -692,7 +703,7 @@ group2compile_item_new(const char *line, struct group2compile_schema *g2c_schema
ret = get_column_pos(line, g2c_schema->not_flag_column, &column_offset, ret = get_column_pos(line, g2c_schema->not_flag_column, &column_offset,
&column_len); &column_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_COMPILE, log_fatal(logger, MODULE_COMPILE,
"[%s:%d] g2c table:<%s> has no NOT_flag in line:%s ", "[%s:%d] g2c table:<%s> has no NOT_flag in line:%s ",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -701,7 +712,7 @@ group2compile_item_new(const char *line, struct group2compile_schema *g2c_schema
g2c_item->not_flag = atoi(line + column_offset); g2c_item->not_flag = atoi(line + column_offset);
if (g2c_item->not_flag != CLAUSE_NOT_FLAG_SET && if (g2c_item->not_flag != CLAUSE_NOT_FLAG_SET &&
g2c_item->not_flag != CLAUSE_NOT_FLAG_UNSET) { g2c_item->not_flag != CLAUSE_NOT_FLAG_UNSET) {
log_error(logger, MODULE_COMPILE, log_fatal(logger, MODULE_COMPILE,
"[%s:%d] g2c table:<%s> NOT_flag:%d is illegal in line:%s ", "[%s:%d] g2c table:<%s> NOT_flag:%d is illegal in line:%s ",
__FUNCTION__, __LINE__, table_name, g2c_item->not_flag, line); __FUNCTION__, __LINE__, table_name, g2c_item->not_flag, line);
goto error; goto error;
@@ -710,14 +721,14 @@ group2compile_item_new(const char *line, struct group2compile_schema *g2c_schema
ret = get_column_pos(line, g2c_schema->vtable_name_column, &column_offset, ret = get_column_pos(line, g2c_schema->vtable_name_column, &column_offset,
&column_len); &column_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_COMPILE, log_fatal(logger, MODULE_COMPILE,
"[%s:%d] g2c table:<%s> has no virtual_table_name in line:%s", "[%s:%d] g2c table:<%s> has no virtual_table_name in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
} }
if (column_len > MAX_NAME_STR_LEN) { if (column_len > MAX_NAME_STR_LEN) {
log_error(logger, MODULE_COMPILE, log_fatal(logger, MODULE_COMPILE,
"[%s:%d] g2c table:<%s> virtual_table_name length exceed " "[%s:%d] g2c table:<%s> virtual_table_name length exceed "
"maxium:%d in line:%s", __FUNCTION__, __LINE__, table_name, "maxium:%d in line:%s", __FUNCTION__, __LINE__, table_name,
MAX_NAME_STR_LEN, line); MAX_NAME_STR_LEN, line);
@@ -731,7 +742,7 @@ group2compile_item_new(const char *line, struct group2compile_schema *g2c_schema
g2c_item->vtable_id = table_manager_get_table_id(g2c_schema->ref_tbl_mgr, g2c_item->vtable_id = table_manager_get_table_id(g2c_schema->ref_tbl_mgr,
vtable_name); vtable_name);
if (g2c_item->vtable_id < 0) { if (g2c_item->vtable_id < 0) {
log_error(logger, MODULE_COMPILE, log_fatal(logger, MODULE_COMPILE,
"[%s:%d] g2c table:<%s> has unknown virtual table:%s in line:%s", "[%s:%d] g2c table:<%s> has unknown virtual table:%s in line:%s",
__FUNCTION__, __LINE__, table_name, vtable_name, line); __FUNCTION__, __LINE__, table_name, vtable_name, line);
goto error; goto error;
@@ -741,7 +752,7 @@ group2compile_item_new(const char *line, struct group2compile_schema *g2c_schema
ret = get_column_pos(line, g2c_schema->clause_index_column, &column_offset, ret = get_column_pos(line, g2c_schema->clause_index_column, &column_offset,
&column_len); &column_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_COMPILE, log_fatal(logger, MODULE_COMPILE,
"[%s:%d] g2c table:<%s> has no clause_index in line:%s", "[%s:%d] g2c table:<%s> has no clause_index in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -749,7 +760,7 @@ group2compile_item_new(const char *line, struct group2compile_schema *g2c_schema
g2c_item->clause_index = atoi(line + column_offset); g2c_item->clause_index = atoi(line + column_offset);
if (g2c_item->clause_index < 0 || g2c_item->clause_index >= MAX_NOT_CLAUSE_NUM) { if (g2c_item->clause_index < 0 || g2c_item->clause_index >= MAX_NOT_CLAUSE_NUM) {
log_error(logger, MODULE_COMPILE, log_fatal(logger, MODULE_COMPILE,
"[%s:%d] g2c table:<%s> clause_index:%d exceed maximum:%d in line:%s", "[%s:%d] g2c table:<%s> clause_index:%d exceed maximum:%d in line:%s",
__FUNCTION__, __LINE__, table_name, g2c_item->clause_index, __FUNCTION__, __LINE__, table_name, g2c_item->clause_index,
MAX_NOT_CLAUSE_NUM, line); MAX_NOT_CLAUSE_NUM, line);
@@ -910,7 +921,7 @@ maat_compile_bool_matcher_new(struct compile_runtime *compile_rt, size_t *compil
// STEP 3, build bool matcher // STEP 3, build bool matcher
size_t mem_size = 0; size_t mem_size = 0;
if (0 == expr_cnt) { if (0 == expr_cnt) {
log_error(compile_rt->logger, MODULE_COMPILE, log_fatal(compile_rt->logger, MODULE_COMPILE,
"[%s:%d] No bool expression to build bool matcher.", "[%s:%d] No bool expression to build bool matcher.",
__FUNCTION__, __LINE__); __FUNCTION__, __LINE__);
FREE(bool_expr_array); FREE(bool_expr_array);
@@ -923,7 +934,7 @@ maat_compile_bool_matcher_new(struct compile_runtime *compile_rt, size_t *compil
"Build bool matcher of %zu expressions with %zu bytes memory.", "Build bool matcher of %zu expressions with %zu bytes memory.",
expr_cnt, mem_size); expr_cnt, mem_size);
} else { } else {
log_error(compile_rt->logger, MODULE_COMPILE, log_fatal(compile_rt->logger, MODULE_COMPILE,
"[%s:%d] Build bool matcher failed!", __FUNCTION__, __LINE__); "[%s:%d] Build bool matcher failed!", __FUNCTION__, __LINE__);
} }
@@ -1058,17 +1069,28 @@ static int maat_compile_has_clause(struct maat_compile *compile, long long claus
static size_t compile_state_if_new_hit_compile(struct compile_state *compile_state, static size_t compile_state_if_new_hit_compile(struct compile_state *compile_state,
struct maat_compile *compile) struct maat_compile *compile)
{ {
size_t i = 0;
size_t r_in_c_cnt = 0; size_t r_in_c_cnt = 0;
int ret = 0; int ret = 0;
long long new_hit_clause_id = 0; long long new_hit_clause_id = 0;
for (size_t i = 0; i < utarray_len(compile_state->this_scan_hit_clauses); i++) { if (0 == compile_state->this_scan_not_logic) {
for (i = 0; i < utarray_len(compile_state->this_scan_hit_clauses); i++) {
new_hit_clause_id = *(long long*)utarray_eltptr(compile_state->this_scan_hit_clauses, i); new_hit_clause_id = *(long long*)utarray_eltptr(compile_state->this_scan_hit_clauses, i);
ret = maat_compile_has_clause(compile, new_hit_clause_id); ret = maat_compile_has_clause(compile, new_hit_clause_id);
if (ret) { if (ret) {
r_in_c_cnt++; r_in_c_cnt++;
} }
} }
} else {
for (i = 0; i < utarray_len(compile_state->this_scan_hit_not_clauses); i++) {
new_hit_clause_id = *(long long*)utarray_eltptr(compile_state->this_scan_hit_not_clauses, i);
ret = maat_compile_has_clause(compile, new_hit_clause_id);
if (ret) {
r_in_c_cnt++;
}
}
}
return r_in_c_cnt; return r_in_c_cnt;
} }
@@ -1104,7 +1126,7 @@ static size_t maat_compile_bool_matcher_match(struct compile_runtime *compile_rt
size_t ud_result_cnt = 0; size_t ud_result_cnt = 0;
struct maat_compile *compile = NULL; struct maat_compile *compile = NULL;
struct bool_expr_match *expr_match = compile_rt->expr_match_buff + struct bool_expr_match *expr_match = compile_rt->expr_match_buff +
(thread_id * MAX_SCANNER_HIT_COMPILE_NUM); (thread_id * MAX_HIT_COMPILE_NUM);
assert(thread_id >= 0); assert(thread_id >= 0);
if (0 == compile_state->compile_rt_version) { if (0 == compile_state->compile_rt_version) {
@@ -1128,7 +1150,7 @@ static size_t maat_compile_bool_matcher_match(struct compile_runtime *compile_rt
int bool_match_ret = bool_matcher_match(compile_rt->bm, int bool_match_ret = bool_matcher_match(compile_rt->bm,
(unsigned long long *)utarray_eltptr(compile_state->all_hit_clauses, 0), (unsigned long long *)utarray_eltptr(compile_state->all_hit_clauses, 0),
utarray_len(compile_state->all_hit_clauses), utarray_len(compile_state->all_hit_clauses),
expr_match, MAX_SCANNER_HIT_COMPILE_NUM); expr_match, MAX_HIT_COMPILE_NUM);
for (int i = 0; i < bool_match_ret && ud_result_cnt < ud_array_size; i++) { for (int i = 0; i < bool_match_ret && ud_result_cnt < ud_array_size; i++) {
compile = (struct maat_compile *)expr_match[i].user_tag; compile = (struct maat_compile *)expr_match[i].user_tag;
assert(compile->magic_num == MAAT_COMPILE_MAGIC); assert(compile->magic_num == MAAT_COMPILE_MAGIC);
@@ -1214,7 +1236,7 @@ static int maat_add_group_to_compile(struct rcu_hash_table *hash_tbl,
ret = maat_compile_clause_add_literal(compile, &literal_id, g2c_item->clause_index, ret = maat_compile_clause_add_literal(compile, &literal_id, g2c_item->clause_index,
g2c_item->not_flag); g2c_item->not_flag);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_COMPILE, log_fatal(logger, MODULE_COMPILE,
"[%s:%d] add literal_id{group_id:%lld, vtable_id:%d} to clause_index: %d" "[%s:%d] add literal_id{group_id:%lld, vtable_id:%d} to clause_index: %d"
" of compile %d failed", __FUNCTION__, __LINE__, g2c_item->group_id, " of compile %d failed", __FUNCTION__, __LINE__, g2c_item->group_id,
g2c_item->vtable_id, g2c_item->clause_index, compile_id); g2c_item->vtable_id, g2c_item->clause_index, compile_id);
@@ -1226,7 +1248,7 @@ static int maat_add_group_to_compile(struct rcu_hash_table *hash_tbl,
ret = maat_compile_clause_add_literal(compile, &literal_id, g2c_item->clause_index, ret = maat_compile_clause_add_literal(compile, &literal_id, g2c_item->clause_index,
g2c_item->not_flag); g2c_item->not_flag);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_COMPILE, log_fatal(logger, MODULE_COMPILE,
"[%s:%d] add literal_id{group_id:%lld, vtable_id:%d} to clause_index: %d" "[%s:%d] add literal_id{group_id:%lld, vtable_id:%d} to clause_index: %d"
" of compile %d failed", __FUNCTION__, __LINE__, g2c_item->group_id, " of compile %d failed", __FUNCTION__, __LINE__, g2c_item->group_id,
g2c_item->vtable_id, g2c_item->clause_index, compile_id); g2c_item->vtable_id, g2c_item->clause_index, compile_id);
@@ -1254,7 +1276,7 @@ static int maat_add_group_to_compile(struct rcu_hash_table *hash_tbl,
ret = maat_compile_clause_add_literal(copy_compile, &literal_id, g2c_item->clause_index, ret = maat_compile_clause_add_literal(copy_compile, &literal_id, g2c_item->clause_index,
g2c_item->not_flag); g2c_item->not_flag);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_COMPILE, log_fatal(logger, MODULE_COMPILE,
"[%s:%d] add literal_id{group_id:%lld, vtable_id:%d} to clause_index: %d" "[%s:%d] add literal_id{group_id:%lld, vtable_id:%d} to clause_index: %d"
" of compile %d failed", __FUNCTION__, __LINE__, g2c_item->group_id, " of compile %d failed", __FUNCTION__, __LINE__, g2c_item->group_id,
g2c_item->vtable_id, g2c_item->clause_index, compile_id); g2c_item->vtable_id, g2c_item->clause_index, compile_id);
@@ -1267,7 +1289,7 @@ static int maat_add_group_to_compile(struct rcu_hash_table *hash_tbl,
ret = maat_compile_clause_add_literal(compile, &literal_id, g2c_item->clause_index, ret = maat_compile_clause_add_literal(compile, &literal_id, g2c_item->clause_index,
g2c_item->not_flag); g2c_item->not_flag);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_COMPILE, log_fatal(logger, MODULE_COMPILE,
"[%s:%d] add literal_id{group_id:%lld, vtable_id:%d} to clause_index: %d" "[%s:%d] add literal_id{group_id:%lld, vtable_id:%d} to clause_index: %d"
" of compile %d failed", __FUNCTION__, __LINE__, g2c_item->group_id, " of compile %d failed", __FUNCTION__, __LINE__, g2c_item->group_id,
g2c_item->vtable_id, g2c_item->clause_index, compile_id); g2c_item->vtable_id, g2c_item->clause_index, compile_id);
@@ -1294,7 +1316,7 @@ static int maat_remove_group_from_compile(struct rcu_hash_table *hash_tbl,
compile = rcu_updating_hash_find(hash_tbl, (char *)&compile_id, compile = rcu_updating_hash_find(hash_tbl, (char *)&compile_id,
sizeof(long long)); sizeof(long long));
if (NULL == compile) { if (NULL == compile) {
log_error(logger, MODULE_COMPILE, log_fatal(logger, MODULE_COMPILE,
"[%s:%d] Remove group_id:%lld from compile_id:%lld failed, compile" "[%s:%d] Remove group_id:%lld from compile_id:%lld failed, compile"
" is not existed.", __FUNCTION__, __LINE__, g2c_item->group_id, " is not existed.", __FUNCTION__, __LINE__, g2c_item->group_id,
compile_id); compile_id);
@@ -1304,7 +1326,7 @@ static int maat_remove_group_from_compile(struct rcu_hash_table *hash_tbl,
ret = maat_compile_clause_remove_literal(compile, &literal_id, ret = maat_compile_clause_remove_literal(compile, &literal_id,
g2c_item->clause_index); g2c_item->clause_index);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_COMPILE, log_fatal(logger, MODULE_COMPILE,
"[%s:%d] Remove group_id:%lld vtable_id %d from clause %d of " "[%s:%d] Remove group_id:%lld vtable_id %d from clause %d of "
"compile_id:%lld failed, literal is not in compile.", __FUNCTION__, "compile_id:%lld failed, literal is not in compile.", __FUNCTION__,
__LINE__, g2c_item->group_id, g2c_item->vtable_id, __LINE__, g2c_item->group_id, g2c_item->vtable_id,
@@ -1337,7 +1359,7 @@ static int maat_remove_group_from_compile(struct rcu_hash_table *hash_tbl,
ret = maat_compile_clause_remove_literal(copy_compile, &literal_id, ret = maat_compile_clause_remove_literal(copy_compile, &literal_id,
g2c_item->clause_index); g2c_item->clause_index);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_COMPILE, log_fatal(logger, MODULE_COMPILE,
"[%s:%d] Remove group_id:%lld vtable_id %d from clause %d of compile_id:" "[%s:%d] Remove group_id:%lld vtable_id %d from clause %d of compile_id:"
"%lld failed, literal is not in compile.", __FUNCTION__, __LINE__, "%lld failed, literal is not in compile.", __FUNCTION__, __LINE__,
g2c_item->group_id, g2c_item->vtable_id, g2c_item->clause_index, g2c_item->group_id, g2c_item->vtable_id, g2c_item->clause_index,
@@ -1350,7 +1372,7 @@ static int maat_remove_group_from_compile(struct rcu_hash_table *hash_tbl,
rcu_hash_add(hash_tbl, (char *)&compile_id, sizeof(long long), copy_compile); rcu_hash_add(hash_tbl, (char *)&compile_id, sizeof(long long), copy_compile);
} }
} else { } else {
log_error(logger, MODULE_COMPILE, log_fatal(logger, MODULE_COMPILE,
"[%s:%d] Remove group_id:%lld from compile_id:%lld failed, " "[%s:%d] Remove group_id:%lld from compile_id:%lld failed, "
"compile is not existed.", __FUNCTION__, __LINE__, "compile is not existed.", __FUNCTION__, __LINE__,
g2c_item->group_id, compile_id); g2c_item->group_id, compile_id);
@@ -1368,28 +1390,58 @@ struct compile_state *compile_state_new(void)
utarray_new(compile_state->internal_hit_paths, &ut_hit_path_icd); utarray_new(compile_state->internal_hit_paths, &ut_hit_path_icd);
utarray_new(compile_state->all_hit_clauses, &ut_clause_id_icd); utarray_new(compile_state->all_hit_clauses, &ut_clause_id_icd);
utarray_new(compile_state->this_scan_hit_clauses, &ut_clause_id_icd); utarray_new(compile_state->this_scan_hit_clauses, &ut_clause_id_icd);
utarray_new(compile_state->this_scan_hit_not_clauses, &ut_clause_id_icd);
utarray_new(compile_state->direct_hit_groups, &ut_maat_hit_group_icd); utarray_new(compile_state->direct_hit_groups, &ut_maat_hit_group_icd);
utarray_new(compile_state->indirect_hit_groups, &ut_maat_hit_group_icd); utarray_new(compile_state->indirect_hit_groups, &ut_maat_hit_group_icd);
utarray_new(compile_state->hit_compile_table_ids, &ut_hit_compile_table_id_icd); utarray_new(compile_state->hit_compile_table_ids, &ut_hit_compile_table_id_icd);
compile_state->hit_not_groups = NULL;
return compile_state; return compile_state;
} }
static long long compile_state_hit_not_groups_free(struct compile_state *compile_state)
{
if (NULL == compile_state) {
return 0;
}
long long free_bytes = 0;
struct table_group *tbl_group = NULL, *tmp_tbl_group = NULL;
HASH_ITER(hh, compile_state->hit_not_groups, tbl_group, tmp_tbl_group) {
free_bytes += (sizeof(tbl_group) + utarray_len(tbl_group->group_ids) * sizeof(long long));
HASH_DEL(compile_state->hit_not_groups, tbl_group);
if (tbl_group->group_ids != NULL) {
utarray_free(tbl_group->group_ids);
tbl_group->group_ids = NULL;
}
FREE(tbl_group);
}
return free_bytes;
}
void compile_state_reset(struct compile_state *compile_state) void compile_state_reset(struct compile_state *compile_state)
{ {
if (NULL == compile_state) { if (NULL == compile_state) {
return; return;
} }
compile_state->this_scan_not_logic = 0;
compile_state->Nth_scan = 0; compile_state->Nth_scan = 0;
compile_state->compile_rt_version = 0; compile_state->compile_rt_version = 0;
utarray_clear(compile_state->internal_hit_paths); utarray_clear(compile_state->internal_hit_paths);
utarray_clear(compile_state->all_hit_clauses); utarray_clear(compile_state->all_hit_clauses);
utarray_clear(compile_state->this_scan_hit_clauses); utarray_clear(compile_state->this_scan_hit_clauses);
utarray_clear(compile_state->this_scan_hit_not_clauses);
utarray_clear(compile_state->direct_hit_groups); utarray_clear(compile_state->direct_hit_groups);
utarray_clear(compile_state->indirect_hit_groups); utarray_clear(compile_state->indirect_hit_groups);
utarray_clear(compile_state->hit_compile_table_ids); utarray_clear(compile_state->hit_compile_table_ids);
struct table_group *tbl_group = NULL, *tmp_tbl_group = NULL;
HASH_ITER(hh, compile_state->hit_not_groups, tbl_group, tmp_tbl_group) {
utarray_clear(tbl_group->group_ids);
}
} }
void compile_state_free(struct compile_state *compile_state, void compile_state_free(struct compile_state *compile_state,
@@ -1419,6 +1471,12 @@ void compile_state_free(struct compile_state *compile_state,
compile_state->this_scan_hit_clauses = NULL; compile_state->this_scan_hit_clauses = NULL;
} }
if (compile_state->this_scan_hit_not_clauses != NULL) {
free_bytes += utarray_size(compile_state->this_scan_hit_not_clauses) * sizeof(long long);
utarray_free(compile_state->this_scan_hit_not_clauses);
compile_state->this_scan_hit_not_clauses = NULL;
}
if (compile_state->direct_hit_groups != NULL) { if (compile_state->direct_hit_groups != NULL) {
free_bytes += utarray_size(compile_state->direct_hit_groups) * sizeof(struct maat_hit_group); free_bytes += utarray_size(compile_state->direct_hit_groups) * sizeof(struct maat_hit_group);
utarray_free(compile_state->direct_hit_groups); utarray_free(compile_state->direct_hit_groups);
@@ -1437,6 +1495,8 @@ void compile_state_free(struct compile_state *compile_state,
compile_state->hit_compile_table_ids = NULL; compile_state->hit_compile_table_ids = NULL;
} }
free_bytes += compile_state_hit_not_groups_free(compile_state);
FREE(compile_state); FREE(compile_state);
free_bytes += sizeof(struct compile_state); free_bytes += sizeof(struct compile_state);
@@ -1444,11 +1504,11 @@ void compile_state_free(struct compile_state *compile_state,
thread_id, free_bytes); thread_id, free_bytes);
} }
static void add_internal_hit_path(UT_array *hit_paths, long long item_id, static void compile_state_add_internal_hit_path(struct compile_state *compile_state,
long long group_id, int vtable_id, int NOT_flag, long long item_id, long long group_id,
int Nth_scan) int vtable_id, int NOT_flag, int Nth_scan)
{ {
if (NULL == hit_paths || utarray_len(hit_paths) >= MAX_HIT_PATH_NUM) { if (NULL == compile_state) {
return; return;
} }
@@ -1459,7 +1519,7 @@ static void add_internal_hit_path(UT_array *hit_paths, long long item_id,
new_path.vtable_id = vtable_id; new_path.vtable_id = vtable_id;
new_path.NOT_flag = NOT_flag; new_path.NOT_flag = NOT_flag;
utarray_push_back(hit_paths, &new_path); utarray_push_back(compile_state->internal_hit_paths, &new_path);
} }
static int maat_compile_has_literal(struct maat_compile *compile, static int maat_compile_has_literal(struct maat_compile *compile,
@@ -1508,7 +1568,7 @@ size_t compile_runtime_get_hit_paths(struct compile_runtime *compile_rt, int thr
struct maat_compile *compile = NULL; struct maat_compile *compile = NULL;
struct literal_id literal_id = {0, 0}; struct literal_id literal_id = {0, 0};
struct bool_expr_match *expr_match = compile_rt->expr_match_buff + struct bool_expr_match *expr_match = compile_rt->expr_match_buff +
(thread_id * MAX_SCANNER_HIT_COMPILE_NUM); (thread_id * MAX_HIT_COMPILE_NUM);
assert(thread_id >= 0); assert(thread_id >= 0);
if (compile_state->compile_rt_version != compile_rt->version) { if (compile_state->compile_rt_version != compile_rt->version) {
@@ -1517,8 +1577,8 @@ size_t compile_runtime_get_hit_paths(struct compile_runtime *compile_rt, int thr
int bool_match_ret = bool_matcher_match(compile_rt->bm, int bool_match_ret = bool_matcher_match(compile_rt->bm,
(unsigned long long *)utarray_eltptr(compile_state->all_hit_clauses, 0), (unsigned long long *)utarray_eltptr(compile_state->all_hit_clauses, 0),
utarray_len(compile_state->all_hit_clauses), expr_match, utarray_len(compile_state->all_hit_clauses), expr_match, MAX_HIT_COMPILE_NUM);
MAX_SCANNER_HIT_COMPILE_NUM);
for (int idx = 0; idx < bool_match_ret; idx++) { for (int idx = 0; idx < bool_match_ret; idx++) {
compile = (struct maat_compile *)expr_match[idx].user_tag; compile = (struct maat_compile *)expr_match[idx].user_tag;
assert(compile->magic_num == MAAT_COMPILE_MAGIC); assert(compile->magic_num == MAAT_COMPILE_MAGIC);
@@ -1620,6 +1680,33 @@ static void compile_state_add_hit_clauses(struct compile_state *compile_state,
} }
} }
static void compile_state_add_hit_not_clauses(struct compile_state *compile_state,
UT_array *clause_id_array)
{
size_t i = 0;
long long *clause_id = NULL;
size_t new_clause_idx = utarray_len(compile_state->this_scan_hit_not_clauses);
for (i = 0; i < utarray_len(clause_id_array); i++) {
clause_id = (long long *)utarray_eltptr(clause_id_array, i);
if (utarray_find(compile_state->all_hit_clauses, clause_id, compare_clause_id)) {
continue;
}
utarray_push_back(compile_state->this_scan_hit_not_clauses, clause_id);
}
if ((utarray_len(compile_state->this_scan_hit_not_clauses) - new_clause_idx) > 0) {
utarray_reserve(compile_state->all_hit_clauses,
utarray_len(compile_state->this_scan_hit_not_clauses) - new_clause_idx);
for (i = new_clause_idx; i < utarray_len(compile_state->this_scan_hit_not_clauses); i++) {
clause_id = (long long *)utarray_eltptr(compile_state->this_scan_hit_not_clauses, i);
utarray_push_back(compile_state->all_hit_clauses, clause_id);
}
utarray_sort(compile_state->all_hit_clauses, compare_clause_id);
}
}
static void compile_state_update_hit_clauses(struct compile_state *compile_state, static void compile_state_update_hit_clauses(struct compile_state *compile_state,
struct compile_runtime *compile_rt, struct compile_runtime *compile_rt,
long long group_id, int vtable_id) long long group_id, int vtable_id)
@@ -1653,43 +1740,58 @@ static inline int compare_group_id(const void *a, const void *b)
} }
} }
static size_t compile_state_update_hit_not_clauses(struct compile_state *compile_state, static void compile_state_cache_hit_not_groups(struct compile_state *compile_state,
struct compile_runtime *compile_rt, struct compile_runtime *compile_rt,
long long *group_ids, size_t n_group_ids, long long *hit_group_ids,
int vtable_id, long long *NOT_group_ids_array, size_t n_hit_group_id, int vtable_id)
size_t NOT_group_ids_array_size)
{ {
if (NULL == compile_state || NULL == compile_rt) { if (NULL == compile_state || NULL == compile_rt) {
return 0; return;
} }
if (n_group_ids != 0) { if (n_hit_group_id != 0) {
qsort(group_ids, n_group_ids, sizeof(long long *), compare_group_id); qsort(hit_group_ids, n_hit_group_id, sizeof(long long *), compare_group_id);
}
struct table_group *tbl_group = NULL;
HASH_FIND(hh, compile_state->hit_not_groups, &vtable_id, sizeof(int), tbl_group);
if (tbl_group != NULL) {
for (size_t i = 0; i < n_hit_group_id; i++) {
long long *group_id = (long long *)utarray_find(tbl_group->group_ids,
&hit_group_ids[i],
compare_group_id);
if (NULL == group_id) {
continue;
}
size_t remove_idx = utarray_eltidx(tbl_group->group_ids, group_id);
utarray_erase(tbl_group->group_ids, remove_idx, 1);
}
} }
size_t hit_NOT_group_cnt = 0;
struct literal_clause *l2c_val = NULL, *tmp_l2c_val = NULL; struct literal_clause *l2c_val = NULL, *tmp_l2c_val = NULL;
//NOTE: Each virtual table can reference up to VTABLE_MAX_NOT_GROUP_NUM groups
HASH_ITER(hh, compile_rt->literal2not_clause_hash, l2c_val, tmp_l2c_val) { HASH_ITER(hh, compile_rt->literal2not_clause_hash, l2c_val, tmp_l2c_val) {
if (l2c_val->key.vtable_id != vtable_id) { if (l2c_val->key.vtable_id != vtable_id) {
continue; continue;
} }
long long *tmp_group_id = bsearch(&(l2c_val->key.group_id), group_ids, n_group_ids, long long *tmp_group_id = bsearch(&(l2c_val->key.group_id), hit_group_ids,
sizeof(long long), compare_group_id); n_hit_group_id, sizeof(long long), compare_group_id);
if (tmp_group_id != NULL) { if (tmp_group_id != NULL) {
continue; continue;
} }
if (hit_NOT_group_cnt < NOT_group_ids_array_size) { if (NULL == tbl_group) {
NOT_group_ids_array[hit_NOT_group_cnt++] = l2c_val->key.group_id; tbl_group = ALLOC(struct table_group, 1);
tbl_group->vtable_id = vtable_id;
utarray_new(tbl_group->group_ids, &ut_compile_group_id_icd);
HASH_ADD_INT(compile_state->hit_not_groups, vtable_id, tbl_group);
} }
compile_state_add_hit_clauses(compile_state, l2c_val->clause_ids); if (!utarray_find(tbl_group->group_ids, &(l2c_val->key.group_id), compare_group_id)) {
utarray_push_back(tbl_group->group_ids, &(l2c_val->key.group_id));
utarray_sort(tbl_group->group_ids, compare_group_id);
}
} }
return hit_NOT_group_cnt;
} }
int compile_state_get_compile_table_id(struct compile_state *compile_state, int compile_state_get_compile_table_id(struct compile_state *compile_state,
@@ -1853,7 +1955,7 @@ int compile_runtime_update(void *compile_runtime, void *compile_schema,
struct compile_runtime *compile_rt = (struct compile_runtime *)compile_runtime; struct compile_runtime *compile_rt = (struct compile_runtime *)compile_runtime;
int is_valid = get_column_value(line, valid_column); int is_valid = get_column_value(line, valid_column);
if (is_valid < 0) { if (is_valid < 0) {
log_error(compile_rt->logger, MODULE_COMPILE, log_fatal(compile_rt->logger, MODULE_COMPILE,
"[%s:%d] compile table:<%s> has no is_valid(column seq:%d)" "[%s:%d] compile table:<%s> has no is_valid(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name, " in table_line:%s", __FUNCTION__, __LINE__, table_name,
valid_column, line); valid_column, line);
@@ -1863,7 +1965,7 @@ int compile_runtime_update(void *compile_runtime, void *compile_schema,
long long compile_id = get_column_value(line, schema->compile_id_column); long long compile_id = get_column_value(line, schema->compile_id_column);
if (compile_id < 0) { if (compile_id < 0) {
log_error(compile_rt->logger, MODULE_COMPILE, log_fatal(compile_rt->logger, MODULE_COMPILE,
"[%s:%d] compile table:<%s> has no compile_id(column seq:%d)" "[%s:%d] compile table:<%s> has no compile_id(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name, " in table_line:%s", __FUNCTION__, __LINE__, table_name,
schema->compile_id_column, line); schema->compile_id_column, line);
@@ -1899,32 +2001,32 @@ static int validate_table_not_clause(struct group2compile_runtime *g2c_rt,
struct table_manager *tbl_mgr, int table_id, struct table_manager *tbl_mgr, int table_id,
int is_valid, struct log_handle *logger) int is_valid, struct log_handle *logger)
{ {
struct table_not_clause *not_clause = NULL; struct table_clause *not_clause = NULL;
HASH_FIND_INT(g2c_rt->not_clause_hash, &table_id, not_clause); HASH_FIND_INT(g2c_rt->tbl_not_clause_hash, &table_id, not_clause);
if (0 == is_valid) { if (0 == is_valid) {
//delete //delete
if (NULL == not_clause || 0 == not_clause->not_clause_num) { if (NULL == not_clause || 0 == not_clause->actual_clause_num) {
return 0; return 0;
} else { } else {
not_clause->not_clause_num--; not_clause->actual_clause_num--;
} }
} else { } else {
//add //add
if (NULL == not_clause) { if (NULL == not_clause) {
not_clause = ALLOC(struct table_not_clause, 1); not_clause = ALLOC(struct table_clause, 1);
not_clause->table_id = table_id; not_clause->vtable_id = table_id;
not_clause->not_clause_num++; not_clause->actual_clause_num++;
HASH_ADD_INT(g2c_rt->not_clause_hash, table_id, not_clause); HASH_ADD_INT(g2c_rt->tbl_not_clause_hash, vtable_id, not_clause);
} else { } else {
if (not_clause->not_clause_num >= MAX_NOT_CLAUSE_NUM) { if (not_clause->actual_clause_num >= MAX_NOT_CLAUSE_NUM) {
const char *table_name = table_manager_get_table_name(tbl_mgr, table_id); const char *table_name = table_manager_get_table_name(tbl_mgr, table_id);
log_fatal(logger, MODULE_COMPILE, log_fatal(logger, MODULE_COMPILE,
"[%s:%d]table:<%s> NOT clause num exceed maximum:%d", "[%s:%d]table:<%s> NOT clause num exceed maximum:%d",
__FUNCTION__, __LINE__, table_name, MAX_NOT_CLAUSE_NUM); __FUNCTION__, __LINE__, table_name, MAX_NOT_CLAUSE_NUM);
return -1; return -1;
} }
not_clause->not_clause_num++; not_clause->actual_clause_num++;
} }
} }
@@ -1945,7 +2047,7 @@ int group2compile_runtime_update(void *g2c_runtime, void *g2c_schema,
int is_valid = get_column_value(line, valid_column); int is_valid = get_column_value(line, valid_column);
if (is_valid < 0) { if (is_valid < 0) {
log_error(compile_rt->logger, MODULE_COMPILE, log_fatal(compile_rt->logger, MODULE_COMPILE,
"[%s:%d] g2c table:<%s> has no is_valid(column seq:%d)" "[%s:%d] g2c table:<%s> has no is_valid(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name, " in table_line:%s", __FUNCTION__, __LINE__, table_name,
valid_column, line); valid_column, line);
@@ -2061,7 +2163,7 @@ int compile_runtime_commit(void *compile_runtime, const char *table_name,
(end.tv_nsec - start.tv_nsec) / 1000000; (end.tv_nsec - start.tv_nsec) / 1000000;
if (NULL == new_bool_matcher) { if (NULL == new_bool_matcher) {
log_error(compile_rt->logger, MODULE_COMPILE, log_fatal(compile_rt->logger, MODULE_COMPILE,
"[%s:%d] table[%s] rebuild compile bool_matcher failed, compile" "[%s:%d] table[%s] rebuild compile bool_matcher failed, compile"
" rules count:%zu", __FUNCTION__, __LINE__, table_name, compile_cnt); " rules count:%zu", __FUNCTION__, __LINE__, table_name, compile_cnt);
ret = -1; ret = -1;
@@ -2190,23 +2292,17 @@ int compile_runtime_match(struct compile_runtime *compile_rt, long long *compile
return MIN(bool_match_ret, compile_ids_size); return MIN(bool_match_ret, compile_ids_size);
} }
int compile_state_update(int vtable_id, struct maat_item *hit_items, int compile_state_update(struct compile_state *compile_state, struct maat *maat_inst,
size_t n_hit_item, struct maat_state *state) int vtable_id, int custom_compile_tbl_id, int Nth_scan,
struct maat_item *hit_items, size_t n_hit_item)
{ {
size_t i = 0, j = 0; size_t i = 0, j = 0;
size_t hit_cnt = n_hit_item; size_t hit_cnt = n_hit_item;
long long hit_group_ids[MAX_SCANNER_HIT_GROUP_NUM]; long long hit_group_ids[MAX_HIT_GROUP_NUM];
struct maat *maat_inst = state->maat_inst;
if (NULL == state->compile_state) {
state->compile_state = compile_state_new();
alignment_int64_array_add(maat_inst->stat->compile_state_cnt,
state->thread_id, 1);
}
struct compile_state *compile_state = state->compile_state;
utarray_clear(compile_state->this_scan_hit_clauses); utarray_clear(compile_state->this_scan_hit_clauses);
compile_state->Nth_scan = state->scan_cnt; compile_state->this_scan_not_logic = 0;
compile_state->Nth_scan = Nth_scan;
for (i = 0; i < hit_cnt; i++) { for (i = 0; i < hit_cnt; i++) {
hit_group_ids[i] = hit_items[i].group_id; hit_group_ids[i] = hit_items[i].group_id;
@@ -2215,14 +2311,15 @@ int compile_state_update(int vtable_id, struct maat_item *hit_items,
int g2g_table_id = table_manager_get_group2group_table_id(maat_inst->tbl_mgr); int g2g_table_id = table_manager_get_group2group_table_id(maat_inst->tbl_mgr);
void *g2g_rt = table_manager_get_runtime(maat_inst->tbl_mgr, g2g_table_id); void *g2g_rt = table_manager_get_runtime(maat_inst->tbl_mgr, g2g_table_id);
long long super_group_ids[MAX_SCANNER_HIT_GROUP_NUM]; long long super_group_ids[MAX_HIT_GROUP_NUM];
size_t super_group_cnt = group2group_runtime_get_super_groups(g2g_rt, hit_group_ids, size_t super_group_cnt = group2group_runtime_get_super_groups(g2g_rt, hit_group_ids,
hit_cnt, super_group_ids, hit_cnt, super_group_ids,
MAX_SCANNER_HIT_GROUP_NUM); MAX_HIT_GROUP_NUM);
if (1 == maat_inst->opts.hit_path_on && hit_cnt > 0) { if (1 == maat_inst->opts.hit_path_on && hit_cnt > 0) {
for (i = 0; i < hit_cnt; i++) { for (i = 0; i < hit_cnt; i++) {
add_internal_hit_path(compile_state->internal_hit_paths, hit_items[i].item_id, compile_state_add_internal_hit_path(compile_state, hit_items[i].item_id,
hit_items[i].group_id, vtable_id, 0, state->scan_cnt); hit_items[i].group_id, vtable_id,
0, Nth_scan);
} }
} }
@@ -2234,8 +2331,8 @@ int compile_state_update(int vtable_id, struct maat_item *hit_items,
/* update hit clause */ /* update hit clause */
int compile_table_id = table_manager_get_default_compile_table_id(maat_inst->tbl_mgr); int compile_table_id = table_manager_get_default_compile_table_id(maat_inst->tbl_mgr);
if (state->compile_table_id > 0) { if (custom_compile_tbl_id > 0) {
compile_table_id = state->compile_table_id; compile_table_id = custom_compile_tbl_id;
} }
struct compile_runtime *compile_rt = table_manager_get_runtime(maat_inst->tbl_mgr, struct compile_runtime *compile_rt = table_manager_get_runtime(maat_inst->tbl_mgr,
@@ -2244,28 +2341,56 @@ int compile_state_update(int vtable_id, struct maat_item *hit_items,
return 0; return 0;
} }
for (j = 0; j < super_group_cnt && hit_cnt < MAX_SCANNER_HIT_GROUP_NUM; j++) { for (j = 0; j < super_group_cnt && hit_cnt < MAX_HIT_GROUP_NUM; j++) {
hit_group_ids[hit_cnt++] = super_group_ids[j]; hit_group_ids[hit_cnt++] = super_group_ids[j];
} }
for (i = 0; i < hit_cnt; i++) { for (i = 0; i < hit_cnt; i++) {
compile_state_update_hit_clauses(state->compile_state, compile_rt, compile_state_update_hit_clauses(compile_state, compile_rt,
hit_group_ids[i], vtable_id); hit_group_ids[i], vtable_id);
} }
long long hit_NOT_group_ids[VTABLE_MAX_NOT_GROUP_NUM]; compile_state_cache_hit_not_groups(compile_state, compile_rt, hit_group_ids,
size_t hit_not_cnt = compile_state_update_hit_not_clauses(state->compile_state, compile_rt, hit_cnt, vtable_id);
hit_group_ids, hit_cnt, vtable_id, return hit_cnt;
hit_NOT_group_ids, VTABLE_MAX_NOT_GROUP_NUM); }
if (1 == maat_inst->opts.hit_path_on && hit_not_cnt > 0) { void compile_state_not_logic_update(struct compile_state *compile_state,
for (i = 0; i < hit_not_cnt; i++) { struct compile_runtime *compile_rt,
add_internal_hit_path(compile_state->internal_hit_paths, -1, hit_NOT_group_ids[i], struct maat *maat_inst, int vtable_id,
vtable_id, 1, state->scan_cnt); int Nth_scan)
} {
if (NULL == compile_state || NULL == maat_inst) {
return;
} }
return (hit_cnt + hit_not_cnt); compile_state->this_scan_not_logic = 1;
compile_state->Nth_scan = Nth_scan;
utarray_clear(compile_state->this_scan_hit_not_clauses);
struct table_group *tbl_group = NULL;
HASH_FIND(hh, compile_state->hit_not_groups, &vtable_id, sizeof(int), tbl_group);
if (NULL == tbl_group) {
return;
}
struct literal_clause *l2c_val = NULL;
for (size_t i = 0; i < utarray_len(tbl_group->group_ids); i++) {
long long *group_id = utarray_eltptr(tbl_group->group_ids, i);
struct literal_id literal_id = {*group_id, vtable_id, 1};
HASH_FIND(hh, compile_rt->literal2not_clause_hash, &literal_id,
sizeof(struct literal_id), l2c_val);
if (NULL == l2c_val) {
continue;
}
compile_state_add_hit_not_clauses(compile_state, l2c_val->clause_ids);
if (1 == maat_inst->opts.hit_path_on) {
compile_state_add_internal_hit_path(compile_state, -1, *group_id,
vtable_id, 1, Nth_scan);
}
}
} }
size_t compile_state_get_indirect_hit_groups(struct compile_state *compile_state, size_t compile_state_get_indirect_hit_groups(struct compile_state *compile_state,
@@ -2332,7 +2457,6 @@ size_t compile_state_get_direct_hit_group_cnt(struct compile_state *compile_stat
return utarray_len(compile_state->direct_hit_groups); return utarray_len(compile_state->direct_hit_groups);
} }
UT_icd ut_compile_group_id_icd = {sizeof(long long), NULL, NULL, NULL};
size_t compile_state_get_internal_hit_paths(struct compile_state *compile_state, size_t compile_state_get_internal_hit_paths(struct compile_state *compile_state,
struct compile_runtime *compile_rt, struct compile_runtime *compile_rt,
struct group2group_runtime *g2g_rt, struct group2group_runtime *g2g_rt,
@@ -2347,12 +2471,12 @@ size_t compile_state_get_internal_hit_paths(struct compile_state *compile_state,
/* /*
NOTE: maybe one item has been deleted, but it's item_id still exist in internal_hit_paths NOTE: maybe one item has been deleted, but it's item_id still exist in internal_hit_paths
*/ */
long long super_group_ids[MAX_SCANNER_HIT_GROUP_NUM]; long long super_group_ids[MAX_HIT_GROUP_NUM];
UT_array *valid_super_group_ids; UT_array *valid_super_group_ids;
utarray_new(valid_super_group_ids, &ut_compile_group_id_icd); utarray_new(valid_super_group_ids, &ut_compile_group_id_icd);
size_t super_group_cnt = group2group_runtime_get_super_groups(g2g_rt, &(internal_path->group_id), 1, size_t super_group_cnt = group2group_runtime_get_super_groups(g2g_rt, &(internal_path->group_id), 1,
super_group_ids, MAX_SCANNER_HIT_GROUP_NUM); super_group_ids, MAX_HIT_GROUP_NUM);
for (size_t idx = 0; idx < super_group_cnt; idx++) { for (size_t idx = 0; idx < super_group_cnt; idx++) {
utarray_push_back(valid_super_group_ids, &super_group_ids[idx]); utarray_push_back(valid_super_group_ids, &super_group_ids[idx]);
} }

View File

@@ -55,7 +55,7 @@ static int cm_read_cfg_index_file(const char *path, struct cm_table_info_t *idx,
ret = stat(idx[i].cfg_path, &file_info); ret = stat(idx[i].cfg_path, &file_info);
if (ret != 0) { if (ret != 0) {
log_error(logger, MODULE_CONFIG_MONITOR, "%s of %s not exist", log_fatal(logger, MODULE_CONFIG_MONITOR, "%s of %s not exist",
idx[i].cfg_path, path); idx[i].cfg_path, path);
fclose(fp); fclose(fp);
return -1; return -1;
@@ -63,7 +63,7 @@ static int cm_read_cfg_index_file(const char *path, struct cm_table_info_t *idx,
i++; i++;
if (i == size) { if (i == size) {
log_error(logger, MODULE_CONFIG_MONITOR, "Too much lines in %s", path); log_fatal(logger, MODULE_CONFIG_MONITOR, "Too much lines in %s", path);
break; break;
} }
} }
@@ -123,7 +123,7 @@ static int cm_read_table_file(struct cm_table_info_t *index,
if (strlen(index->encrypt_algo) > 0) { if (strlen(index->encrypt_algo) > 0) {
//JSON file has been encrypted //JSON file has been encrypted
if (NULL == dec_key || 0 == strlen(dec_key)) { if (NULL == dec_key || 0 == strlen(dec_key)) {
log_error(logger, MODULE_CONFIG_MONITOR, log_fatal(logger, MODULE_CONFIG_MONITOR,
"update error, no key to decrypt %s.", "update error, no key to decrypt %s.",
index->cfg_path); index->cfg_path);
return -1; return -1;
@@ -133,7 +133,7 @@ static int cm_read_table_file(struct cm_table_info_t *index,
(unsigned char**)&file_buff, &file_sz, error_string, (unsigned char**)&file_buff, &file_sz, error_string,
sizeof(error_string)); sizeof(error_string));
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_CONFIG_MONITOR, log_fatal(logger, MODULE_CONFIG_MONITOR,
"update error, decrypt %s failed: %s", "update error, decrypt %s failed: %s",
index->cfg_path, error_string); index->cfg_path, error_string);
return -1; return -1;
@@ -142,7 +142,7 @@ static int cm_read_table_file(struct cm_table_info_t *index,
// not encrypted // not encrypted
ret = load_file_to_memory(index->cfg_path, (unsigned char **)&file_buff, &file_sz); ret = load_file_to_memory(index->cfg_path, (unsigned char **)&file_buff, &file_sz);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_CONFIG_MONITOR, "[%s:%d] open %s failed.", log_fatal(logger, MODULE_CONFIG_MONITOR, "[%s:%d] open %s failed.",
__FUNCTION__, __LINE__, index->cfg_path); __FUNCTION__, __LINE__, index->cfg_path);
return -1; return -1;
} }
@@ -156,7 +156,7 @@ static int cm_read_table_file(struct cm_table_info_t *index,
if(cfg_num != index->cfg_num) { if(cfg_num != index->cfg_num) {
FREE(file_buff); FREE(file_buff);
log_error(logger, MODULE_CONFIG_MONITOR, log_fatal(logger, MODULE_CONFIG_MONITOR,
"[%s:%d] file %s config num not matched", "[%s:%d] file %s config num not matched",
__FUNCTION__, __LINE__, index->cfg_path); __FUNCTION__, __LINE__, index->cfg_path);
return -1; return -1;
@@ -168,14 +168,14 @@ static int cm_read_table_file(struct cm_table_info_t *index,
char *ret_str = read_nxt_line_from_buff(file_buff, file_sz, &file_offset, char *ret_str = read_nxt_line_from_buff(file_buff, file_sz, &file_offset,
line, sizeof(line)); line, sizeof(line));
if (ret_str == NULL) { if (ret_str == NULL) {
log_error(logger, MODULE_CONFIG_MONITOR, log_fatal(logger, MODULE_CONFIG_MONITOR,
"[%s:%d] file %s line_num %d less than claimed %d", "[%s:%d] file %s line_num %d less than claimed %d",
__FUNCTION__, __LINE__, index->cfg_path, i, cfg_num); __FUNCTION__, __LINE__, index->cfg_path, i, cfg_num);
break; break;
} }
if(line[sizeof(line) - 1] != '\0') { if(line[sizeof(line) - 1] != '\0') {
log_error(logger, MODULE_CONFIG_MONITOR, log_fatal(logger, MODULE_CONFIG_MONITOR,
"[%s:%d] line size more than %u at of file %s:%d", "[%s:%d] line size more than %u at of file %s:%d",
__FUNCTION__, __LINE__, sizeof(line), index->cfg_path, i); __FUNCTION__, __LINE__, sizeof(line), index->cfg_path, i);
continue; continue;
@@ -266,7 +266,7 @@ static int get_new_idx_path(long long current_version, const char *file_dir,
int n = my_scandir(file_dir, &namelist, filter_fn, int n = my_scandir(file_dir, &namelist, filter_fn,
(int (*)(const void*, const void*))alphasort); (int (*)(const void*, const void*))alphasort);
if (n < 0) { if (n < 0) {
log_error(logger, MODULE_CONFIG_MONITOR, log_fatal(logger, MODULE_CONFIG_MONITOR,
"[%s:%d] scan dir error", __FUNCTION__, __LINE__); "[%s:%d] scan dir error", __FUNCTION__, __LINE__);
return update_type; return update_type;
} }
@@ -288,7 +288,7 @@ static int get_new_idx_path(long long current_version, const char *file_dir,
} }
if (strlen(namelist[i]->d_name) > 42) { if (strlen(namelist[i]->d_name) > 42) {
log_error(logger, MODULE_CONFIG_MONITOR, log_fatal(logger, MODULE_CONFIG_MONITOR,
"[%s:%d] config file %s filename too long, should like" "[%s:%d] config file %s filename too long, should like"
" full_config_index.000000000001", " full_config_index.000000000001",
__FUNCTION__, __LINE__, namelist[i]->d_name); __FUNCTION__, __LINE__, namelist[i]->d_name);
@@ -298,7 +298,7 @@ static int get_new_idx_path(long long current_version, const char *file_dir,
int ret = sscanf(namelist[i]->d_name,"%[a-zA-Z]_config_index.%lld", int ret = sscanf(namelist[i]->d_name,"%[a-zA-Z]_config_index.%lld",
update_str, &config_seq); update_str, &config_seq);
if (ret != 2) { if (ret != 2) {
log_error(logger, MODULE_CONFIG_MONITOR, log_fatal(logger, MODULE_CONFIG_MONITOR,
"[%s:%d] config file %s filename error, should like" "[%s:%d] config file %s filename error, should like"
" full_config_index.000000000001", " full_config_index.000000000001",
__FUNCTION__, __LINE__, namelist[i]->d_name); __FUNCTION__, __LINE__, namelist[i]->d_name);
@@ -319,7 +319,7 @@ static int get_new_idx_path(long long current_version, const char *file_dir,
} }
} }
} else { } else {
log_error(logger, MODULE_CONFIG_MONITOR, log_fatal(logger, MODULE_CONFIG_MONITOR,
"[%s:%d] config file %s, not full or inc config", "[%s:%d] config file %s, not full or inc config",
__FUNCTION__, __LINE__, namelist[i]->d_name); __FUNCTION__, __LINE__, namelist[i]->d_name);
} }
@@ -381,7 +381,7 @@ void config_monitor_traverse(long long current_version, const char *idx_dir,
log_info(logger, MODULE_CONFIG_MONITOR, "load %s", idx_path_array[i]); log_info(logger, MODULE_CONFIG_MONITOR, "load %s", idx_path_array[i]);
int table_num = cm_read_cfg_index_file(idx_path_array[i], table_array, MAX_TABLE_NUM, logger); int table_num = cm_read_cfg_index_file(idx_path_array[i], table_array, MAX_TABLE_NUM, logger);
if (table_num < 0) { if (table_num < 0) {
log_error(logger, MODULE_CONFIG_MONITOR, log_fatal(logger, MODULE_CONFIG_MONITOR,
"[%s:%d] load %s failed, abandon update", "[%s:%d] load %s failed, abandon update",
__FUNCTION__, __LINE__, idx_path_array[i]); __FUNCTION__, __LINE__, idx_path_array[i]);
break; break;
@@ -434,7 +434,7 @@ int load_maat_json_file(struct maat *maat_inst, const char *json_filename,
&decrypted_buff_sz, &decrypted_buff_sz,
err_str, err_str_sz); err_str, err_str_sz);
if (ret < 0) { if (ret < 0) {
log_error(maat_inst->logger, MODULE_CONFIG_MONITOR, log_fatal(maat_inst->logger, MODULE_CONFIG_MONITOR,
"[%s:%d] Decrypt Maat JSON file %s failed", "[%s:%d] Decrypt Maat JSON file %s failed",
__FUNCTION__, __LINE__, json_filename); __FUNCTION__, __LINE__, json_filename);
return -1; return -1;
@@ -449,7 +449,7 @@ int load_maat_json_file(struct maat *maat_inst, const char *json_filename,
&uncompressed_buff_sz); &uncompressed_buff_sz);
FREE(json_buff); FREE(json_buff);
if (ret < 0) { if (ret < 0) {
log_error(maat_inst->logger, MODULE_CONFIG_MONITOR, log_fatal(maat_inst->logger, MODULE_CONFIG_MONITOR,
"[%s:%d] Uncompress Maat JSON file %s failed", "[%s:%d] Uncompress Maat JSON file %s failed",
__FUNCTION__, __LINE__, json_filename); __FUNCTION__, __LINE__, json_filename);
return -1; return -1;
@@ -463,7 +463,7 @@ int load_maat_json_file(struct maat *maat_inst, const char *json_filename,
if (NULL == json_buff) { if (NULL == json_buff) {
ret = load_file_to_memory(json_filename, &json_buff, &json_buff_sz); ret = load_file_to_memory(json_filename, &json_buff, &json_buff_sz);
if (ret < 0) { if (ret < 0) {
log_error(maat_inst->logger, MODULE_CONFIG_MONITOR, log_fatal(maat_inst->logger, MODULE_CONFIG_MONITOR,
"[%s:%d] Read Maat JSON file %s failed", "[%s:%d] Read Maat JSON file %s failed",
__FUNCTION__, __LINE__, json_filename); __FUNCTION__, __LINE__, json_filename);
return -1; return -1;

View File

@@ -187,7 +187,7 @@ expr_item_new(struct expr_schema *expr_schema, const char *table_name,
int ret = get_column_pos(line, expr_schema->item_id_column, &column_offset, int ret = get_column_pos(line, expr_schema->item_id_column, &column_offset,
&column_len); &column_len);
if (ret < 0) { if (ret < 0) {
log_error(expr_rt->logger, MODULE_EXPR, log_fatal(expr_rt->logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> has no item_id in line:%s", "[%s:%d] expr table:<%s> has no item_id in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -197,7 +197,7 @@ expr_item_new(struct expr_schema *expr_schema, const char *table_name,
ret = get_column_pos(line, expr_schema->group_id_column, &column_offset, ret = get_column_pos(line, expr_schema->group_id_column, &column_offset,
&column_len); &column_len);
if (ret < 0) { if (ret < 0) {
log_error(expr_rt->logger, MODULE_EXPR, log_fatal(expr_rt->logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> has no group_id in line:%s", "[%s:%d] expr table:<%s> has no group_id in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -206,14 +206,14 @@ expr_item_new(struct expr_schema *expr_schema, const char *table_name,
ret = get_column_pos(line, expr_schema->keywords_column, &column_offset, &column_len); ret = get_column_pos(line, expr_schema->keywords_column, &column_offset, &column_len);
if (ret < 0) { if (ret < 0) {
log_error(expr_rt->logger, MODULE_EXPR, log_fatal(expr_rt->logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> has no keywords in line:%s", "[%s:%d] expr table:<%s> has no keywords in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
} }
if (column_len > MAX_KEYWORDS_STR_LEN) { if (column_len > MAX_KEYWORDS_STR_LEN) {
log_error(expr_rt->logger, MODULE_EXPR, log_fatal(expr_rt->logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> keywords length too long in line:%s", "[%s:%d] expr table:<%s> keywords length too long in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -222,7 +222,7 @@ expr_item_new(struct expr_schema *expr_schema, const char *table_name,
ret = get_column_pos(line, expr_schema->expr_type_column, &column_offset, &column_len); ret = get_column_pos(line, expr_schema->expr_type_column, &column_offset, &column_len);
if (ret < 0) { if (ret < 0) {
log_error(expr_rt->logger, MODULE_EXPR, log_fatal(expr_rt->logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> has no expr_type in line:%s", "[%s:%d] expr table:<%s> has no expr_type in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -231,14 +231,14 @@ expr_item_new(struct expr_schema *expr_schema, const char *table_name,
expr_type = atoi(line + column_offset); expr_type = atoi(line + column_offset);
expr_item->expr_type = int_to_expr_type(expr_type); expr_item->expr_type = int_to_expr_type(expr_type);
if (expr_item->expr_type == EXPR_TYPE_INVALID) { if (expr_item->expr_type == EXPR_TYPE_INVALID) {
log_error(expr_rt->logger, MODULE_EXPR, log_fatal(expr_rt->logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> has invalid expr_type in line:%s", "[%s:%d] expr table:<%s> has invalid expr_type in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
} else if (expr_item->expr_type == EXPR_TYPE_REGEX) { } else if (expr_item->expr_type == EXPR_TYPE_REGEX) {
ret = expr_matcher_verify_regex_expression(expr_item->keywords, expr_rt->logger); ret = expr_matcher_verify_regex_expression(expr_item->keywords, expr_rt->logger);
if (0 == ret) { if (0 == ret) {
log_error(expr_rt->logger, MODULE_EXPR, log_fatal(expr_rt->logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> regex expression(item_id:%lld):%s illegal," "[%s:%d] expr table:<%s> regex expression(item_id:%lld):%s illegal,"
" will be dropped", __FUNCTION__, __LINE__, table_name, " will be dropped", __FUNCTION__, __LINE__, table_name,
expr_item->item_id, expr_item->keywords); expr_item->item_id, expr_item->keywords);
@@ -254,7 +254,7 @@ expr_item_new(struct expr_schema *expr_schema, const char *table_name,
} }
if (column_len > MAX_DISTRICT_STR_LEN) { if (column_len > MAX_DISTRICT_STR_LEN) {
log_error(expr_rt->logger, MODULE_EXPR, log_fatal(expr_rt->logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> district length exceed maximum:%d" "[%s:%d] expr table:<%s> district length exceed maximum:%d"
" in line:%s", __FUNCTION__, __LINE__, table_name, " in line:%s", __FUNCTION__, __LINE__, table_name,
MAX_DISTRICT_STR_LEN, line); MAX_DISTRICT_STR_LEN, line);
@@ -272,7 +272,7 @@ expr_item_new(struct expr_schema *expr_schema, const char *table_name,
ret = get_column_pos(line, expr_schema->match_method_column, &column_offset, &column_len); ret = get_column_pos(line, expr_schema->match_method_column, &column_offset, &column_len);
if (ret < 0) { if (ret < 0) {
log_error(expr_rt->logger, MODULE_EXPR, log_fatal(expr_rt->logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> has no match_method in line:%s", "[%s:%d] expr table:<%s> has no match_method in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -281,7 +281,7 @@ expr_item_new(struct expr_schema *expr_schema, const char *table_name,
match_method_type = atoi(line + column_offset); match_method_type = atoi(line + column_offset);
expr_item->match_mode = int_to_match_mode(match_method_type); expr_item->match_mode = int_to_match_mode(match_method_type);
if (expr_item->match_mode == EXPR_MATCH_MODE_INVALID) { if (expr_item->match_mode == EXPR_MATCH_MODE_INVALID) {
log_error(expr_rt->logger, MODULE_EXPR, log_fatal(expr_rt->logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> has invalid match_method in line:%s", "[%s:%d] expr table:<%s> has invalid match_method in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -289,7 +289,7 @@ expr_item_new(struct expr_schema *expr_schema, const char *table_name,
ret = get_column_pos(line, expr_schema->is_hexbin_column, &column_offset, &column_len); ret = get_column_pos(line, expr_schema->is_hexbin_column, &column_offset, &column_len);
if (ret < 0) { if (ret < 0) {
log_error(expr_rt->logger, MODULE_EXPR, log_fatal(expr_rt->logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> has no is_hexbin in line:%s", "[%s:%d] expr table:<%s> has no is_hexbin in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -310,7 +310,7 @@ expr_item_new(struct expr_schema *expr_schema, const char *table_name,
expr_item->is_case_sensitive = TRUE; expr_item->is_case_sensitive = TRUE;
break; break;
default: default:
log_error(expr_rt->logger, MODULE_EXPR, log_fatal(expr_rt->logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> has invalid hexbin value:%d in line:%s", "[%s:%d] expr table:<%s> has invalid hexbin value:%d in line:%s",
__FUNCTION__, __LINE__, table_name, db_hexbin, line); __FUNCTION__, __LINE__, table_name, db_hexbin, line);
goto error; goto error;
@@ -333,7 +333,7 @@ void *expr_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (item != NULL && item->type == cJSON_Number) { if (item != NULL && item->type == cJSON_Number) {
expr_schema->table_id = item->valueint; expr_schema->table_id = item->valueint;
} else { } else {
log_error(logger, MODULE_EXPR, log_fatal(logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> schema has no table_id column", "[%s:%d] expr table:<%s> schema has no table_id column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -345,7 +345,7 @@ void *expr_schema_new(cJSON *json, struct table_manager *tbl_mgr,
item = cJSON_GetObjectItem(json, "custom"); item = cJSON_GetObjectItem(json, "custom");
if (item == NULL || item->type != cJSON_Object) { if (item == NULL || item->type != cJSON_Object) {
log_error(logger, MODULE_EXPR, log_fatal(logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> schema has no custom column", "[%s:%d] expr table:<%s> schema has no custom column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -355,7 +355,7 @@ void *expr_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
expr_schema->item_id_column = custom_item->valueint; expr_schema->item_id_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_EXPR, log_fatal(logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> schema has no item_id column", "[%s:%d] expr table:<%s> schema has no item_id column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -365,7 +365,7 @@ void *expr_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
expr_schema->group_id_column = custom_item->valueint; expr_schema->group_id_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_EXPR, log_fatal(logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> schema has no group_id column", "[%s:%d] expr table:<%s> schema has no group_id column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -375,7 +375,7 @@ void *expr_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
expr_schema->keywords_column = custom_item->valueint; expr_schema->keywords_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_EXPR, log_fatal(logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> schema has no keywords column", "[%s:%d] expr table:<%s> schema has no keywords column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -387,7 +387,7 @@ void *expr_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
expr_schema->district_column = custom_item->valueint; expr_schema->district_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_EXPR, log_fatal(logger, MODULE_EXPR,
"[%s:%d] expr_plus table:<%s> schema has no district column", "[%s:%d] expr_plus table:<%s> schema has no district column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -398,7 +398,7 @@ void *expr_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
expr_schema->expr_type_column = custom_item->valueint; expr_schema->expr_type_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_EXPR, log_fatal(logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> schema has no expr_type column", "[%s:%d] expr table:<%s> schema has no expr_type column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -408,7 +408,7 @@ void *expr_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
expr_schema->match_method_column = custom_item->valueint; expr_schema->match_method_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_EXPR, log_fatal(logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> schema has no match_method column", "[%s:%d] expr table:<%s> schema has no match_method column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -418,7 +418,7 @@ void *expr_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
expr_schema->is_hexbin_column = custom_item->valueint; expr_schema->is_hexbin_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_EXPR, log_fatal(logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> schema has no is_hexbin column", "[%s:%d] expr table:<%s> schema has no is_hexbin column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -553,7 +553,7 @@ static int expr_runtime_update_row(struct expr_runtime *expr_rt, char *key,
//add //add
ret = rcu_hash_add(expr_rt->item_hash, key, key_len, (void *)item); ret = rcu_hash_add(expr_rt->item_hash, key, key_len, (void *)item);
if (ret < 0) { if (ret < 0) {
log_error(expr_rt->logger, MODULE_EXPR, log_fatal(expr_rt->logger, MODULE_EXPR,
"[%s:%d] expr item(item_id:%lld) add to item_hash failed", "[%s:%d] expr item(item_id:%lld) add to item_hash failed",
__FUNCTION__, __LINE__, item->item_id); __FUNCTION__, __LINE__, item->item_id);
return -1; return -1;
@@ -637,7 +637,7 @@ static int expr_item_to_expr_rule(struct expr_item *expr_item,
} }
if (i >= MAAT_MAX_EXPR_ITEM_NUM) { if (i >= MAAT_MAX_EXPR_ITEM_NUM) {
log_error(logger, MODULE_EXPR, log_fatal(logger, MODULE_EXPR,
"[%s:%d]abandon config expr_item(item_id:%d) " "[%s:%d]abandon config expr_item(item_id:%d) "
"too many patterns", __FUNCTION__, __LINE__, "too many patterns", __FUNCTION__, __LINE__,
expr_item->item_id); expr_item->item_id);
@@ -657,7 +657,7 @@ static int expr_item_to_expr_rule(struct expr_item *expr_item,
} }
if (i >= MAAT_MAX_EXPR_ITEM_NUM) { if (i >= MAAT_MAX_EXPR_ITEM_NUM) {
log_error(logger, MODULE_EXPR, log_fatal(logger, MODULE_EXPR,
"[%s:%d]abandon config expr_item(item_id:%d) " "[%s:%d]abandon config expr_item(item_id:%d) "
"too many patterns", __FUNCTION__, __LINE__, "too many patterns", __FUNCTION__, __LINE__,
expr_item->item_id); expr_item->item_id);
@@ -669,7 +669,7 @@ static int expr_item_to_expr_rule(struct expr_item *expr_item,
&(key_right_offset[i])); &(key_right_offset[i]));
if (!(key_left_offset[i] >= 0 && key_right_offset[i] > 0 if (!(key_left_offset[i] >= 0 && key_right_offset[i] > 0
&& key_left_offset[i] <= key_right_offset[i])) { && key_left_offset[i] <= key_right_offset[i])) {
log_error(logger, MODULE_EXPR, log_fatal(logger, MODULE_EXPR,
"[%s:%d]abandon config expr_item(item_id:%d) " "[%s:%d]abandon config expr_item(item_id:%d) "
"has invalid offset.", __FUNCTION__, __LINE__, "has invalid offset.", __FUNCTION__, __LINE__,
expr_item->item_id); expr_item->item_id);
@@ -679,7 +679,7 @@ static int expr_item_to_expr_rule(struct expr_item *expr_item,
sub_key_array[i] = (char *)memchr(sub_key_array[i], ':', sub_key_array[i] = (char *)memchr(sub_key_array[i], ':',
strlen(sub_key_array[i])); strlen(sub_key_array[i]));
if (NULL == sub_key_array[i]) { if (NULL == sub_key_array[i]) {
log_error(logger, MODULE_EXPR, log_fatal(logger, MODULE_EXPR,
"[%s:%d]abandon config expr_item(item_id:%d) " "[%s:%d]abandon config expr_item(item_id:%d) "
"has invalid offset keyword format.", "has invalid offset keyword format.",
__FUNCTION__, __LINE__, expr_item->item_id); __FUNCTION__, __LINE__, expr_item->item_id);
@@ -701,7 +701,7 @@ static int expr_item_to_expr_rule(struct expr_item *expr_item,
sub_key_array[0] = expr_item->keywords; sub_key_array[0] = expr_item->keywords;
break; break;
default: default:
log_error(logger, MODULE_EXPR, log_fatal(logger, MODULE_EXPR,
"[%s:%d]abandon config expr_item(item_id:%lld) has " "[%s:%d]abandon config expr_item(item_id:%lld) has "
"invalid expr type=%d", __FUNCTION__, __LINE__, "invalid expr type=%d", __FUNCTION__, __LINE__,
expr_item->item_id, expr_item->expr_type); expr_item->item_id, expr_item->expr_type);
@@ -769,7 +769,7 @@ int expr_runtime_update(void *expr_runtime, void *expr_schema,
long long item_id = get_column_value(line, schema->item_id_column); long long item_id = get_column_value(line, schema->item_id_column);
if (item_id < 0) { if (item_id < 0) {
log_error(expr_rt->logger, MODULE_EXPR, log_fatal(expr_rt->logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> has no item_id(column seq:%d)" "[%s:%d] expr table:<%s> has no item_id(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name, " in table_line:%s", __FUNCTION__, __LINE__, table_name,
schema->item_id_column, line); schema->item_id_column, line);
@@ -779,7 +779,7 @@ int expr_runtime_update(void *expr_runtime, void *expr_schema,
int is_valid = get_column_value(line, valid_column); int is_valid = get_column_value(line, valid_column);
if (is_valid < 0) { if (is_valid < 0) {
log_error(expr_rt->logger, MODULE_EXPR, log_fatal(expr_rt->logger, MODULE_EXPR,
"[%s:%d] expr table:<%s> has no is_valid(column seq:%d)" "[%s:%d] expr table:<%s> has no is_valid(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name, " in table_line:%s", __FUNCTION__, __LINE__, table_name,
valid_column, line); valid_column, line);
@@ -887,7 +887,7 @@ int expr_runtime_commit(void *expr_runtime, const char *table_name,
(end.tv_nsec - start.tv_nsec) / 1000000; (end.tv_nsec - start.tv_nsec) / 1000000;
if (NULL == new_matcher) { if (NULL == new_matcher) {
log_error(expr_rt->logger, MODULE_EXPR, log_fatal(expr_rt->logger, MODULE_EXPR,
"[%s:%d] table[%s] rebuild expr_matcher failed when update" "[%s:%d] table[%s] rebuild expr_matcher failed when update"
" %zu expr rules", __FUNCTION__, __LINE__, table_name, real_rule_cnt); " %zu expr rules", __FUNCTION__, __LINE__, table_name, real_rule_cnt);
ret = -1; ret = -1;
@@ -969,9 +969,9 @@ int expr_runtime_scan(struct expr_runtime *expr_rt, int thread_id,
} }
size_t n_hit_item = 0; size_t n_hit_item = 0;
struct expr_scan_result hit_results[MAX_SCANNER_HIT_ITEM_NUM]; struct expr_scan_result hit_results[MAX_HIT_ITEM_NUM];
int ret = expr_matcher_match(expr_rt->matcher, thread_id, data, data_len, int ret = expr_matcher_match(expr_rt->matcher, thread_id, data, data_len,
hit_results, MAX_SCANNER_HIT_ITEM_NUM, &n_hit_item); hit_results, MAX_HIT_ITEM_NUM, &n_hit_item);
if (ret < 0) { if (ret < 0) {
return -1; return -1;
} }
@@ -1003,7 +1003,15 @@ int expr_runtime_scan(struct expr_runtime *expr_rt, int thread_id,
} }
next: next:
return compile_state_update(vtable_id, hit_maat_items, real_hit_item_cnt, state); if (NULL == state->compile_state) {
state->compile_state = compile_state_new();
alignment_int64_array_add(state->maat_inst->stat->compile_state_cnt,
state->thread_id, 1);
}
return compile_state_update(state->compile_state, state->maat_inst, vtable_id,
state->compile_table_id, state->scan_cnt,
hit_maat_items, real_hit_item_cnt);
} }
struct expr_matcher_stream * struct expr_matcher_stream *
@@ -1033,10 +1041,10 @@ int expr_runtime_stream_scan(struct expr_runtime *expr_rt,
} }
size_t n_hit_item = 0; size_t n_hit_item = 0;
struct expr_scan_result hit_results[MAX_SCANNER_HIT_ITEM_NUM]; struct expr_scan_result hit_results[MAX_HIT_ITEM_NUM];
int ret = expr_matcher_stream_match(s_handle, data, data_len, hit_results, int ret = expr_matcher_stream_match(s_handle, data, data_len, hit_results,
MAX_SCANNER_HIT_ITEM_NUM, &n_hit_item); MAX_HIT_ITEM_NUM, &n_hit_item);
if (ret < 0) { if (ret < 0) {
return -1; return -1;
} }
@@ -1065,7 +1073,15 @@ int expr_runtime_stream_scan(struct expr_runtime *expr_rt,
} }
next: next:
return compile_state_update(vtable_id, hit_maat_items, real_hit_item_cnt, state); if (NULL == state->compile_state) {
state->compile_state = compile_state_new();
alignment_int64_array_add(state->maat_inst->stat->compile_state_cnt,
state->thread_id, 1);
}
return compile_state_update(state->compile_state, state->maat_inst, vtable_id,
state->compile_table_id, state->scan_cnt,
hit_maat_items, real_hit_item_cnt);
} }
void expr_runtime_stream_close(struct expr_runtime *expr_rt, int thread_id, void expr_runtime_stream_close(struct expr_runtime *expr_rt, int thread_id,

View File

@@ -73,7 +73,7 @@ void *flag_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (item != NULL && item->type == cJSON_Number) { if (item != NULL && item->type == cJSON_Number) {
schema->table_id = item->valueint; schema->table_id = item->valueint;
} else { } else {
log_error(logger, MODULE_FLAG, log_fatal(logger, MODULE_FLAG,
"[%s:%d] flag table:<%s> schema has no table_id column", "[%s:%d] flag table:<%s> schema has no table_id column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -85,7 +85,7 @@ void *flag_schema_new(cJSON *json, struct table_manager *tbl_mgr,
item = cJSON_GetObjectItem(json, "custom"); item = cJSON_GetObjectItem(json, "custom");
if (item == NULL || item->type != cJSON_Object) { if (item == NULL || item->type != cJSON_Object) {
log_error(logger, MODULE_FLAG, log_fatal(logger, MODULE_FLAG,
"[%s:%d] flag table:<%s> schema has no custom column", "[%s:%d] flag table:<%s> schema has no custom column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -95,7 +95,7 @@ void *flag_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->item_id_column = custom_item->valueint; schema->item_id_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_FLAG, log_fatal(logger, MODULE_FLAG,
"[%s:%d] flag table:<%s> schema has no item_id column", "[%s:%d] flag table:<%s> schema has no item_id column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -105,7 +105,7 @@ void *flag_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->group_id_column = custom_item->valueint; schema->group_id_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_FLAG, log_fatal(logger, MODULE_FLAG,
"[%s:%d] flag table:<%s> schema has no group_id column", "[%s:%d] flag table:<%s> schema has no group_id column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -117,7 +117,7 @@ void *flag_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->district_column = custom_item->valueint; schema->district_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_FLAG, log_fatal(logger, MODULE_FLAG,
"[%s:%d] flag_plus table:<%s> schema has no district column", "[%s:%d] flag_plus table:<%s> schema has no district column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -128,7 +128,7 @@ void *flag_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->flag_column = custom_item->valueint; schema->flag_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_FLAG, log_fatal(logger, MODULE_FLAG,
"[%s:%d] flag table:<%s> schema has no flag column", "[%s:%d] flag table:<%s> schema has no flag column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -138,7 +138,7 @@ void *flag_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->flag_mask_column = custom_item->valueint; schema->flag_mask_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_FLAG, log_fatal(logger, MODULE_FLAG,
"[%s:%d] flag table:<%s> schema has no flag_mask column", "[%s:%d] flag table:<%s> schema has no flag_mask column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -254,7 +254,7 @@ static int flag_runtime_update_row(struct flag_runtime *flag_rt, char *key,
//add //add
ret = rcu_hash_add(flag_rt->item_hash, key, key_len, (void *)item); ret = rcu_hash_add(flag_rt->item_hash, key, key_len, (void *)item);
if (ret < 0) { if (ret < 0) {
log_error(flag_rt->logger, MODULE_FLAG, log_fatal(flag_rt->logger, MODULE_FLAG,
"[%s:%d] flag item(item_id:%lld) add to item_hash failed", "[%s:%d] flag item(item_id:%lld) add to item_hash failed",
__FUNCTION__, __LINE__, item->item_id); __FUNCTION__, __LINE__, item->item_id);
return -1; return -1;
@@ -309,7 +309,7 @@ flag_item_new(struct flag_schema *schema, const char *table_name,
int ret = get_column_pos(line, schema->item_id_column, &column_offset, int ret = get_column_pos(line, schema->item_id_column, &column_offset,
&column_len); &column_len);
if (ret < 0) { if (ret < 0) {
log_error(flag_rt->logger, MODULE_FLAG, log_fatal(flag_rt->logger, MODULE_FLAG,
"[%s:%d] flag table:<%s> has no item_id in line:%s", "[%s:%d] flag table:<%s> has no item_id in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -319,7 +319,7 @@ flag_item_new(struct flag_schema *schema, const char *table_name,
ret = get_column_pos(line, schema->group_id_column, &column_offset, ret = get_column_pos(line, schema->group_id_column, &column_offset,
&column_len); &column_len);
if (ret < 0) { if (ret < 0) {
log_error(flag_rt->logger, MODULE_FLAG, log_fatal(flag_rt->logger, MODULE_FLAG,
"[%s:%d] flag table:<%s> has no group_id in line:%s", "[%s:%d] flag table:<%s> has no group_id in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -335,7 +335,7 @@ flag_item_new(struct flag_schema *schema, const char *table_name,
} }
if (column_len > MAX_DISTRICT_STR_LEN) { if (column_len > MAX_DISTRICT_STR_LEN) {
log_error(flag_rt->logger, MODULE_FLAG, log_fatal(flag_rt->logger, MODULE_FLAG,
"[%s:%d] flag_plus table:<%s> district length exceed " "[%s:%d] flag_plus table:<%s> district length exceed "
"maximum:%d in line:%s", __FUNCTION__, __LINE__, "maximum:%d in line:%s", __FUNCTION__, __LINE__,
table_name, MAX_DISTRICT_STR_LEN, line); table_name, MAX_DISTRICT_STR_LEN, line);
@@ -353,7 +353,7 @@ flag_item_new(struct flag_schema *schema, const char *table_name,
ret = get_column_pos(line, schema->flag_column, &column_offset, &column_len); ret = get_column_pos(line, schema->flag_column, &column_offset, &column_len);
if (ret < 0) { if (ret < 0) {
log_error(flag_rt->logger, MODULE_FLAG, log_fatal(flag_rt->logger, MODULE_FLAG,
"[%s:%d] flag table:<%s> has no flag in line:%s", "[%s:%d] flag table:<%s> has no flag in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -363,7 +363,7 @@ flag_item_new(struct flag_schema *schema, const char *table_name,
ret = get_column_pos(line, schema->flag_mask_column, &column_offset, &column_len); ret = get_column_pos(line, schema->flag_mask_column, &column_offset, &column_len);
if (ret < 0) { if (ret < 0) {
log_error(flag_rt->logger, MODULE_FLAG, log_fatal(flag_rt->logger, MODULE_FLAG,
"[%s:%d] flag table:<%s> has no flag_mask in line:%s", "[%s:%d] flag table:<%s> has no flag_mask in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -402,7 +402,7 @@ int flag_runtime_update(void *flag_runtime, void *flag_schema,
long long item_id = get_column_value(line, schema->item_id_column); long long item_id = get_column_value(line, schema->item_id_column);
if (item_id < 0) { if (item_id < 0) {
log_error(flag_rt->logger, MODULE_FLAG, log_fatal(flag_rt->logger, MODULE_FLAG,
"[%s:%d] flag table:<%s> has no item_id(column seq:%d)" "[%s:%d] flag table:<%s> has no item_id(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name, " in table_line:%s", __FUNCTION__, __LINE__, table_name,
schema->item_id_column, line); schema->item_id_column, line);
@@ -411,7 +411,7 @@ int flag_runtime_update(void *flag_runtime, void *flag_schema,
int is_valid = get_column_value(line, valid_column); int is_valid = get_column_value(line, valid_column);
if (is_valid < 0) { if (is_valid < 0) {
log_error(flag_rt->logger, MODULE_FLAG, log_fatal(flag_rt->logger, MODULE_FLAG,
"[%s:%d] flag table:<%s> has no is_valid(column seq:%d)" "[%s:%d] flag table:<%s> has no is_valid(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name, " in table_line:%s", __FUNCTION__, __LINE__, table_name,
valid_column, line); valid_column, line);
@@ -499,7 +499,7 @@ int flag_runtime_commit(void *flag_runtime, const char *table_name,
(end.tv_nsec - start.tv_nsec) / 1000000; (end.tv_nsec - start.tv_nsec) / 1000000;
if (NULL == new_flag_matcher) { if (NULL == new_flag_matcher) {
log_error(flag_rt->logger, MODULE_FLAG, log_fatal(flag_rt->logger, MODULE_FLAG,
"[%s:%d] table[%s] rebuild flag_matcher engine failed " "[%s:%d] table[%s] rebuild flag_matcher engine failed "
"when update %zu flag rules", __FUNCTION__, __LINE__, "when update %zu flag rules", __FUNCTION__, __LINE__,
table_name, rule_cnt); table_name, rule_cnt);
@@ -556,9 +556,8 @@ int flag_runtime_scan(struct flag_runtime *flag_rt, int thread_id,
return 0; return 0;
} }
struct flag_result hit_results[MAX_SCANNER_HIT_ITEM_NUM]; struct flag_result hit_results[MAX_HIT_ITEM_NUM];
int n_hit_item = flag_matcher_match(flag_rt->matcher, flag, int n_hit_item = flag_matcher_match(flag_rt->matcher, flag, hit_results, MAX_HIT_ITEM_NUM);
hit_results, MAX_SCANNER_HIT_ITEM_NUM);
if (n_hit_item < 0) { if (n_hit_item < 0) {
return -1; return -1;
} }
@@ -589,7 +588,15 @@ int flag_runtime_scan(struct flag_runtime *flag_rt, int thread_id,
} }
next: next:
return compile_state_update(vtable_id, hit_maat_items, real_hit_item_cnt, state); if (NULL == state->compile_state) {
state->compile_state = compile_state_new();
alignment_int64_array_add(state->maat_inst->stat->compile_state_cnt,
state->thread_id, 1);
}
return compile_state_update(state->compile_state, state->maat_inst, vtable_id,
state->compile_table_id, state->scan_cnt,
hit_maat_items, real_hit_item_cnt);
} }
void flag_runtime_hit_inc(struct flag_runtime *flag_rt, int thread_id) void flag_runtime_hit_inc(struct flag_runtime *flag_rt, int thread_id)

View File

@@ -54,7 +54,7 @@ void *fqdn_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (item != NULL && item->type == cJSON_Number) { if (item != NULL && item->type == cJSON_Number) {
schema->table_id = item->valueint; schema->table_id = item->valueint;
} else { } else {
log_error(logger, MODULE_FQDN_PLUGIN, log_fatal(logger, MODULE_FQDN_PLUGIN,
"[%s:%d] fqdn_plugin table:<%s> schema has no table_id column", "[%s:%d] fqdn_plugin table:<%s> schema has no table_id column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -62,7 +62,7 @@ void *fqdn_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
item = cJSON_GetObjectItem(json, "custom"); item = cJSON_GetObjectItem(json, "custom");
if (NULL == item || item->type != cJSON_Object) { if (NULL == item || item->type != cJSON_Object) {
log_error(logger, MODULE_FQDN_PLUGIN, log_fatal(logger, MODULE_FQDN_PLUGIN,
"[%s:%d] fqdn_plugin table:<%s> schema has no custom column", "[%s:%d] fqdn_plugin table:<%s> schema has no custom column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -72,7 +72,7 @@ void *fqdn_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->item_id_column = custom_item->valueint; schema->item_id_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_FQDN_PLUGIN, log_fatal(logger, MODULE_FQDN_PLUGIN,
"[%s:%d] fqdn_plugin table:<%s> schema has no item_id column", "[%s:%d] fqdn_plugin table:<%s> schema has no item_id column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -82,7 +82,7 @@ void *fqdn_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->suffix_match_method_column = custom_item->valueint; schema->suffix_match_method_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_FQDN_PLUGIN, log_fatal(logger, MODULE_FQDN_PLUGIN,
"[%s:%d] fqdn_plugin table:<%s> schema has no suffix_match_method column", "[%s:%d] fqdn_plugin table:<%s> schema has no suffix_match_method column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -93,7 +93,7 @@ void *fqdn_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->fqdn_column = custom_item->valueint; schema->fqdn_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_FQDN_PLUGIN, log_fatal(logger, MODULE_FQDN_PLUGIN,
"[%s:%d] fqdn_plugin table:<%s> schema has no fqdn column", "[%s:%d] fqdn_plugin table:<%s> schema has no fqdn column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -137,7 +137,7 @@ int fqdn_plugin_table_set_ex_container_schema(void *fqdn_plugin_schema, int tabl
struct fqdn_plugin_schema *schema = (struct fqdn_plugin_schema *)fqdn_plugin_schema; struct fqdn_plugin_schema *schema = (struct fqdn_plugin_schema *)fqdn_plugin_schema;
if (1 == schema->container_schema.set_flag) { if (1 == schema->container_schema.set_flag) {
log_error(schema->logger, MODULE_FQDN_PLUGIN, log_fatal(schema->logger, MODULE_FQDN_PLUGIN,
"[%s:%d] fqdn_plugin table(table_id:%d) ex_container_schema " "[%s:%d] fqdn_plugin table(table_id:%d) ex_container_schema "
"has been set, can't set again", __FUNCTION__, __LINE__, table_id); "has been set, can't set again", __FUNCTION__, __LINE__, table_id);
return -1; return -1;
@@ -240,7 +240,7 @@ static int fqdn_plugin_accept_tag_match(struct fqdn_plugin_schema *schema,
int ret = get_column_pos(line, schema->rule_tag_column, int ret = get_column_pos(line, schema->rule_tag_column,
&column_offset, &column_len); &column_offset, &column_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_FQDN_PLUGIN, log_fatal(logger, MODULE_FQDN_PLUGIN,
"[%s:%d] fqdn_plugin table:<%s> has no rule_tag in line:%s", "[%s:%d] fqdn_plugin table:<%s> has no rule_tag in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
return TAG_MATCH_ERR; return TAG_MATCH_ERR;
@@ -252,14 +252,14 @@ static int fqdn_plugin_accept_tag_match(struct fqdn_plugin_schema *schema,
ret = table_manager_accept_tags_match(schema->ref_tbl_mgr, tag_str); ret = table_manager_accept_tags_match(schema->ref_tbl_mgr, tag_str);
FREE(tag_str); FREE(tag_str);
if (TAG_MATCH_ERR == ret) { if (TAG_MATCH_ERR == ret) {
log_error(logger, MODULE_FQDN_PLUGIN, log_fatal(logger, MODULE_FQDN_PLUGIN,
"[%s:%d] fqdn_plugin table:<%s> has invalid tag format in line:%s", "[%s:%d] fqdn_plugin table:<%s> has invalid tag format in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
return TAG_MATCH_ERR; return TAG_MATCH_ERR;
} }
if (TAG_MATCH_UNMATCHED == ret) { if (TAG_MATCH_UNMATCHED == ret) {
log_error(logger, MODULE_FQDN_PLUGIN, log_fatal(logger, MODULE_FQDN_PLUGIN,
"[%s:%d] fqdn_plugin table:<%s> has unmatched tag in line:%s", "[%s:%d] fqdn_plugin table:<%s> has unmatched tag in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
return TAG_MATCH_UNMATCHED; return TAG_MATCH_UNMATCHED;
@@ -287,7 +287,7 @@ fqdn_plugin_rule_new(const char *line, struct fqdn_plugin_schema *schema,
ret = get_column_pos(line, schema->item_id_column, &column_offset, &column_len); ret = get_column_pos(line, schema->item_id_column, &column_offset, &column_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_FQDN_PLUGIN, log_fatal(logger, MODULE_FQDN_PLUGIN,
"[%s:%d] fqdn_plugin table:<%s> has no item_id in line:%s", "[%s:%d] fqdn_plugin table:<%s> has no item_id in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -296,7 +296,7 @@ fqdn_plugin_rule_new(const char *line, struct fqdn_plugin_schema *schema,
ret = get_column_pos(line, schema->suffix_match_method_column, &column_offset, &column_len); ret = get_column_pos(line, schema->suffix_match_method_column, &column_offset, &column_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_FQDN_PLUGIN, log_fatal(logger, MODULE_FQDN_PLUGIN,
"[%s:%d] fqdn_plugin table:<%s> has no suffix_match_method in line:%s", "[%s:%d] fqdn_plugin table:<%s> has no suffix_match_method in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -305,7 +305,7 @@ fqdn_plugin_rule_new(const char *line, struct fqdn_plugin_schema *schema,
fqdn_plugin_rule->is_suffix_match = atoi(line + column_offset); fqdn_plugin_rule->is_suffix_match = atoi(line + column_offset);
if (fqdn_plugin_rule->is_suffix_match != 0 && if (fqdn_plugin_rule->is_suffix_match != 0 &&
fqdn_plugin_rule->is_suffix_match != 1) { fqdn_plugin_rule->is_suffix_match != 1) {
log_error(logger, MODULE_FQDN_PLUGIN, log_fatal(logger, MODULE_FQDN_PLUGIN,
"[%s:%d] fqdn_plugin table:<%s> suffix_match_method:%d is illegal in line:%s", "[%s:%d] fqdn_plugin table:<%s> suffix_match_method:%d is illegal in line:%s",
__FUNCTION__, __LINE__, table_name, fqdn_plugin_rule->is_suffix_match, line); __FUNCTION__, __LINE__, table_name, fqdn_plugin_rule->is_suffix_match, line);
goto error; goto error;
@@ -313,7 +313,7 @@ fqdn_plugin_rule_new(const char *line, struct fqdn_plugin_schema *schema,
ret = get_column_pos(line, schema->fqdn_column, &column_offset, &column_len); ret = get_column_pos(line, schema->fqdn_column, &column_offset, &column_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_FQDN_PLUGIN, log_fatal(logger, MODULE_FQDN_PLUGIN,
"[%s:%d] fqdn_plugin table:<%s> has no fqdn in line:%s", "[%s:%d] fqdn_plugin table:<%s> has no fqdn in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -399,7 +399,7 @@ int fqdn_plugin_runtime_update(void *fqdn_plugin_runtime, void *fqdn_plugin_sche
int is_valid = get_column_value(line, valid_column); int is_valid = get_column_value(line, valid_column);
if (is_valid < 0) { if (is_valid < 0) {
log_error(fqdn_plugin_rt->logger, MODULE_FQDN_PLUGIN, log_fatal(fqdn_plugin_rt->logger, MODULE_FQDN_PLUGIN,
"[%s:%d] fqdn_plugin table:<%s> has no is_valid(column seq:%d)" "[%s:%d] fqdn_plugin table:<%s> has no is_valid(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name, " in table_line:%s", __FUNCTION__, __LINE__, table_name,
valid_column, line); valid_column, line);
@@ -409,7 +409,7 @@ int fqdn_plugin_runtime_update(void *fqdn_plugin_runtime, void *fqdn_plugin_sche
int ret = get_column_pos(line, schema->item_id_column, &item_id_offset, &item_id_len); int ret = get_column_pos(line, schema->item_id_column, &item_id_offset, &item_id_len);
if (ret < 0) { if (ret < 0) {
log_error(fqdn_plugin_rt->logger, MODULE_FQDN_PLUGIN, log_fatal(fqdn_plugin_rt->logger, MODULE_FQDN_PLUGIN,
"[%s:%d] fqdn_plugin table:<%s> has no item_id(column seq:%d)" "[%s:%d] fqdn_plugin table:<%s> has no item_id(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name, " in table_line:%s", __FUNCTION__, __LINE__, table_name,
schema->item_id_column, line); schema->item_id_column, line);
@@ -501,7 +501,7 @@ int fqdn_plugin_runtime_commit(void *fqdn_plugin_runtime, const char *table_name
(end.tv_nsec - start.tv_nsec) / 1000000; (end.tv_nsec - start.tv_nsec) / 1000000;
if (NULL == new_fqdn_engine) { if (NULL == new_fqdn_engine) {
log_error(fqdn_plugin_rt->logger, MODULE_FQDN_PLUGIN, log_fatal(fqdn_plugin_rt->logger, MODULE_FQDN_PLUGIN,
"[%s:%d] table[%s] rebuild FQDN engine failed when update" "[%s:%d] table[%s] rebuild FQDN engine failed when update"
" %zu fqdn_plugin rules", __FUNCTION__, __LINE__, table_name, " %zu fqdn_plugin rules", __FUNCTION__, __LINE__, table_name,
rule_cnt); rule_cnt);

View File

@@ -96,7 +96,7 @@ void *group2group_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (item != NULL && item->type == cJSON_Number) { if (item != NULL && item->type == cJSON_Number) {
g2g_schema->table_id = item->valueint; g2g_schema->table_id = item->valueint;
} else { } else {
log_error(logger, MODULE_GROUP, log_fatal(logger, MODULE_GROUP,
"[%s:%d] g2g table:<%s> schema has no table_id column", "[%s:%d] g2g table:<%s> schema has no table_id column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -104,7 +104,7 @@ void *group2group_schema_new(cJSON *json, struct table_manager *tbl_mgr,
item = cJSON_GetObjectItem(json, "custom"); item = cJSON_GetObjectItem(json, "custom");
if (item == NULL || item->type != cJSON_Object) { if (item == NULL || item->type != cJSON_Object) {
log_error(logger, MODULE_GROUP, log_fatal(logger, MODULE_GROUP,
"[%s:%d] g2g table:<%s> schema has no custom column", "[%s:%d] g2g table:<%s> schema has no custom column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -114,7 +114,7 @@ void *group2group_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
g2g_schema->group_id_column = custom_item->valueint; g2g_schema->group_id_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_GROUP, log_fatal(logger, MODULE_GROUP,
"[%s:%d] g2g table:<%s> schema has no group_id column", "[%s:%d] g2g table:<%s> schema has no group_id column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -124,7 +124,7 @@ void *group2group_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
g2g_schema->super_group_id_column = custom_item->valueint; g2g_schema->super_group_id_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_GROUP, log_fatal(logger, MODULE_GROUP,
"[%s:%d] g2g table:<%s> schema has no super_group_id column", "[%s:%d] g2g table:<%s> schema has no super_group_id column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -134,7 +134,7 @@ void *group2group_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
g2g_schema->is_exclude_column = custom_item->valueint; g2g_schema->is_exclude_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_GROUP, log_fatal(logger, MODULE_GROUP,
"[%s:%d] g2g table:<%s> schema has no is_exclude column", "[%s:%d] g2g table:<%s> schema has no is_exclude column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -329,7 +329,7 @@ group2group_item_new(const char *line, struct group2group_schema *g2g_schema,
int ret = get_column_pos(line, g2g_schema->group_id_column, int ret = get_column_pos(line, g2g_schema->group_id_column,
&column_offset, &column_len); &column_offset, &column_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_GROUP, log_fatal(logger, MODULE_GROUP,
"[%s:%d] g2g table:<%s> has no group_id in line:%s", "[%s:%d] g2g table:<%s> has no group_id in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -339,7 +339,7 @@ group2group_item_new(const char *line, struct group2group_schema *g2g_schema,
ret = get_column_pos(line, g2g_schema->super_group_id_column, ret = get_column_pos(line, g2g_schema->super_group_id_column,
&column_offset, &column_len); &column_offset, &column_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_GROUP, log_fatal(logger, MODULE_GROUP,
"[%s:%d] g2 table:<%s> has no super_group_id in line:%s", "[%s:%d] g2 table:<%s> has no super_group_id in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -349,7 +349,7 @@ group2group_item_new(const char *line, struct group2group_schema *g2g_schema,
ret = get_column_pos(line, g2g_schema->is_exclude_column, ret = get_column_pos(line, g2g_schema->is_exclude_column,
&column_offset, &column_len); &column_offset, &column_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_GROUP, log_fatal(logger, MODULE_GROUP,
"[%s:%d] g2g table:<%s> has no is_exclude in line:%s", "[%s:%d] g2g table:<%s> has no is_exclude in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -357,14 +357,14 @@ group2group_item_new(const char *line, struct group2group_schema *g2g_schema,
g2g_item->is_exclude = atoi(line + column_offset); g2g_item->is_exclude = atoi(line + column_offset);
if (g2g_item->is_exclude != 0 && g2g_item->is_exclude != 1) { if (g2g_item->is_exclude != 0 && g2g_item->is_exclude != 1) {
log_error(logger, MODULE_GROUP, log_fatal(logger, MODULE_GROUP,
"[%s:%d] g2g table:<%s> is_exclude:%d is illegal in line:%s", "[%s:%d] g2g table:<%s> is_exclude:%d is illegal in line:%s",
__FUNCTION__, __LINE__, table_name, g2g_item->is_exclude, line); __FUNCTION__, __LINE__, table_name, g2g_item->is_exclude, line);
goto error; goto error;
} }
if (g2g_item->is_exclude != 0 && g2g_item->is_exclude != 1) { if (g2g_item->is_exclude != 0 && g2g_item->is_exclude != 1) {
log_error(logger, MODULE_GROUP, log_fatal(logger, MODULE_GROUP,
"[%s:%d] g2g table:<%s> is_exclude:%d is illegal in line:%s", "[%s:%d] g2g table:<%s> is_exclude:%d is illegal in line:%s",
__FUNCTION__, __LINE__, table_name, g2g_item->is_exclude, line); __FUNCTION__, __LINE__, table_name, g2g_item->is_exclude, line);
goto error; goto error;
@@ -433,7 +433,7 @@ static void group_topology_del_group(struct maat_group_topology *group_topo,
igraph_neighbors(&group_topo->group_graph, &v, group->vertex_id, IGRAPH_ALL); igraph_neighbors(&group_topo->group_graph, &v, group->vertex_id, IGRAPH_ALL);
if (igraph_vector_size(&v) > 0) { if (igraph_vector_size(&v) > 0) {
print_igraph_vector(&v, buff, sizeof(buff)); print_igraph_vector(&v, buff, sizeof(buff));
log_error(group_topo->logger, MODULE_GROUP, log_fatal(group_topo->logger, MODULE_GROUP,
"[%s:%d] Del group %d exception, still reached by %s.", "[%s:%d] Del group %d exception, still reached by %s.",
__FUNCTION__, __LINE__, group->vertex_id, buff); __FUNCTION__, __LINE__, group->vertex_id, buff);
assert(0); assert(0);
@@ -595,7 +595,7 @@ static int group_topology_add_group_to_group(struct maat_group_topology *group_t
//No duplicated edges between two groups. //No duplicated edges between two groups.
if (edge_id > 0) { if (edge_id > 0) {
log_error(group_topo->logger, MODULE_GROUP, log_fatal(group_topo->logger, MODULE_GROUP,
"[%s:%d] Add group %d to group %d failed, relation already existed.", "[%s:%d] Add group %d to group %d failed, relation already existed.",
__FUNCTION__, __LINE__, group->group_id, super_group->group_id); __FUNCTION__, __LINE__, group->group_id, super_group->group_id);
ret = -1; ret = -1;
@@ -621,7 +621,7 @@ static int group_topology_del_group_from_group(struct maat_group_topology *group
//No hash write operation, LOCK protection is unnecessary. //No hash write operation, LOCK protection is unnecessary.
struct maat_group *group = group_topology_find_group(group_topo, group_id); struct maat_group *group = group_topology_find_group(group_topo, group_id);
if (NULL == group) { if (NULL == group) {
log_error(group_topo->logger, MODULE_GROUP, log_fatal(group_topo->logger, MODULE_GROUP,
"[%s:%d] Del group %d from group %d failed, group %d not existed.", "[%s:%d] Del group %d from group %d failed, group %d not existed.",
__FUNCTION__, __LINE__, group_id, super_group_id, group_id); __FUNCTION__, __LINE__, group_id, super_group_id, group_id);
return -1; return -1;
@@ -629,7 +629,7 @@ static int group_topology_del_group_from_group(struct maat_group_topology *group
struct maat_group *super_group = group_topology_find_group(group_topo, super_group_id); struct maat_group *super_group = group_topology_find_group(group_topo, super_group_id);
if (NULL == super_group) { if (NULL == super_group) {
log_error(group_topo->logger, MODULE_GROUP, log_fatal(group_topo->logger, MODULE_GROUP,
"[%s:%d] Del group %d from group %d failed, superior group %d not existed.", "[%s:%d] Del group %d from group %d failed, superior group %d not existed.",
__FUNCTION__, __LINE__, group_id, super_group_id, super_group_id); __FUNCTION__, __LINE__, group_id, super_group_id, super_group_id);
return -1; return -1;
@@ -677,7 +677,7 @@ static int group_topology_build_super_groups(struct maat_group_topology *group_t
igraph_bool_t is_dag; igraph_bool_t is_dag;
igraph_is_dag(&(group_topo->group_graph), &is_dag); igraph_is_dag(&(group_topo->group_graph), &is_dag);
if (!is_dag) { if (!is_dag) {
log_error(group_topo->logger, MODULE_GROUP, log_fatal(group_topo->logger, MODULE_GROUP,
"[%s:%d] Sub group cycle detected!", __FUNCTION__, __LINE__); "[%s:%d] Sub group cycle detected!", __FUNCTION__, __LINE__);
return -1; return -1;
} }
@@ -709,7 +709,7 @@ int group2group_runtime_update(void *g2g_runtime, void *g2g_schema,
struct group2group_runtime *g2g_rt = (struct group2group_runtime *)g2g_runtime; struct group2group_runtime *g2g_rt = (struct group2group_runtime *)g2g_runtime;
int is_valid = get_column_value(line, valid_column); int is_valid = get_column_value(line, valid_column);
if (is_valid < 0) { if (is_valid < 0) {
log_error(g2g_rt->logger, MODULE_GROUP, log_fatal(g2g_rt->logger, MODULE_GROUP,
"[%s:%d] g2g table:<%s> has no is_valid(column seq:%d)" "[%s:%d] g2g table:<%s> has no is_valid(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name, " in table_line:%s", __FUNCTION__, __LINE__, table_name,
valid_column, line); valid_column, line);
@@ -790,7 +790,7 @@ int group2group_runtime_commit(void *g2g_runtime, const char *table_name,
(end.tv_nsec - start.tv_nsec) / 1000000; (end.tv_nsec - start.tv_nsec) / 1000000;
if (ret < 0) { if (ret < 0) {
log_error(g2g_rt->logger, MODULE_GROUP, log_fatal(g2g_rt->logger, MODULE_GROUP,
"[%s:%d] table[%s] group2group runtime commit failed", "[%s:%d] table[%s] group2group runtime commit failed",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
return -1; return -1;
@@ -1007,12 +1007,12 @@ static void get_super_group_ids(struct maat_group_topology *group_topo,
UT_array *kept_super_group_ids; UT_array *kept_super_group_ids;
if (depth >= MAX_RECURSION_DEPTH) { if (depth >= MAX_RECURSION_DEPTH) {
log_error(group_topo->logger, MODULE_GROUP, log_fatal(group_topo->logger, MODULE_GROUP,
"[%s:%d]exceed max recursion depth(5)", "[%s:%d]exceed max recursion depth(5)",
__FUNCTION__, __LINE__); __FUNCTION__, __LINE__);
for (int i = 0; i < utarray_len(hit_group_ids); i++) { for (int i = 0; i < utarray_len(hit_group_ids); i++) {
long long *p = (long long *)utarray_eltptr(hit_group_ids, i); long long *p = (long long *)utarray_eltptr(hit_group_ids, i);
log_error(group_topo->logger, MODULE_GROUP, log_fatal(group_topo->logger, MODULE_GROUP,
"[%s:%d]group_id:%lld can't recursively get super group_id", "[%s:%d]group_id:%lld can't recursively get super group_id",
__FUNCTION__, __LINE__, *p); __FUNCTION__, __LINE__, *p);
} }

View File

@@ -70,7 +70,7 @@ void *interval_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (item != NULL && item->type == cJSON_Number) { if (item != NULL && item->type == cJSON_Number) {
schema->table_id = item->valueint; schema->table_id = item->valueint;
} else { } else {
log_error(logger, MODULE_INTERVAL, log_fatal(logger, MODULE_INTERVAL,
"[%s:%d] interval table:<%s> schema has no table_id column", "[%s:%d] interval table:<%s> schema has no table_id column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -82,7 +82,7 @@ void *interval_schema_new(cJSON *json, struct table_manager *tbl_mgr,
item = cJSON_GetObjectItem(json, "custom"); item = cJSON_GetObjectItem(json, "custom");
if (item == NULL || item->type != cJSON_Object) { if (item == NULL || item->type != cJSON_Object) {
log_error(logger, MODULE_INTERVAL, log_fatal(logger, MODULE_INTERVAL,
"[%s:%d] interval table:<%s> schema has no custom column", "[%s:%d] interval table:<%s> schema has no custom column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -92,7 +92,7 @@ void *interval_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->item_id_column = custom_item->valueint; schema->item_id_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_INTERVAL, log_fatal(logger, MODULE_INTERVAL,
"[%s:%d] interval table:<%s> schema has no item_id column", "[%s:%d] interval table:<%s> schema has no item_id column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -102,7 +102,7 @@ void *interval_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->group_id_column = custom_item->valueint; schema->group_id_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_INTERVAL, log_fatal(logger, MODULE_INTERVAL,
"[%s:%d] interval table:<%s> schema has no group_id column", "[%s:%d] interval table:<%s> schema has no group_id column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -114,7 +114,7 @@ void *interval_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->district_column = custom_item->valueint; schema->district_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_INTERVAL, log_fatal(logger, MODULE_INTERVAL,
"[%s:%d] interval_plus table:<%s> schema has no district column", "[%s:%d] interval_plus table:<%s> schema has no district column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -125,7 +125,7 @@ void *interval_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->low_bound_column = custom_item->valueint; schema->low_bound_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_INTERVAL, log_fatal(logger, MODULE_INTERVAL,
"[%s:%d] interval table:<%s> schema has no low_bound column", "[%s:%d] interval table:<%s> schema has no low_bound column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -135,7 +135,7 @@ void *interval_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->up_bound_column = custom_item->valueint; schema->up_bound_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_INTERVAL, log_fatal(logger, MODULE_INTERVAL,
"[%s:%d] interval table:<%s> schema has no up_bound column", "[%s:%d] interval table:<%s> schema has no up_bound column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -283,7 +283,7 @@ interval_item_new(struct interval_schema *schema, const char *table_name,
int ret = get_column_pos(line, schema->item_id_column, &column_offset, int ret = get_column_pos(line, schema->item_id_column, &column_offset,
&column_len); &column_len);
if (ret < 0) { if (ret < 0) {
log_error(interval_rt->logger, MODULE_INTERVAL, log_fatal(interval_rt->logger, MODULE_INTERVAL,
"[%s:%d] interval table:<%s> has no item_id in line:%s", "[%s:%d] interval table:<%s> has no item_id in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -293,7 +293,7 @@ interval_item_new(struct interval_schema *schema, const char *table_name,
ret = get_column_pos(line, schema->group_id_column, &column_offset, ret = get_column_pos(line, schema->group_id_column, &column_offset,
&column_len); &column_len);
if (ret < 0) { if (ret < 0) {
log_error(interval_rt->logger, MODULE_INTERVAL, log_fatal(interval_rt->logger, MODULE_INTERVAL,
"[%s:%d] interval table:<%s> has no group_id in line:%s", "[%s:%d] interval table:<%s> has no group_id in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -309,7 +309,7 @@ interval_item_new(struct interval_schema *schema, const char *table_name,
} }
if (column_len > MAX_DISTRICT_STR_LEN) { if (column_len > MAX_DISTRICT_STR_LEN) {
log_error(interval_rt->logger, MODULE_INTERVAL, log_fatal(interval_rt->logger, MODULE_INTERVAL,
"[%s:%d] interval_plus table:<%s> district length exceed " "[%s:%d] interval_plus table:<%s> district length exceed "
"maximum:%d in line:%s", __FUNCTION__, __LINE__, table_name, "maximum:%d in line:%s", __FUNCTION__, __LINE__, table_name,
MAX_DISTRICT_STR_LEN, line); MAX_DISTRICT_STR_LEN, line);
@@ -327,7 +327,7 @@ interval_item_new(struct interval_schema *schema, const char *table_name,
ret = get_column_pos(line, schema->low_bound_column, &column_offset, &column_len); ret = get_column_pos(line, schema->low_bound_column, &column_offset, &column_len);
if (ret < 0) { if (ret < 0) {
log_error(interval_rt->logger, MODULE_INTERVAL, log_fatal(interval_rt->logger, MODULE_INTERVAL,
"[%s:%d] interval table:<%s> has no low_bound in line:%s", "[%s:%d] interval table:<%s> has no low_bound in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -336,7 +336,7 @@ interval_item_new(struct interval_schema *schema, const char *table_name,
ret = get_column_pos(line, schema->up_bound_column, &column_offset, &column_len); ret = get_column_pos(line, schema->up_bound_column, &column_offset, &column_len);
if (ret < 0) { if (ret < 0) {
log_error(interval_rt->logger, MODULE_INTERVAL, log_fatal(interval_rt->logger, MODULE_INTERVAL,
"[%s:%d] interval table:<%s> has no up_bound in line:%s", "[%s:%d] interval table:<%s> has no up_bound in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -375,7 +375,7 @@ static int interval_runtime_update_row(struct interval_runtime *interval_rt,
//add //add
ret = rcu_hash_add(interval_rt->item_hash, key, key_len, (void *)item); ret = rcu_hash_add(interval_rt->item_hash, key, key_len, (void *)item);
if (ret < 0) { if (ret < 0) {
log_error(interval_rt->logger, MODULE_INTERVAL, log_fatal(interval_rt->logger, MODULE_INTERVAL,
"[%s:%d] interval item(item_id:%lld) add to " "[%s:%d] interval item(item_id:%lld) add to "
"interavl_item_hash failed", __FUNCTION__, __LINE__, "interavl_item_hash failed", __FUNCTION__, __LINE__,
item->item_id); item->item_id);
@@ -400,7 +400,7 @@ int interval_runtime_update(void *interval_runtime, void *interval_schema,
long long item_id = get_column_value(line, schema->item_id_column); long long item_id = get_column_value(line, schema->item_id_column);
if (item_id < 0) { if (item_id < 0) {
log_error(interval_rt->logger, MODULE_INTERVAL, log_fatal(interval_rt->logger, MODULE_INTERVAL,
"[%s:%d] interval table:<%s> has no item_id(column seq:%d)" "[%s:%d] interval table:<%s> has no item_id(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name, " in table_line:%s", __FUNCTION__, __LINE__, table_name,
schema->item_id_column, line); schema->item_id_column, line);
@@ -410,7 +410,7 @@ int interval_runtime_update(void *interval_runtime, void *interval_schema,
int is_valid = get_column_value(line, valid_column); int is_valid = get_column_value(line, valid_column);
if (is_valid < 0) { if (is_valid < 0) {
log_error(interval_rt->logger, MODULE_INTERVAL, log_fatal(interval_rt->logger, MODULE_INTERVAL,
"[%s:%d] interval table:<%s> has no is_valid(column seq:%d)" "[%s:%d] interval table:<%s> has no is_valid(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name, " in table_line:%s", __FUNCTION__, __LINE__, table_name,
valid_column, line); valid_column, line);
@@ -499,7 +499,7 @@ int interval_runtime_commit(void *interval_runtime, const char *table_name,
(end.tv_nsec - start.tv_nsec) / 1000000; (end.tv_nsec - start.tv_nsec) / 1000000;
if (NULL == new_interval_matcher) { if (NULL == new_interval_matcher) {
log_error(interval_rt->logger, MODULE_INTERVAL, log_fatal(interval_rt->logger, MODULE_INTERVAL,
"[%s:%d] table[%s]rebuild interval_matcher engine failed " "[%s:%d] table[%s]rebuild interval_matcher engine failed "
"when update %zu interval rules", __FUNCTION__, __LINE__, "when update %zu interval rules", __FUNCTION__, __LINE__,
table_name, rule_cnt); table_name, rule_cnt);
@@ -556,9 +556,9 @@ int interval_runtime_scan(struct interval_runtime *interval_rt, int thread_id,
return 0; return 0;
} }
struct interval_result hit_results[MAX_SCANNER_HIT_ITEM_NUM]; struct interval_result hit_results[MAX_HIT_ITEM_NUM];
int n_hit_item = interval_matcher_match(interval_rt->matcher, integer, int n_hit_item = interval_matcher_match(interval_rt->matcher, integer,
hit_results, MAX_SCANNER_HIT_ITEM_NUM); hit_results, MAX_HIT_ITEM_NUM);
if (n_hit_item < 0) { if (n_hit_item < 0) {
return -1; return -1;
} }
@@ -589,7 +589,15 @@ int interval_runtime_scan(struct interval_runtime *interval_rt, int thread_id,
} }
next: next:
return compile_state_update(vtable_id, hit_maat_items, real_hit_item_cnt, state); if (NULL == state->compile_state) {
state->compile_state = compile_state_new();
alignment_int64_array_add(state->maat_inst->stat->compile_state_cnt,
state->thread_id, 1);
}
return compile_state_update(state->compile_state, state->maat_inst, vtable_id,
state->compile_table_id, state->scan_cnt,
hit_maat_items, real_hit_item_cnt);
} }
void interval_runtime_hit_inc(struct interval_runtime *interval_rt, int thread_id) void interval_runtime_hit_inc(struct interval_runtime *interval_rt, int thread_id)

View File

@@ -95,7 +95,7 @@ void *ip_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (item != NULL && item->type == cJSON_Number) { if (item != NULL && item->type == cJSON_Number) {
ip_schema->table_id = item->valueint; ip_schema->table_id = item->valueint;
} else { } else {
log_error(logger, MODULE_IP, log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> schema has no table_id column", "[%s:%d] ip table:<%s> schema has no table_id column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -103,7 +103,7 @@ void *ip_schema_new(cJSON *json, struct table_manager *tbl_mgr,
item = cJSON_GetObjectItem(json, "custom"); item = cJSON_GetObjectItem(json, "custom");
if (NULL == item || item->type != cJSON_Object) { if (NULL == item || item->type != cJSON_Object) {
log_error(logger, MODULE_IP, log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> schema has no custom column", "[%s:%d] ip table:<%s> schema has no custom column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -113,7 +113,7 @@ void *ip_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
ip_schema->item_id_column = custom_item->valueint; ip_schema->item_id_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_IP, log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> schema has no item_id column", "[%s:%d] ip table:<%s> schema has no item_id column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -123,7 +123,7 @@ void *ip_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
ip_schema->group_id_column = custom_item->valueint; ip_schema->group_id_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_IP, log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> schema has no group_id column", "[%s:%d] ip table:<%s> schema has no group_id column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -133,7 +133,7 @@ void *ip_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
ip_schema->addr_type_column = custom_item->valueint; ip_schema->addr_type_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_IP, log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> schema has no add_type column", "[%s:%d] ip table:<%s> schema has no add_type column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -143,7 +143,7 @@ void *ip_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
ip_schema->addr_format_column = custom_item->valueint; ip_schema->addr_format_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_IP, log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> schema has no addr_format column", "[%s:%d] ip table:<%s> schema has no addr_format column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -153,7 +153,7 @@ void *ip_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
ip_schema->ip1_column = custom_item->valueint; ip_schema->ip1_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_IP, log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> schema has no ip1 column", "[%s:%d] ip table:<%s> schema has no ip1 column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -163,7 +163,7 @@ void *ip_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
ip_schema->ip2_column = custom_item->valueint; ip_schema->ip2_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_IP, log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> schema has no ip2 column", "[%s:%d] ip table:<%s> schema has no ip2 column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -173,7 +173,7 @@ void *ip_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
ip_schema->port_format_column = custom_item->valueint; ip_schema->port_format_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_IP, log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> schema has no port_format column", "[%s:%d] ip table:<%s> schema has no port_format column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -183,7 +183,7 @@ void *ip_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
ip_schema->port1_column = custom_item->valueint; ip_schema->port1_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_IP, log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> schema has no port1 column", "[%s:%d] ip table:<%s> schema has no port1 column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -193,7 +193,7 @@ void *ip_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
ip_schema->port2_column = custom_item->valueint; ip_schema->port2_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_IP, log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> schema has no port2 column", "[%s:%d] ip table:<%s> schema has no port2 column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -203,7 +203,7 @@ void *ip_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
ip_schema->protocol_column = custom_item->valueint; ip_schema->protocol_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_IP, log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> schema has no protocol column", "[%s:%d] ip table:<%s> schema has no protocol column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -236,7 +236,7 @@ ip_item_new(struct ip_schema *ip_schema, const char *table_name,
int ret = get_column_pos(line, ip_schema->item_id_column, &column_offset, int ret = get_column_pos(line, ip_schema->item_id_column, &column_offset,
&column_len); &column_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_IP, log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> has no item_id in line:%s", "[%s:%d] ip table:<%s> has no item_id in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -246,7 +246,7 @@ ip_item_new(struct ip_schema *ip_schema, const char *table_name,
ret = get_column_pos(line, ip_schema->group_id_column, &column_offset, ret = get_column_pos(line, ip_schema->group_id_column, &column_offset,
&column_len); &column_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_IP, log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> has no group_id in line:%s", "[%s:%d] ip table:<%s> has no group_id in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -256,7 +256,7 @@ ip_item_new(struct ip_schema *ip_schema, const char *table_name,
ret = get_column_pos(line, ip_schema->addr_type_column, &column_offset, ret = get_column_pos(line, ip_schema->addr_type_column, &column_offset,
&column_len); &column_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_IP, log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> has no addr_type in line:%s", "[%s:%d] ip table:<%s> has no addr_type in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -264,7 +264,7 @@ ip_item_new(struct ip_schema *ip_schema, const char *table_name,
ip_item->addr_type = atoi(line + column_offset); ip_item->addr_type = atoi(line + column_offset);
if (ip_item->addr_type != IPv4 && ip_item->addr_type != IPv6) { if (ip_item->addr_type != IPv4 && ip_item->addr_type != IPv6) {
log_error(logger, MODULE_IP, log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> has invalid addr type:%d in line:%s", "[%s:%d] ip table:<%s> has invalid addr type:%d in line:%s",
__FUNCTION__, __LINE__, table_name, ip_item->addr_type, line); __FUNCTION__, __LINE__, table_name, ip_item->addr_type, line);
goto error; goto error;
@@ -273,14 +273,14 @@ ip_item_new(struct ip_schema *ip_schema, const char *table_name,
ret = get_column_pos(line, ip_schema->addr_format_column, &column_offset, ret = get_column_pos(line, ip_schema->addr_format_column, &column_offset,
&column_len); &column_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_IP, log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> has no addr_format in line:%s", "[%s:%d] ip table:<%s> has no addr_format in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
} }
memcpy(addr_format, (line + column_offset), column_len); memcpy(addr_format, (line + column_offset), column_len);
if (IP_FORMAT_UNKNOWN == ip_format_str2int(addr_format)) { if (IP_FORMAT_UNKNOWN == ip_format_str2int(addr_format)) {
log_error(logger, MODULE_IP, log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> has invalid addr_format, " "[%s:%d] ip table:<%s> has invalid addr_format, "
"should be single/range/CIDR/mask in line:%s", "should be single/range/CIDR/mask in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
@@ -290,7 +290,7 @@ ip_item_new(struct ip_schema *ip_schema, const char *table_name,
ret = get_column_pos(line, ip_schema->ip1_column, &column_offset, ret = get_column_pos(line, ip_schema->ip1_column, &column_offset,
&column_len); &column_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_IP, log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> has no ip1 in line:%s", "[%s:%d] ip table:<%s> has no ip1 in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -300,7 +300,7 @@ ip_item_new(struct ip_schema *ip_schema, const char *table_name,
ret = get_column_pos(line, ip_schema->ip2_column, &column_offset, ret = get_column_pos(line, ip_schema->ip2_column, &column_offset,
&column_len); &column_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_IP, log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> has no ip2 in line:%s", "[%s:%d] ip table:<%s> has no ip2 in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -311,7 +311,7 @@ ip_item_new(struct ip_schema *ip_schema, const char *table_name,
ret = ip_format2range(ip_item->addr_type, ip_format_str2int(addr_format), ret = ip_format2range(ip_item->addr_type, ip_format_str2int(addr_format),
ip1_str, ip2_str, &ip_item->ipv4.min_ip, &ip_item->ipv4.max_ip); ip1_str, ip2_str, &ip_item->ipv4.min_ip, &ip_item->ipv4.max_ip);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_IP, log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> ip_format2range(ip4) failed in line:%s", "[%s:%d] ip table:<%s> ip_format2range(ip4) failed in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -321,7 +321,7 @@ ip_item_new(struct ip_schema *ip_schema, const char *table_name,
ret = ip_format2range(ip_item->addr_type, ip_format_str2int(addr_format), ret = ip_format2range(ip_item->addr_type, ip_format_str2int(addr_format),
ip1_str, ip2_str, ip_item->ipv6.min_ip, ip_item->ipv6.max_ip); ip1_str, ip2_str, ip_item->ipv6.min_ip, ip_item->ipv6.max_ip);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_IP, log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> ip_format2range(ip6) failed in line:%s", "[%s:%d] ip table:<%s> ip_format2range(ip6) failed in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -331,7 +331,7 @@ ip_item_new(struct ip_schema *ip_schema, const char *table_name,
ret = get_column_pos(line, ip_schema->port_format_column, &column_offset, ret = get_column_pos(line, ip_schema->port_format_column, &column_offset,
&column_len); &column_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_IP, log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> has no port_format in line:%s", "[%s:%d] ip table:<%s> has no port_format in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -339,7 +339,7 @@ ip_item_new(struct ip_schema *ip_schema, const char *table_name,
memcpy(port_format, (line + column_offset), column_len); memcpy(port_format, (line + column_offset), column_len);
if (PORT_FORMAT_UNKNOWN == port_format_str2int(port_format)) { if (PORT_FORMAT_UNKNOWN == port_format_str2int(port_format)) {
log_error(logger, MODULE_IP, log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> has invalid port_format, " "[%s:%d] ip table:<%s> has invalid port_format, "
"should be single/range in line:%s", "should be single/range in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
@@ -350,7 +350,7 @@ ip_item_new(struct ip_schema *ip_schema, const char *table_name,
ret = get_column_pos(line, ip_schema->port1_column, &column_offset, ret = get_column_pos(line, ip_schema->port1_column, &column_offset,
&column_len); &column_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_IP, log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s>) has no port1 in line:%s", "[%s:%d] ip table:<%s>) has no port1 in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -360,7 +360,7 @@ ip_item_new(struct ip_schema *ip_schema, const char *table_name,
ret = get_column_pos(line, ip_schema->port2_column, &column_offset, ret = get_column_pos(line, ip_schema->port2_column, &column_offset,
&column_len); &column_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_IP, log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> has no port2 in line:%s", "[%s:%d] ip table:<%s> has no port2 in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -370,7 +370,7 @@ ip_item_new(struct ip_schema *ip_schema, const char *table_name,
ret = get_column_pos(line, ip_schema->protocol_column, &column_offset, ret = get_column_pos(line, ip_schema->protocol_column, &column_offset,
&column_len); &column_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_IP, log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> has no protocol in line:%s", "[%s:%d] ip table:<%s> has no protocol in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -379,7 +379,7 @@ ip_item_new(struct ip_schema *ip_schema, const char *table_name,
ip_item->proto = atoi(line + column_offset); ip_item->proto = atoi(line + column_offset);
if (ip_item->proto != IP_PROTO_ANY && ip_item->proto != IP_PROTO_ICMP && if (ip_item->proto != IP_PROTO_ANY && ip_item->proto != IP_PROTO_ICMP &&
ip_item->proto != IP_PROTO_TCP && ip_item->proto != IP_PROTO_UDP) { ip_item->proto != IP_PROTO_TCP && ip_item->proto != IP_PROTO_UDP) {
log_error(logger, MODULE_IP, log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> protocol:%d is illegal in line:%s", "[%s:%d] ip table:<%s> protocol:%d is illegal in line:%s",
__FUNCTION__, __LINE__, table_name, ip_item->proto, line); __FUNCTION__, __LINE__, table_name, ip_item->proto, line);
goto error; goto error;
@@ -387,7 +387,7 @@ ip_item_new(struct ip_schema *ip_schema, const char *table_name,
if (ip_item->proto != IP_PROTO_ANY && ip_item->proto != IP_PROTO_ICMP && if (ip_item->proto != IP_PROTO_ANY && ip_item->proto != IP_PROTO_ICMP &&
ip_item->proto != IP_PROTO_TCP && ip_item->proto != IP_PROTO_UDP) { ip_item->proto != IP_PROTO_TCP && ip_item->proto != IP_PROTO_UDP) {
log_error(logger, MODULE_IP, log_fatal(logger, MODULE_IP,
"[%s:%d] ip table:<%s> protocol:%d is illegal in line:%s", "[%s:%d] ip table:<%s> protocol:%d is illegal in line:%s",
__FUNCTION__, __LINE__, table_name, ip_item->proto, line); __FUNCTION__, __LINE__, table_name, ip_item->proto, line);
goto error; goto error;
@@ -506,7 +506,7 @@ static int ip_runtime_update_row(struct ip_runtime *ip_rt, char *key, size_t key
// add // add
ret = rcu_hash_add(ip_rt->item_hash, key, key_len, (void *)item); ret = rcu_hash_add(ip_rt->item_hash, key, key_len, (void *)item);
if (ret < 0) { if (ret < 0) {
log_error(ip_rt->logger, MODULE_IP, log_fatal(ip_rt->logger, MODULE_IP,
"[%s:%d] ip item(item_id:%lld) add to ip runtime htable failed", "[%s:%d] ip item(item_id:%lld) add to ip runtime htable failed",
__FUNCTION__, __LINE__, item->item_id); __FUNCTION__, __LINE__, item->item_id);
return -1; return -1;
@@ -529,7 +529,7 @@ int ip_runtime_update(void *ip_runtime, void *ip_schema,
long long item_id = get_column_value(line, schema->item_id_column); long long item_id = get_column_value(line, schema->item_id_column);
if (item_id < 0) { if (item_id < 0) {
log_error(ip_rt->logger, MODULE_IP, log_fatal(ip_rt->logger, MODULE_IP,
"[%s:%d] ip table:<%s> has no item_id(column seq:%d)" "[%s:%d] ip table:<%s> has no item_id(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name, " in table_line:%s", __FUNCTION__, __LINE__, table_name,
schema->item_id_column, line); schema->item_id_column, line);
@@ -539,7 +539,7 @@ int ip_runtime_update(void *ip_runtime, void *ip_schema,
int is_valid = get_column_value(line, valid_column); int is_valid = get_column_value(line, valid_column);
if (is_valid < 0) { if (is_valid < 0) {
log_error(ip_rt->logger, MODULE_IP, log_fatal(ip_rt->logger, MODULE_IP,
"[%s:%d] ip table:<%s> has no is_valid(column seq:%d)" "[%s:%d] ip table:<%s> has no is_valid(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name, " in table_line:%s", __FUNCTION__, __LINE__, table_name,
valid_column, line); valid_column, line);
@@ -625,7 +625,7 @@ int ip_runtime_commit(void *ip_runtime, const char *table_name,
(end.tv_nsec - start.tv_nsec) / 1000000; (end.tv_nsec - start.tv_nsec) / 1000000;
if (NULL == new_ip_matcher) { if (NULL == new_ip_matcher) {
log_error(ip_rt->logger, MODULE_IP, log_fatal(ip_rt->logger, MODULE_IP,
"[%s:%d] table[%s] rebuild ip_matcher engine failed " "[%s:%d] table[%s] rebuild ip_matcher engine failed "
"when update %zu ip rules", __FUNCTION__, __LINE__, "when update %zu ip rules", __FUNCTION__, __LINE__,
table_name, rule_cnt); table_name, rule_cnt);
@@ -709,7 +709,7 @@ int ip_runtime_scan(struct ip_runtime *ip_rt, int thread_id, int ip_type,
} }
struct ip_data scan_data; struct ip_data scan_data;
struct scan_result ip_results[MAX_SCANNER_HIT_ITEM_NUM]; struct scan_result ip_results[MAX_HIT_ITEM_NUM];
if (ip_type == IPv4) { if (ip_type == IPv4) {
scan_data.type = IPv4; scan_data.type = IPv4;
@@ -724,14 +724,14 @@ int ip_runtime_scan(struct ip_runtime *ip_rt, int thread_id, int ip_type,
int ret = 0; int ret = 0;
size_t real_hit_item_cnt = 0; size_t real_hit_item_cnt = 0;
struct maat_item hit_maat_items[MAX_SCANNER_HIT_ITEM_NUM]; struct maat_item hit_maat_items[MAX_HIT_ITEM_NUM];
if (NULL == ip_rt->ip_matcher) { if (NULL == ip_rt->ip_matcher) {
return 0; return 0;
} }
int n_hit_ip_item = ip_matcher_match(ip_rt->ip_matcher, &scan_data, int n_hit_ip_item = ip_matcher_match(ip_rt->ip_matcher, &scan_data,
ip_results, MAX_SCANNER_HIT_ITEM_NUM); ip_results, MAX_HIT_ITEM_NUM);
if (n_hit_ip_item < 0) { if (n_hit_ip_item < 0) {
return -1; return -1;
} }
@@ -761,7 +761,15 @@ int ip_runtime_scan(struct ip_runtime *ip_rt, int thread_id, int ip_type,
} }
next: next:
return compile_state_update(vtable_id, hit_maat_items, real_hit_item_cnt, state); if (NULL == state->compile_state) {
state->compile_state = compile_state_new();
alignment_int64_array_add(state->maat_inst->stat->compile_state_cnt,
state->thread_id, 1);
}
return compile_state_update(state->compile_state, state->maat_inst, vtable_id,
state->compile_table_id, state->scan_cnt,
hit_maat_items, real_hit_item_cnt);
} }
void ip_runtime_hit_inc(struct ip_runtime *ip_rt, int thread_id) void ip_runtime_hit_inc(struct ip_runtime *ip_rt, int thread_id)

View File

@@ -57,7 +57,7 @@ void *ip_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (item != NULL && item->type == cJSON_Number) { if (item != NULL && item->type == cJSON_Number) {
schema->table_id = item->valueint; schema->table_id = item->valueint;
} else { } else {
log_error(logger, MODULE_IP_PLUGIN, log_fatal(logger, MODULE_IP_PLUGIN,
"[%s:%d] ip_plugin table:<%s> schema has no table_id column", "[%s:%d] ip_plugin table:<%s> schema has no table_id column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -65,7 +65,7 @@ void *ip_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
item = cJSON_GetObjectItem(json, "custom"); item = cJSON_GetObjectItem(json, "custom");
if (NULL == item || item->type != cJSON_Object) { if (NULL == item || item->type != cJSON_Object) {
log_error(logger, MODULE_IP_PLUGIN, log_fatal(logger, MODULE_IP_PLUGIN,
"[%s:%d] ip_plugin table:<%s> schema has no custom column", "[%s:%d] ip_plugin table:<%s> schema has no custom column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -75,7 +75,7 @@ void *ip_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->item_id_column = custom_item->valueint; schema->item_id_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_IP_PLUGIN, log_fatal(logger, MODULE_IP_PLUGIN,
"[%s:%d] ip_plugin table:<%s> schema has no item_id column", "[%s:%d] ip_plugin table:<%s> schema has no item_id column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -85,7 +85,7 @@ void *ip_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->ip_type_column = custom_item->valueint; schema->ip_type_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_IP_PLUGIN, log_fatal(logger, MODULE_IP_PLUGIN,
"[%s:%d] ip_plugin table:<%s> schema has no ip_type column", "[%s:%d] ip_plugin table:<%s> schema has no ip_type column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -95,7 +95,7 @@ void *ip_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->start_ip_column = custom_item->valueint; schema->start_ip_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_IP_PLUGIN, log_fatal(logger, MODULE_IP_PLUGIN,
"[%s:%d] ip_plugin table:<%s> schema has no start_ip column", "[%s:%d] ip_plugin table:<%s> schema has no start_ip column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -105,7 +105,7 @@ void *ip_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->end_ip_column = custom_item->valueint; schema->end_ip_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_IP_PLUGIN, log_fatal(logger, MODULE_IP_PLUGIN,
"[%s:%d] ip_plugin table:<%s> schema has no end_ip column", "[%s:%d] ip_plugin table:<%s> schema has no end_ip column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -152,7 +152,7 @@ static int ip_plugin_accept_tag_match(struct ip_plugin_schema *schema,
int ret = get_column_pos(line, schema->rule_tag_column, int ret = get_column_pos(line, schema->rule_tag_column,
&column_offset, &column_len); &column_offset, &column_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_IP_PLUGIN, log_fatal(logger, MODULE_IP_PLUGIN,
"[%s:%d] ip_plugin table:<%s> has no rule_tag in line:%s", "[%s:%d] ip_plugin table:<%s> has no rule_tag in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
return TAG_MATCH_ERR; return TAG_MATCH_ERR;
@@ -164,14 +164,14 @@ static int ip_plugin_accept_tag_match(struct ip_plugin_schema *schema,
ret = table_manager_accept_tags_match(schema->ref_tbl_mgr, tag_str); ret = table_manager_accept_tags_match(schema->ref_tbl_mgr, tag_str);
FREE(tag_str); FREE(tag_str);
if (TAG_MATCH_ERR == ret) { if (TAG_MATCH_ERR == ret) {
log_error(logger, MODULE_IP_PLUGIN, log_fatal(logger, MODULE_IP_PLUGIN,
"[%s:%d] ip_plugin table:<%s> has invalid tag format in line:%s", "[%s:%d] ip_plugin table:<%s> has invalid tag format in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
return TAG_MATCH_ERR; return TAG_MATCH_ERR;
} }
if (TAG_MATCH_UNMATCHED == ret) { if (TAG_MATCH_UNMATCHED == ret) {
log_error(logger, MODULE_IP_PLUGIN, log_fatal(logger, MODULE_IP_PLUGIN,
"[%s:%d] ip_plugin table:<%s> has unmatched tag in line:%s", "[%s:%d] ip_plugin table:<%s> has unmatched tag in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
return TAG_MATCH_UNMATCHED; return TAG_MATCH_UNMATCHED;
@@ -199,7 +199,7 @@ ip_plugin_rule_new(struct ip_plugin_schema *schema, const char *table_name,
ret = get_column_pos(line, schema->item_id_column, &column_offset, &column_len); ret = get_column_pos(line, schema->item_id_column, &column_offset, &column_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_IP_PLUGIN, log_fatal(logger, MODULE_IP_PLUGIN,
"[%s:%d] ip_plugin table:<%s> has no item_id in line:%s", "[%s:%d] ip_plugin table:<%s> has no item_id in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -208,14 +208,14 @@ ip_plugin_rule_new(struct ip_plugin_schema *schema, const char *table_name,
ret = get_column_pos(line, schema->ip_type_column, &column_offset, &column_len); ret = get_column_pos(line, schema->ip_type_column, &column_offset, &column_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_IP_PLUGIN, log_fatal(logger, MODULE_IP_PLUGIN,
"[%s:%d] ip_plugin table:<%s> has no ip_type in line:%s", "[%s:%d] ip_plugin table:<%s> has no ip_type in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
} }
ip_plugin_rule->type = atoi(line + column_offset); ip_plugin_rule->type = atoi(line + column_offset);
if (ip_plugin_rule->type != IPv4 && ip_plugin_rule->type != IPv6) { if (ip_plugin_rule->type != IPv4 && ip_plugin_rule->type != IPv6) {
log_error(logger, MODULE_IP_PLUGIN, log_fatal(logger, MODULE_IP_PLUGIN,
"[%s:%d] ip_plugin table:<%s> ip_type[%d] invalid in line:%s", "[%s:%d] ip_plugin table:<%s> ip_type[%d] invalid in line:%s",
__FUNCTION__, __LINE__, table_name, ip_plugin_rule->type, line); __FUNCTION__, __LINE__, table_name, ip_plugin_rule->type, line);
goto error; goto error;
@@ -223,7 +223,7 @@ ip_plugin_rule_new(struct ip_plugin_schema *schema, const char *table_name,
ret = get_column_pos(line, schema->start_ip_column, &column_offset, &column_len); ret = get_column_pos(line, schema->start_ip_column, &column_offset, &column_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_IP_PLUGIN, log_fatal(logger, MODULE_IP_PLUGIN,
"[%s:%d] ip_plugin table:<%s> has no start_ip in line:%s", "[%s:%d] ip_plugin table:<%s> has no start_ip in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -232,7 +232,7 @@ ip_plugin_rule_new(struct ip_plugin_schema *schema, const char *table_name,
ret = get_column_pos(line, schema->end_ip_column, &column_offset, &column_len); ret = get_column_pos(line, schema->end_ip_column, &column_offset, &column_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_IP_PLUGIN, log_fatal(logger, MODULE_IP_PLUGIN,
"[%s:%d] ip_plugin table:<%s> has no end_ip in line:%s", "[%s:%d] ip_plugin table:<%s> has no end_ip in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -245,7 +245,7 @@ ip_plugin_rule_new(struct ip_plugin_schema *schema, const char *table_name,
&ip_plugin_rule->ipv4_rule.start_ip, &ip_plugin_rule->ipv4_rule.start_ip,
&ip_plugin_rule->ipv4_rule.end_ip); &ip_plugin_rule->ipv4_rule.end_ip);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_IP_PLUGIN, log_fatal(logger, MODULE_IP_PLUGIN,
"[%s:%d] ip_plugin table:<%s>> ip_format2range(ip4) failed in line:%s", "[%s:%d] ip_plugin table:<%s>> ip_format2range(ip4) failed in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -257,7 +257,7 @@ ip_plugin_rule_new(struct ip_plugin_schema *schema, const char *table_name,
ip_plugin_rule->ipv6_rule.start_ip, ip_plugin_rule->ipv6_rule.start_ip,
ip_plugin_rule->ipv6_rule.end_ip); ip_plugin_rule->ipv6_rule.end_ip);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_IP_PLUGIN, log_fatal(logger, MODULE_IP_PLUGIN,
"[%s:%d] ip_plugin table:<%s> ip_format2range(ip6) failed in line:%s", "[%s:%d] ip_plugin table:<%s> ip_format2range(ip6) failed in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -285,7 +285,7 @@ int ip_plugin_table_set_ex_container_schema(void *ip_plugin_schema, int table_id
struct ip_plugin_schema *schema = (struct ip_plugin_schema *)ip_plugin_schema; struct ip_plugin_schema *schema = (struct ip_plugin_schema *)ip_plugin_schema;
if (1 == schema->container_schema.set_flag) { if (1 == schema->container_schema.set_flag) {
log_error(schema->logger, MODULE_IP_PLUGIN, log_fatal(schema->logger, MODULE_IP_PLUGIN,
"[%s:%d] ip_plugin table(table_id:%d) ex_container_schema has been set, can't set again", "[%s:%d] ip_plugin table(table_id:%d) ex_container_schema has been set, can't set again",
__FUNCTION__, __LINE__, table_id); __FUNCTION__, __LINE__, table_id);
return -1; return -1;
@@ -498,7 +498,7 @@ int ip_plugin_runtime_commit(void *ip_plugin_runtime, const char *table_name,
(end.tv_nsec - start.tv_nsec) / 1000000; (end.tv_nsec - start.tv_nsec) / 1000000;
if (NULL == new_ip_matcher) { if (NULL == new_ip_matcher) {
log_error(ip_plugin_rt->logger, MODULE_IP_PLUGIN, log_fatal(ip_plugin_rt->logger, MODULE_IP_PLUGIN,
"[%s:%d] ip_plugin table[%s] rebuild ip_matcher failed when " "[%s:%d] ip_plugin table[%s] rebuild ip_matcher failed when "
"update %zu rules", __FUNCTION__, __LINE__, table_name, rule_cnt); "update %zu rules", __FUNCTION__, __LINE__, table_name, rule_cnt);
ret = -1; ret = -1;

View File

@@ -79,7 +79,7 @@ void *ipport_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (item != NULL && item->type == cJSON_Number) { if (item != NULL && item->type == cJSON_Number) {
schema->table_id = item->valueint; schema->table_id = item->valueint;
} else { } else {
log_error(logger, MODULE_IPPORT_PLUGIN, log_fatal(logger, MODULE_IPPORT_PLUGIN,
"[%s:%d] ipport_plugin table:<%s> schema has no table_id column", "[%s:%d] ipport_plugin table:<%s> schema has no table_id column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -87,7 +87,7 @@ void *ipport_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
item = cJSON_GetObjectItem(json, "custom"); item = cJSON_GetObjectItem(json, "custom");
if (NULL == item || item->type != cJSON_Object) { if (NULL == item || item->type != cJSON_Object) {
log_error(logger, MODULE_IPPORT_PLUGIN, log_fatal(logger, MODULE_IPPORT_PLUGIN,
"[%s:%d] ipport_plugin table:<%s> schema has no custom column", "[%s:%d] ipport_plugin table:<%s> schema has no custom column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -97,7 +97,7 @@ void *ipport_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->item_id_column = custom_item->valueint; schema->item_id_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_IPPORT_PLUGIN, log_fatal(logger, MODULE_IPPORT_PLUGIN,
"[%s:%d] ipport_plugin table:<%s> schema has no item_id column", "[%s:%d] ipport_plugin table:<%s> schema has no item_id column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -107,7 +107,7 @@ void *ipport_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->ip_type_column = custom_item->valueint; schema->ip_type_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_IPPORT_PLUGIN, log_fatal(logger, MODULE_IPPORT_PLUGIN,
"[%s:%d] ipport_plugin table:<%s> schema has no ip_type column", "[%s:%d] ipport_plugin table:<%s> schema has no ip_type column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -117,7 +117,7 @@ void *ipport_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->ip_addr_column = custom_item->valueint; schema->ip_addr_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_IPPORT_PLUGIN, log_fatal(logger, MODULE_IPPORT_PLUGIN,
"[%s:%d] ipport_plugin table:<%s> schema has no ip_addr column", "[%s:%d] ipport_plugin table:<%s> schema has no ip_addr column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -127,7 +127,7 @@ void *ipport_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->port1_column = custom_item->valueint; schema->port1_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_IPPORT_PLUGIN, log_fatal(logger, MODULE_IPPORT_PLUGIN,
"[%s:%d] ipport_plugin table:<%s> schema has no port1 column", "[%s:%d] ipport_plugin table:<%s> schema has no port1 column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -137,7 +137,7 @@ void *ipport_plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (custom_item != NULL && custom_item->type == cJSON_Number) { if (custom_item != NULL && custom_item->type == cJSON_Number) {
schema->port2_column = custom_item->valueint; schema->port2_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_IPPORT_PLUGIN, log_fatal(logger, MODULE_IPPORT_PLUGIN,
"[%s:%d] ipport_plugin table:<%s> schema has no port2 column", "[%s:%d] ipport_plugin table:<%s> schema has no port2 column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -176,7 +176,7 @@ int ipport_plugin_table_set_ex_container_schema(void *ipport_plugin_schema, int
struct ipport_plugin_schema *schema = (struct ipport_plugin_schema *)ipport_plugin_schema; struct ipport_plugin_schema *schema = (struct ipport_plugin_schema *)ipport_plugin_schema;
if (1 == schema->container_schema.set_flag) { if (1 == schema->container_schema.set_flag) {
log_error(schema->logger, MODULE_IPPORT_PLUGIN, log_fatal(schema->logger, MODULE_IPPORT_PLUGIN,
"[%s:%d] ipport_plugin table(table_id:%d) ex_container_schema has been set" "[%s:%d] ipport_plugin table(table_id:%d) ex_container_schema has been set"
", can't set again", __FUNCTION__, __LINE__, table_id); ", can't set again", __FUNCTION__, __LINE__, table_id);
return -1; return -1;
@@ -265,7 +265,7 @@ ipport_item_new(struct ipport_plugin_schema *schema, const char *table_name,
int ret = get_column_pos(line, schema->item_id_column, &column_offset, int ret = get_column_pos(line, schema->item_id_column, &column_offset,
&column_len); &column_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_IPPORT_PLUGIN, log_fatal(logger, MODULE_IPPORT_PLUGIN,
"[%s:%d] ipport table:<%s> has no item_id in line:%s", "[%s:%d] ipport table:<%s> has no item_id in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -275,7 +275,7 @@ ipport_item_new(struct ipport_plugin_schema *schema, const char *table_name,
ret = get_column_pos(line, schema->ip_type_column, &column_offset, ret = get_column_pos(line, schema->ip_type_column, &column_offset,
&column_len); &column_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_IPPORT_PLUGIN, log_fatal(logger, MODULE_IPPORT_PLUGIN,
"[%s:%d] ipport table:<%s> has no ip_type in line:%s", "[%s:%d] ipport table:<%s> has no ip_type in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -283,7 +283,7 @@ ipport_item_new(struct ipport_plugin_schema *schema, const char *table_name,
ipport_item->ip_type = atoi(line + column_offset); ipport_item->ip_type = atoi(line + column_offset);
if (ipport_item->ip_type != IPV4 && ipport_item->ip_type != IPV6) { if (ipport_item->ip_type != IPV4 && ipport_item->ip_type != IPV6) {
log_error(logger, MODULE_IPPORT_PLUGIN, log_fatal(logger, MODULE_IPPORT_PLUGIN,
"[%s:%d] ipport table:<%s> has invalid ip type:%d in line:%s", "[%s:%d] ipport table:<%s> has invalid ip type:%d in line:%s",
__FUNCTION__, __LINE__, table_name, ipport_item->ip_type, line); __FUNCTION__, __LINE__, table_name, ipport_item->ip_type, line);
goto error; goto error;
@@ -292,7 +292,7 @@ ipport_item_new(struct ipport_plugin_schema *schema, const char *table_name,
ret = get_column_pos(line, schema->ip_addr_column, &column_offset, ret = get_column_pos(line, schema->ip_addr_column, &column_offset,
&column_len); &column_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_IPPORT_PLUGIN, log_fatal(logger, MODULE_IPPORT_PLUGIN,
"[%s:%d] ipport table:<%s> has no ip_addr in line:%s", "[%s:%d] ipport table:<%s> has no ip_addr in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -303,7 +303,7 @@ ipport_item_new(struct ipport_plugin_schema *schema, const char *table_name,
uint32_t ipv4_addr = 0; uint32_t ipv4_addr = 0;
ret = inet_pton(AF_INET, ip_str, &ipv4_addr); ret = inet_pton(AF_INET, ip_str, &ipv4_addr);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_IPPORT_PLUGIN, log_fatal(logger, MODULE_IPPORT_PLUGIN,
"[%s:%d] ipport table:<%s> ip_format2range(ip4) failed in line:%s", "[%s:%d] ipport table:<%s> ip_format2range(ip4) failed in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -315,7 +315,7 @@ ipport_item_new(struct ipport_plugin_schema *schema, const char *table_name,
uint32_t ipv6_addr[4] = {0}; uint32_t ipv6_addr[4] = {0};
ret = inet_pton(AF_INET6, ip_str, ipv6_addr); ret = inet_pton(AF_INET6, ip_str, ipv6_addr);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_IPPORT_PLUGIN, log_fatal(logger, MODULE_IPPORT_PLUGIN,
"[%s:%d] ipport table:<%s> ip_format2range(ip6) failed in line:%s", "[%s:%d] ipport table:<%s> ip_format2range(ip6) failed in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -326,7 +326,7 @@ ipport_item_new(struct ipport_plugin_schema *schema, const char *table_name,
ret = get_column_pos(line, schema->port1_column, &column_offset, ret = get_column_pos(line, schema->port1_column, &column_offset,
&column_len); &column_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_IPPORT_PLUGIN, log_fatal(logger, MODULE_IPPORT_PLUGIN,
"[%s:%d] ipport table:<%s>) has no port1 in line:%s", "[%s:%d] ipport table:<%s>) has no port1 in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -336,7 +336,7 @@ ipport_item_new(struct ipport_plugin_schema *schema, const char *table_name,
ret = get_column_pos(line, schema->port2_column, &column_offset, ret = get_column_pos(line, schema->port2_column, &column_offset,
&column_len); &column_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_IPPORT_PLUGIN, log_fatal(logger, MODULE_IPPORT_PLUGIN,
"[%s:%d] ipport table:<%s> has no port2 in line:%s", "[%s:%d] ipport table:<%s> has no port2 in line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
goto error; goto error;
@@ -514,7 +514,7 @@ int ipport_plugin_runtime_commit(void *ipport_plugin_runtime, const char *table_
long long time_elapse_ms = (end.tv_sec - start.tv_sec) * 1000 + long long time_elapse_ms = (end.tv_sec - start.tv_sec) * 1000 +
(end.tv_nsec - start.tv_nsec) / 1000000; (end.tv_nsec - start.tv_nsec) / 1000000;
if (NULL == new_matcher) { if (NULL == new_matcher) {
log_error(ipport_plugin_rt->logger, MODULE_IPPORT_PLUGIN, log_fatal(ipport_plugin_rt->logger, MODULE_IPPORT_PLUGIN,
"[%s:%d] ipport_plugin table[%s] rebuild ipport_matcher failed when " "[%s:%d] ipport_plugin table[%s] rebuild ipport_matcher failed when "
"update %zu rules", __FUNCTION__, __LINE__, table_name, rule_cnt); "update %zu rules", __FUNCTION__, __LINE__, table_name, rule_cnt);
ret = -1; ret = -1;

View File

@@ -96,7 +96,7 @@ void *plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
cJSON *custom_item = NULL; cJSON *custom_item = NULL;
cJSON *item = cJSON_GetObjectItem(json, "table_id"); cJSON *item = cJSON_GetObjectItem(json, "table_id");
if (NULL == item || item->type != cJSON_Number) { if (NULL == item || item->type != cJSON_Number) {
log_error(logger, MODULE_PLUGIN, log_fatal(logger, MODULE_PLUGIN,
"[%s:%d]plugin table:<%s> schema has no table_id column", "[%s:%d]plugin table:<%s> schema has no table_id column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -108,7 +108,7 @@ void *plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
if (item != NULL && item->type == cJSON_Object) { if (item != NULL && item->type == cJSON_Object) {
custom_item = cJSON_GetObjectItem(item, "key"); custom_item = cJSON_GetObjectItem(item, "key");
if (NULL == custom_item || custom_item->type != cJSON_Number) { if (NULL == custom_item || custom_item->type != cJSON_Number) {
log_error(logger, MODULE_PLUGIN, log_fatal(logger, MODULE_PLUGIN,
"[%s:%d]plugin table:<%s> schema has no key column", "[%s:%d]plugin table:<%s> schema has no key column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -117,7 +117,7 @@ void *plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
custom_item = cJSON_GetObjectItem(item, "key_type"); custom_item = cJSON_GetObjectItem(item, "key_type");
if (NULL == custom_item || custom_item->type != cJSON_String) { if (NULL == custom_item || custom_item->type != cJSON_String) {
log_error(logger, MODULE_PLUGIN, log_fatal(logger, MODULE_PLUGIN,
"[%s:%d]plugin table:<%s> schema has no key_type column", "[%s:%d]plugin table:<%s> schema has no key_type column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -129,7 +129,7 @@ void *plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
schema->key_type = PLUGIN_KEY_TYPE_INTEGER; schema->key_type = PLUGIN_KEY_TYPE_INTEGER;
custom_item = cJSON_GetObjectItem(item, "key_len"); custom_item = cJSON_GetObjectItem(item, "key_len");
if (NULL == custom_item || custom_item->type != cJSON_Number) { if (NULL == custom_item || custom_item->type != cJSON_Number) {
log_error(logger, MODULE_PLUGIN, log_fatal(logger, MODULE_PLUGIN,
"[%s:%d]plugin table:<%s> schema integer key must" "[%s:%d]plugin table:<%s> schema integer key must"
" have key_len column", __FUNCTION__, __LINE__, " have key_len column", __FUNCTION__, __LINE__,
table_name); table_name);
@@ -140,7 +140,7 @@ void *plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
schema->key_type = PLUGIN_KEY_TYPE_IP_ADDR; schema->key_type = PLUGIN_KEY_TYPE_IP_ADDR;
custom_item = cJSON_GetObjectItem(item, "addr_type"); custom_item = cJSON_GetObjectItem(item, "addr_type");
if (NULL == custom_item || custom_item->type != cJSON_Number) { if (NULL == custom_item || custom_item->type != cJSON_Number) {
log_error(logger, MODULE_PLUGIN, log_fatal(logger, MODULE_PLUGIN,
"[%s:%d]plugin table:<%s> schema ip_addr key must" "[%s:%d]plugin table:<%s> schema ip_addr key must"
" have addr_type column", __FUNCTION__, __LINE__, " have addr_type column", __FUNCTION__, __LINE__,
table_name); table_name);
@@ -148,7 +148,7 @@ void *plugin_schema_new(cJSON *json, struct table_manager *tbl_mgr,
} }
schema->addr_type_column = custom_item->valueint; schema->addr_type_column = custom_item->valueint;
} else { } else {
log_error(logger, MODULE_PLUGIN, log_fatal(logger, MODULE_PLUGIN,
"[%s:%d]plugin table:<%s> schema key_type:%s is illegal, " "[%s:%d]plugin table:<%s> schema key_type:%s is illegal, "
"just allow {pointer}, {integer}, {ip_addr}", "just allow {pointer}, {integer}, {ip_addr}",
__FUNCTION__, __LINE__, table_name, custom_item->valuestring); __FUNCTION__, __LINE__, table_name, custom_item->valuestring);
@@ -212,7 +212,7 @@ int plugin_table_add_callback(void *plugin_schema, int table_id,
size_t idx = schema->cb_cnt; size_t idx = schema->cb_cnt;
if (idx == MAX_PLUGIN_PER_TABLE) { if (idx == MAX_PLUGIN_PER_TABLE) {
log_error(logger, MODULE_PLUGIN, log_fatal(logger, MODULE_PLUGIN,
"[%s:%d] the plugin number of table_id: %d exceed maxium:%d", "[%s:%d] the plugin number of table_id: %d exceed maxium:%d",
__FUNCTION__, __LINE__, table_id, MAX_PLUGIN_PER_TABLE); __FUNCTION__, __LINE__, table_id, MAX_PLUGIN_PER_TABLE);
return -1; return -1;
@@ -271,7 +271,7 @@ int plugin_table_set_ex_container_schema(void *plugin_schema, int table_id,
struct plugin_schema *schema = (struct plugin_schema *)plugin_schema; struct plugin_schema *schema = (struct plugin_schema *)plugin_schema;
if (1 == schema->container_schema.set_flag) { if (1 == schema->container_schema.set_flag) {
log_error(schema->logger, MODULE_PLUGIN, log_fatal(schema->logger, MODULE_PLUGIN,
"[%s:%d] plugin table(table_id:%d) ex_container_schema" "[%s:%d] plugin table(table_id:%d) ex_container_schema"
" has been set, can't set again", __FUNCTION__, __LINE__, " has been set, can't set again", __FUNCTION__, __LINE__,
table_id); table_id);
@@ -405,7 +405,7 @@ static int plugin_accept_tag_match(struct plugin_schema *schema,
int ret = get_column_pos(line, schema->rule_tag_column, &column_offset, int ret = get_column_pos(line, schema->rule_tag_column, &column_offset,
&column_len); &column_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_PLUGIN, log_fatal(logger, MODULE_PLUGIN,
"[%s:%d] table: <%s> has no rule_tag(column_seq:%d) " "[%s:%d] table: <%s> has no rule_tag(column_seq:%d) "
"in table_line:%s", __FUNCTION__, __LINE__, table_name, "in table_line:%s", __FUNCTION__, __LINE__, table_name,
schema->rule_tag_column, line); schema->rule_tag_column, line);
@@ -418,14 +418,14 @@ static int plugin_accept_tag_match(struct plugin_schema *schema,
ret = table_manager_accept_tags_match(schema->ref_tbl_mgr, tag_str); ret = table_manager_accept_tags_match(schema->ref_tbl_mgr, tag_str);
FREE(tag_str); FREE(tag_str);
if (TAG_MATCH_ERR == ret) { if (TAG_MATCH_ERR == ret) {
log_error(logger, MODULE_PLUGIN, log_fatal(logger, MODULE_PLUGIN,
"[%s:%d] table: <%s> has invalid tag format in table_line:%s", "[%s:%d] table: <%s> has invalid tag format in table_line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
return TAG_MATCH_ERR; return TAG_MATCH_ERR;
} }
if (TAG_MATCH_UNMATCHED == ret) { if (TAG_MATCH_UNMATCHED == ret) {
log_error(logger, MODULE_PLUGIN, log_fatal(logger, MODULE_PLUGIN,
"[%s:%d] table: <%s> has unmatched tag in table_line:%s", "[%s:%d] table: <%s> has unmatched tag in table_line:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
return TAG_MATCH_UNMATCHED; return TAG_MATCH_UNMATCHED;
@@ -445,7 +445,7 @@ static int plugin_table_line_get_key(struct plugin_schema *schema,
int ret = get_column_pos(line, schema->key_column, &key_offset, &key_len); int ret = get_column_pos(line, schema->key_column, &key_offset, &key_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_PLUGIN, log_fatal(logger, MODULE_PLUGIN,
"[%s:%d] plugin table:<%s> has no key(column seq:%d)" "[%s:%d] plugin table:<%s> has no key(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name, " in table_line:%s", __FUNCTION__, __LINE__, table_name,
schema->key_column, line); schema->key_column, line);
@@ -453,7 +453,7 @@ static int plugin_table_line_get_key(struct plugin_schema *schema,
} }
if (key_len > MAX_KEYWORDS_STR_LEN) { if (key_len > MAX_KEYWORDS_STR_LEN) {
log_error(logger, MODULE_PLUGIN, log_fatal(logger, MODULE_PLUGIN,
"[%s:%d] plugin table:<%s> key(column seq:%d) length exceed maxium:%d" "[%s:%d] plugin table:<%s> key(column seq:%d) length exceed maxium:%d"
" in table_line:%s", __FUNCTION__, __LINE__, table_name, " in table_line:%s", __FUNCTION__, __LINE__, table_name,
schema->key_column, MAX_KEYWORDS_STR_LEN, line); schema->key_column, MAX_KEYWORDS_STR_LEN, line);
@@ -475,7 +475,7 @@ static int plugin_table_line_get_key(struct plugin_schema *schema,
*dst_key_len = schema->key_len; *dst_key_len = schema->key_len;
} else if (schema->key_type == PLUGIN_KEY_TYPE_IP_ADDR) { } else if (schema->key_type == PLUGIN_KEY_TYPE_IP_ADDR) {
if (key_len >= INET6_ADDRSTRLEN) { if (key_len >= INET6_ADDRSTRLEN) {
log_error(logger, MODULE_PLUGIN, log_fatal(logger, MODULE_PLUGIN,
"[%s:%d] plugin table:<%s> ip_key too long(illegal) in " "[%s:%d] plugin table:<%s> ip_key too long(illegal) in "
"table_line:%s", __FUNCTION__, __LINE__, table_name, line); "table_line:%s", __FUNCTION__, __LINE__, table_name, line);
return -1; return -1;
@@ -486,7 +486,7 @@ static int plugin_table_line_get_key(struct plugin_schema *schema,
ret = get_column_pos(line, schema->addr_type_column, &addr_type_offset, ret = get_column_pos(line, schema->addr_type_column, &addr_type_offset,
&addr_type_len); &addr_type_len);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_PLUGIN, log_fatal(logger, MODULE_PLUGIN,
"[%s:%d] plugin table:<%s> has no addr_type(column seq:%d)" "[%s:%d] plugin table:<%s> has no addr_type(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name, " in table_line:%s", __FUNCTION__, __LINE__, table_name,
schema->addr_type_column, line); schema->addr_type_column, line);
@@ -502,7 +502,7 @@ static int plugin_table_line_get_key(struct plugin_schema *schema,
uint32_t ipv4_addr; uint32_t ipv4_addr;
ret = inet_pton(AF_INET, ip_key, &ipv4_addr); ret = inet_pton(AF_INET, ip_key, &ipv4_addr);
if (ret <= 0) { if (ret <= 0) {
log_error(logger, MODULE_PLUGIN, log_fatal(logger, MODULE_PLUGIN,
"[%s:%d] plugin table:<%s> ipv4 key(column seq:%d)" "[%s:%d] plugin table:<%s> ipv4 key(column seq:%d)"
" illegal in table_line:%s", __FUNCTION__, __LINE__, " illegal in table_line:%s", __FUNCTION__, __LINE__,
table_name, schema->key_column, line); table_name, schema->key_column, line);
@@ -515,7 +515,7 @@ static int plugin_table_line_get_key(struct plugin_schema *schema,
uint8_t ipv6_addr[16]; uint8_t ipv6_addr[16];
ret = inet_pton(AF_INET6, ip_key, ipv6_addr); ret = inet_pton(AF_INET6, ip_key, ipv6_addr);
if (ret <= 0) { if (ret <= 0) {
log_error(logger, MODULE_PLUGIN, log_fatal(logger, MODULE_PLUGIN,
"[%s:%d] plugin table:<%s> ipv6 key(column seq:%d)" "[%s:%d] plugin table:<%s> ipv6 key(column seq:%d)"
" illegal in table_line:%s", __FUNCTION__, __LINE__, " illegal in table_line:%s", __FUNCTION__, __LINE__,
table_name, schema->key_column, line); table_name, schema->key_column, line);
@@ -525,7 +525,7 @@ static int plugin_table_line_get_key(struct plugin_schema *schema,
memcpy(dst_key, (char *)&ipv6_addr, sizeof(ipv6_addr)); memcpy(dst_key, (char *)&ipv6_addr, sizeof(ipv6_addr));
*dst_key_len = sizeof(ipv6_addr); *dst_key_len = sizeof(ipv6_addr);
} else { } else {
log_error(logger, MODULE_PLUGIN, log_fatal(logger, MODULE_PLUGIN,
"[%s:%d] plugin table:<%s> addr_type:%d illegal, just" "[%s:%d] plugin table:<%s> addr_type:%d illegal, just"
" allow{4, 6}, table_line:%s", __FUNCTION__, __LINE__, " allow{4, 6}, table_line:%s", __FUNCTION__, __LINE__,
table_name, addr_type, line); table_name, addr_type, line);
@@ -549,7 +549,7 @@ int plugin_runtime_update(void *plugin_runtime, void *plugin_schema,
struct plugin_runtime *plugin_rt = (struct plugin_runtime *)plugin_runtime; struct plugin_runtime *plugin_rt = (struct plugin_runtime *)plugin_runtime;
int is_valid = get_column_value(line, valid_column); int is_valid = get_column_value(line, valid_column);
if (is_valid < 0) { if (is_valid < 0) {
log_error(plugin_rt->logger, MODULE_PLUGIN, log_fatal(plugin_rt->logger, MODULE_PLUGIN,
"[%s:%d] plugin table:<%s> has no is_valid(column seq:%d)" "[%s:%d] plugin table:<%s> has no is_valid(column seq:%d)"
" in table_line:%s", __FUNCTION__, __LINE__, table_name, " in table_line:%s", __FUNCTION__, __LINE__, table_name,
valid_column, line); valid_column, line);

View File

@@ -110,7 +110,7 @@ static void _get_foregin_keys(struct serial_rule *p_rule, int *foreign_columns,
foreign_columns[i], foreign_columns[i],
&foreign_key_size); &foreign_key_size);
if (NULL == p_foreign) { if (NULL == p_foreign) {
log_error(logger, MODULE_REDIS_MONITOR, log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] Get %s,%lld foreign keys failed: No %dth column", "[%s:%d] Get %s,%lld foreign keys failed: No %dth column",
__FUNCTION__, __LINE__, p_rule->table_name, p_rule->rule_id, __FUNCTION__, __LINE__, p_rule->table_name, p_rule->rule_id,
foreign_columns[i]); foreign_columns[i]);
@@ -123,7 +123,7 @@ static void _get_foregin_keys(struct serial_rule *p_rule, int *foreign_columns,
} }
if (0 != strncmp(p_foreign, foreign_source_prefix, strlen(foreign_source_prefix))) { if (0 != strncmp(p_foreign, foreign_source_prefix, strlen(foreign_source_prefix))) {
log_error(logger, MODULE_REDIS_MONITOR, log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] Get %s,%lld foreign key failed: Invalid source prefix %s", "[%s:%d] Get %s,%lld foreign key failed: Invalid source prefix %s",
__FUNCTION__, __LINE__, p_rule->table_name, p_rule->rule_id, p_foreign); __FUNCTION__, __LINE__, p_rule->table_name, p_rule->rule_id, p_foreign);
continue; continue;
@@ -245,7 +245,7 @@ static int _get_maat_redis_value(redisContext *c, struct serial_rule *rule_list,
for (i = 0; i < rule_num; i++) { for (i = 0; i < rule_num; i++) {
ret = maat_wrap_redis_get_reply(c, &reply); ret = maat_wrap_redis_get_reply(c, &reply);
if (ret == REDIS_ERR) { if (ret == REDIS_ERR) {
log_error(logger, MODULE_REDIS_MONITOR, log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] Redis GET %s:%s,%lld failed, redis server error", "[%s:%d] Redis GET %s:%s,%lld failed, redis server error",
__FUNCTION__, __LINE__, mr_key_prefix[rule_list[i].op], __FUNCTION__, __LINE__, mr_key_prefix[rule_list[i].op],
rule_list[i].table_name, rule_list[i].rule_id); rule_list[i].table_name, rule_list[i].rule_id);
@@ -260,7 +260,7 @@ static int _get_maat_redis_value(redisContext *c, struct serial_rule *rule_list,
retry_ids[failed_cnt] = i; retry_ids[failed_cnt] = i;
failed_cnt++; failed_cnt++;
} else { } else {
log_error(logger, MODULE_REDIS_MONITOR, log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] Redis GET %s:%s,%lld failed", "[%s:%d] Redis GET %s:%s,%lld failed",
__FUNCTION__, __LINE__, mr_key_prefix[rule_list[i].op], __FUNCTION__, __LINE__, mr_key_prefix[rule_list[i].op],
rule_list[i].table_name, rule_list[i].rule_id); rule_list[i].table_name, rule_list[i].rule_id);
@@ -291,7 +291,7 @@ static int _get_maat_redis_value(redisContext *c, struct serial_rule *rule_list,
idx = retry_ids[i]; idx = retry_ids[i];
ret = maat_wrap_redis_get_reply(c, &reply); ret = maat_wrap_redis_get_reply(c, &reply);
if (ret == REDIS_ERR) { if (ret == REDIS_ERR) {
log_error(logger, MODULE_REDIS_MONITOR, log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] redis command %s failed, redis server error", "[%s:%d] redis command %s failed, redis server error",
__FUNCTION__, __LINE__, redis_cmd); __FUNCTION__, __LINE__, redis_cmd);
FREE(retry_ids); FREE(retry_ids);
@@ -302,12 +302,12 @@ static int _get_maat_redis_value(redisContext *c, struct serial_rule *rule_list,
rule_list[idx].table_line = maat_strdup(reply->str); rule_list[idx].table_line = maat_strdup(reply->str);
} else if(reply->type==REDIS_REPLY_ERROR) { } else if(reply->type==REDIS_REPLY_ERROR) {
//Deal with Redis response: "Loading Redis is loading the database in memory" //Deal with Redis response: "Loading Redis is loading the database in memory"
log_error(logger, MODULE_REDIS_MONITOR, log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] redis command %s error, reply type=%d, error str=%s", "[%s:%d] redis command %s error, reply type=%d, error str=%s",
__FUNCTION__, __LINE__, redis_cmd, reply->type, reply->str); __FUNCTION__, __LINE__, redis_cmd, reply->type, reply->str);
} else { } else {
//Handle type "nil" //Handle type "nil"
log_error(logger, MODULE_REDIS_MONITOR, log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] redis command %s failed, reply type=%d", "[%s:%d] redis command %s failed, reply type=%d",
__FUNCTION__, __LINE__, redis_cmd, reply->type); __FUNCTION__, __LINE__, redis_cmd, reply->type);
} }
@@ -362,7 +362,7 @@ static int get_inc_key_list(long long instance_version, long long target_version
mr_status_sset, instance_version, mr_status_sset, instance_version,
target_version); target_version);
if (NULL == reply) { if (NULL == reply) {
log_error(logger, MODULE_REDIS_MONITOR, log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] GET %s failed with a NULL reply, error: %s", "[%s:%d] GET %s failed with a NULL reply, error: %s",
__FUNCTION__, __LINE__, mr_status_sset, c->errstr); __FUNCTION__, __LINE__, mr_status_sset, c->errstr);
return -1; return -1;
@@ -381,7 +381,7 @@ static int get_inc_key_list(long long instance_version, long long target_version
mr_status_sset, mr_status_sset,
reply->element[0]->str); reply->element[0]->str);
if (tmp_reply->type != REDIS_REPLY_STRING) { if (tmp_reply->type != REDIS_REPLY_STRING) {
log_error(logger, MODULE_REDIS_MONITOR, log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] ZSCORE %s %s failed Version: %lld->%lld", "[%s:%d] ZSCORE %s %s failed Version: %lld->%lld",
__FUNCTION__, __LINE__, mr_status_sset, __FUNCTION__, __LINE__, mr_status_sset,
reply->element[0]->str, instance_version, reply->element[0]->str, instance_version,
@@ -417,7 +417,7 @@ static int get_inc_key_list(long long instance_version, long long target_version
int ret = sscanf(reply->element[i]->str, "%3s,%[^,],%lld", int ret = sscanf(reply->element[i]->str, "%3s,%[^,],%lld",
op_str, s_rule[j].table_name, &(s_rule[j].rule_id)); op_str, s_rule[j].table_name, &(s_rule[j].rule_id));
if (ret != 3 || s_rule[i].rule_id < 0) { if (ret != 3 || s_rule[i].rule_id < 0) {
log_error(logger, MODULE_REDIS_MONITOR, log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] Invalid Redis Key: %s", "[%s:%d] Invalid Redis Key: %s",
__FUNCTION__, __LINE__, reply->element[i]->str); __FUNCTION__, __LINE__, reply->element[i]->str);
continue; continue;
@@ -428,7 +428,7 @@ static int get_inc_key_list(long long instance_version, long long target_version
} else if(strncmp(op_str, "DEL", strlen("DEL")) == 0) { } else if(strncmp(op_str, "DEL", strlen("DEL")) == 0) {
s_rule[j].op = MAAT_OP_DEL; s_rule[j].op = MAAT_OP_DEL;
} else { } else {
log_error(logger, MODULE_REDIS_MONITOR, log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] Invalid Redis Key: %s", "[%s:%d] Invalid Redis Key: %s",
__FUNCTION__, __LINE__, reply->element[i]->str); __FUNCTION__, __LINE__, reply->element[i]->str);
continue; continue;
@@ -489,7 +489,7 @@ int maat_get_rm_key_list(redisContext *c, long long instance_version,
redisReply *reply = (redisReply *)redisCommand(c, "GET MAAT_VERSION"); redisReply *reply = (redisReply *)redisCommand(c, "GET MAAT_VERSION");
if (reply != NULL) { if (reply != NULL) {
if (reply->type == REDIS_REPLY_NIL || reply->type == REDIS_REPLY_ERROR) { if (reply->type == REDIS_REPLY_NIL || reply->type == REDIS_REPLY_ERROR) {
log_error(logger, MODULE_REDIS_MONITOR, log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] GET MAAT_VERSION failed, maybe Redis is busy", "[%s:%d] GET MAAT_VERSION failed, maybe Redis is busy",
__FUNCTION__, __LINE__); __FUNCTION__, __LINE__);
freeReplyObject(reply); freeReplyObject(reply);
@@ -497,7 +497,7 @@ int maat_get_rm_key_list(redisContext *c, long long instance_version,
return -1; return -1;
} }
} else { } else {
log_error(logger, MODULE_REDIS_MONITOR, log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] GET MAAT_VERSION failed with NULL reply, error: %s", "[%s:%d] GET MAAT_VERSION failed with NULL reply, error: %s",
__FUNCTION__, __LINE__, c->errstr); __FUNCTION__, __LINE__, c->errstr);
return -1; return -1;
@@ -506,7 +506,7 @@ int maat_get_rm_key_list(redisContext *c, long long instance_version,
long long redis_version = maat_read_redis_integer(reply); long long redis_version = maat_read_redis_integer(reply);
if (redis_version < 0) { if (redis_version < 0) {
if (reply->type == REDIS_REPLY_ERROR) { if (reply->type == REDIS_REPLY_ERROR) {
log_error(logger, MODULE_REDIS_MONITOR, log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] Redis Communication error: %s", "[%s:%d] Redis Communication error: %s",
__FUNCTION__, __LINE__, reply->str); __FUNCTION__, __LINE__, reply->str);
} }
@@ -525,7 +525,7 @@ int maat_get_rm_key_list(redisContext *c, long long instance_version,
} }
if (redis_version < instance_version) { if (redis_version < instance_version) {
log_error(logger, MODULE_REDIS_MONITOR, log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] VERSION roll back MAAT: %lld -> Redis: %lld", "[%s:%d] VERSION roll back MAAT: %lld -> Redis: %lld",
__FUNCTION__, __LINE__, instance_version, redis_version); __FUNCTION__, __LINE__, instance_version, redis_version);
goto FULL_UPDATE; goto FULL_UPDATE;
@@ -568,7 +568,7 @@ int maat_get_rm_key_list(redisContext *c, long long instance_version,
return rule_num; return rule_num;
FULL_UPDATE: FULL_UPDATE:
log_info(logger, MODULE_REDIS_MONITOR, log_fatal(logger, MODULE_REDIS_MONITOR,
"Initiate full update from instance_version %lld to %lld", "Initiate full update from instance_version %lld to %lld",
instance_version, redis_version); instance_version, redis_version);
size_t append_cmd_cnt = 0; size_t append_cmd_cnt = 0;
@@ -591,14 +591,14 @@ FULL_UPDATE:
reply = maat_wrap_redis_command(c, "EXEC"); reply = maat_wrap_redis_command(c, "EXEC");
if (NULL == reply) { if (NULL == reply) {
log_error(logger, MODULE_REDIS_MONITOR, log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] Redis Communication error: %s", "[%s:%d] Redis Communication error: %s",
__FUNCTION__, __LINE__, c->errstr); __FUNCTION__, __LINE__, c->errstr);
return -1; return -1;
} }
if (reply->type != REDIS_REPLY_ARRAY) { if (reply->type != REDIS_REPLY_ARRAY) {
log_error(logger, MODULE_REDIS_MONITOR, log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] Invalid Redis Key List type %d", "[%s:%d] Invalid Redis Key List type %d",
__FUNCTION__, __LINE__, reply->type); __FUNCTION__, __LINE__, reply->type);
freeReplyObject(reply); freeReplyObject(reply);
@@ -609,7 +609,7 @@ FULL_UPDATE:
*new_version = maat_read_redis_integer(reply->element[0]); *new_version = maat_read_redis_integer(reply->element[0]);
redisReply *sub_reply = reply->element[1]; redisReply *sub_reply = reply->element[1];
if (sub_reply->type != REDIS_REPLY_ARRAY) { if (sub_reply->type != REDIS_REPLY_ARRAY) {
log_error(logger, MODULE_REDIS_MONITOR, log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] Invalid Redis Key List type %d", "[%s:%d] Invalid Redis Key List type %d",
__FUNCTION__, __LINE__, sub_reply->type); __FUNCTION__, __LINE__, sub_reply->type);
freeReplyObject(reply); freeReplyObject(reply);
@@ -621,7 +621,7 @@ FULL_UPDATE:
s_rule_array = ALLOC(struct serial_rule, sub_reply->elements); s_rule_array = ALLOC(struct serial_rule, sub_reply->elements);
for (i = 0, full_idx = 0; i < sub_reply->elements; i++) { for (i = 0, full_idx = 0; i < sub_reply->elements; i++) {
if (sub_reply->element[i]->type != REDIS_REPLY_STRING) { if (sub_reply->element[i]->type != REDIS_REPLY_STRING) {
log_error(logger, MODULE_REDIS_MONITOR, log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] Invalid Redis Key Type: %d", "[%s:%d] Invalid Redis Key Type: %d",
__FUNCTION__, __LINE__, sub_reply->element[i]->type); __FUNCTION__, __LINE__, sub_reply->element[i]->type);
continue; continue;
@@ -634,7 +634,7 @@ FULL_UPDATE:
if (ret != 2 || s_rule_array[full_idx].rule_id < 0 || if (ret != 2 || s_rule_array[full_idx].rule_id < 0 ||
strlen(s_rule_array[full_idx].table_name) == 0) { strlen(s_rule_array[full_idx].table_name) == 0) {
log_error(logger, MODULE_REDIS_MONITOR, log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] Invalid Redis Key Format: %s", "[%s:%d] Invalid Redis Key Format: %s",
__FUNCTION__, __LINE__, sub_reply->element[i]->str); __FUNCTION__, __LINE__, sub_reply->element[i]->str);
continue; continue;
@@ -687,7 +687,7 @@ static void _get_foreign_conts(redisContext *c, struct serial_rule *rule_list,
ret = remove(rule_list[i].f_keys[j].filename); ret = remove(rule_list[i].f_keys[j].filename);
if (ret == -1) { if (ret == -1) {
log_error(logger, MODULE_REDIS_MONITOR, log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] Foreign content file %s remove failed", "[%s:%d] Foreign content file %s remove failed",
__FUNCTION__, __LINE__, rule_list[i].f_keys[j].filename); __FUNCTION__, __LINE__, rule_list[i].f_keys[j].filename);
} }
@@ -719,7 +719,7 @@ static void _get_foreign_conts(redisContext *c, struct serial_rule *rule_list,
for (i = 0; i < key_num; i++) { for (i = 0; i < key_num; i++) {
ret = maat_wrap_redis_get_reply(c, &reply); ret = maat_wrap_redis_get_reply(c, &reply);
if (ret == REDIS_ERR) { if (ret == REDIS_ERR) {
log_error(logger, MODULE_REDIS_MONITOR, log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] Get %s,%lld foreign key %s content failed, redis server error", "[%s:%d] Get %s,%lld foreign key %s content failed, redis server error",
__FUNCTION__, __LINE__, __FUNCTION__, __LINE__,
rule_list[track[i].rule_idx].table_name, rule_list[track[i].rule_idx].table_name,
@@ -729,7 +729,7 @@ static void _get_foreign_conts(redisContext *c, struct serial_rule *rule_list,
} }
if (reply->type != REDIS_REPLY_STRING) { if (reply->type != REDIS_REPLY_STRING) {
log_error(logger, MODULE_REDIS_MONITOR, log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] Get %s,%lld foreign key %s content failed", "[%s:%d] Get %s,%lld foreign key %s content failed",
__FUNCTION__, __LINE__, __FUNCTION__, __LINE__,
rule_list[track[i].rule_idx].table_name, rule_list[track[i].rule_idx].table_name,
@@ -740,7 +740,7 @@ static void _get_foreign_conts(redisContext *c, struct serial_rule *rule_list,
s_rule = rule_list+track[i].rule_idx; s_rule = rule_list+track[i].rule_idx;
FILE *fp = fopen(s_rule->f_keys[track[i].foreign_idx].filename, "w"); FILE *fp = fopen(s_rule->f_keys[track[i].foreign_idx].filename, "w");
if (NULL == fp) { if (NULL == fp) {
log_error(logger, MODULE_REDIS_MONITOR, log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] Write foreign content failed: fopen %s error", __FUNCTION__, "[%s:%d] Write foreign content failed: fopen %s error", __FUNCTION__,
__LINE__, s_rule->f_keys[track[i].foreign_idx].filename); __LINE__, s_rule->f_keys[track[i].foreign_idx].filename);
} else { } else {
@@ -1134,7 +1134,7 @@ int maat_cmd_write_rule(redisContext *c, struct serial_rule *s_rule,
} }
rule_seq = expected_reply[i].s_rule_seq; rule_seq = expected_reply[i].s_rule_seq;
log_error(logger, MODULE_REDIS_MONITOR, log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] %s %s %lld failed, rule id maybe conflict or not exist", "[%s:%d] %s %s %lld failed, rule id maybe conflict or not exist",
__FUNCTION__, __LINE__, mr_op_str[s_rule[rule_seq].op], __FUNCTION__, __LINE__, mr_op_str[s_rule[rule_seq].op],
s_rule[rule_seq].table_name, s_rule[rule_seq].rule_id); s_rule[rule_seq].table_name, s_rule[rule_seq].rule_id);
@@ -1159,7 +1159,7 @@ error_out:
if (renew_num > 0 && renew_allowed != 1) { if (renew_num > 0 && renew_allowed != 1) {
for (i = 0; i < (unsigned int)serial_rule_num; i++) { for (i = 0; i < (unsigned int)serial_rule_num; i++) {
if (s_rule[i].op == MAAT_OP_RENEW_TIMEOUT) { if (s_rule[i].op == MAAT_OP_RENEW_TIMEOUT) {
log_error(logger, MODULE_REDIS_MONITOR, log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] %s %s %lld is not allowed due to lock contention", "[%s:%d] %s %s %lld is not allowed due to lock contention",
__FUNCTION__, __LINE__, mr_op_str[MAAT_OP_RENEW_TIMEOUT], __FUNCTION__, __LINE__, mr_op_str[MAAT_OP_RENEW_TIMEOUT],
s_rule[i].table_name, s_rule[i].rule_id); s_rule[i].table_name, s_rule[i].rule_id);
@@ -1278,13 +1278,13 @@ static void check_maat_expiration(redisContext *c, struct log_handle *logger)
int success_cnt = maat_cmd_write_rule(c, s_rule, s_rule_num, server_time, logger); int success_cnt = maat_cmd_write_rule(c, s_rule, s_rule_num, server_time, logger);
if (success_cnt < 0) { if (success_cnt < 0) {
log_error(logger, MODULE_REDIS_MONITOR, "[%s:%d] maat_cmd_write_rule failed.", log_fatal(logger, MODULE_REDIS_MONITOR, "[%s:%d] maat_cmd_write_rule failed.",
__FUNCTION__, __LINE__); __FUNCTION__, __LINE__);
} else if (success_cnt == (int)s_rule_num) { } else if (success_cnt == (int)s_rule_num) {
log_info(logger, MODULE_REDIS_MONITOR, log_info(logger, MODULE_REDIS_MONITOR,
"Succesfully expired %zu rules in Redis", s_rule_num); "Succesfully expired %zu rules in Redis", s_rule_num);
} else { } else {
log_error(logger, MODULE_REDIS_MONITOR, log_fatal(logger, MODULE_REDIS_MONITOR,
"[%s:%d] Failed to expired %d of %zu rules in Redis, try later", "[%s:%d] Failed to expired %d of %zu rules in Redis, try later",
__FUNCTION__, __LINE__, s_rule_num - success_cnt, s_rule_num); __FUNCTION__, __LINE__, s_rule_num - success_cnt, s_rule_num);
} }
@@ -1369,7 +1369,7 @@ void redis_monitor_traverse(long long version, struct source_redis_ctx *mr_ctx,
if (ret < 0) { if (ret < 0) {
redisFree(mr_ctx->read_ctx); redisFree(mr_ctx->read_ctx);
mr_ctx->read_ctx = NULL; mr_ctx->read_ctx = NULL;
log_error(maat_inst->logger, MODULE_REDIS_MONITOR, log_fatal(maat_inst->logger, MODULE_REDIS_MONITOR,
"[%s:%d] Get Redis value failed, abandon update and close connection", "[%s:%d] Get Redis value failed, abandon update and close connection",
__FUNCTION__, __LINE__); __FUNCTION__, __LINE__);
goto clean_up; goto clean_up;
@@ -1417,7 +1417,7 @@ void redis_monitor_traverse(long long version, struct source_redis_ctx *mr_ctx,
valid_column = table_manager_get_valid_column(maat_inst->tbl_mgr, table_id); valid_column = table_manager_get_valid_column(maat_inst->tbl_mgr, table_id);
ret = validate_line(rule_list[i].table_line, valid_column); ret = validate_line(rule_list[i].table_line, valid_column);
if (ret < 0) { if (ret < 0) {
log_error(maat_inst->logger, MODULE_REDIS_MONITOR, log_fatal(maat_inst->logger, MODULE_REDIS_MONITOR,
"[%s:%d] Validate line failed, invaid format %s", "[%s:%d] Validate line failed, invaid format %s",
__FUNCTION__, __LINE__, rule_list[i].table_line); __FUNCTION__, __LINE__, rule_list[i].table_line);
continue; continue;
@@ -1435,7 +1435,7 @@ void redis_monitor_traverse(long long version, struct source_redis_ctx *mr_ctx,
finish_fn(u_param); finish_fn(u_param);
if (call_update_num < rule_num) { if (call_update_num < rule_num) {
log_error(maat_inst->logger, MODULE_REDIS_MONITOR, log_fatal(maat_inst->logger, MODULE_REDIS_MONITOR,
"[%s:%d] Load %d entries to match engine, no table: %d, empty value: %d", "[%s:%d] Load %d entries to match engine, no table: %d, empty value: %d",
__FUNCTION__, __LINE__, call_update_num, no_table_num, empty_value_num); __FUNCTION__, __LINE__, call_update_num, no_table_num, empty_value_num);
} }

View File

@@ -131,7 +131,7 @@ static int maat_update_cb(const char *table_name, const char *line, void *u_para
struct maat *maat_inst =(struct maat *)u_param; struct maat *maat_inst =(struct maat *)u_param;
int table_id = table_manager_get_table_id(maat_inst->tbl_mgr, table_name); int table_id = table_manager_get_table_id(maat_inst->tbl_mgr, table_name);
if (table_id < 0) { if (table_id < 0) {
log_error(maat_inst->logger, MODULE_MAAT_RULE, log_fatal(maat_inst->logger, MODULE_MAAT_RULE,
"[%s:%d] update warning, unknown table name %s", "[%s:%d] update warning, unknown table name %s",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
return -1; return -1;
@@ -151,7 +151,7 @@ static int maat_update_cb(const char *table_name, const char *line, void *u_para
int ret = table_manager_update_runtime(maat_inst->tbl_mgr, table_name, int ret = table_manager_update_runtime(maat_inst->tbl_mgr, table_name,
(int)conj_parent_table_ids[i], line, update_type); (int)conj_parent_table_ids[i], line, update_type);
if (ret < 0) { if (ret < 0) {
log_error(maat_inst->logger, MODULE_MAAT_RULE, log_fatal(maat_inst->logger, MODULE_MAAT_RULE,
"[%s:%d] table<%s> update runtime error for rule:%s", "[%s:%d] table<%s> update runtime error for rule:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
continue; continue;
@@ -161,7 +161,7 @@ static int maat_update_cb(const char *table_name, const char *line, void *u_para
int ret = table_manager_update_runtime(maat_inst->tbl_mgr, table_name, int ret = table_manager_update_runtime(maat_inst->tbl_mgr, table_name,
table_id, line, update_type); table_id, line, update_type);
if (ret < 0) { if (ret < 0) {
log_error(maat_inst->logger, MODULE_MAAT_RULE, log_fatal(maat_inst->logger, MODULE_MAAT_RULE,
"[%s:%d] table<%s> update runtime error for rules:%s", "[%s:%d] table<%s> update runtime error for rules:%s",
__FUNCTION__, __LINE__, table_name, line); __FUNCTION__, __LINE__, table_name, line);
return -1; return -1;
@@ -302,7 +302,7 @@ void maat_read_full_config(struct maat *maat_inst)
} }
if (NULL == maat_inst->creating_maat_rt) { if (NULL == maat_inst->creating_maat_rt) {
log_error(maat_inst->logger, MODULE_MAAT_RULE, log_fatal(maat_inst->logger, MODULE_MAAT_RULE,
"[%s:%d] At initiation: NO effective rule in redis %s:%hu db%d", "[%s:%d] At initiation: NO effective rule in redis %s:%hu db%d",
__FUNCTION__, __LINE__, redis_ctx->redis_ip, redis_ctx->redis_port, __FUNCTION__, __LINE__, redis_ctx->redis_ip, redis_ctx->redis_port,
redis_ctx->redis_db); redis_ctx->redis_db);
@@ -315,7 +315,7 @@ void maat_read_full_config(struct maat *maat_inst)
maat_inst, maat_inst->opts.decrypt_key, maat_inst, maat_inst->opts.decrypt_key,
maat_inst->logger); maat_inst->logger);
if (NULL == maat_inst->creating_maat_rt) { if (NULL == maat_inst->creating_maat_rt) {
log_error(maat_inst->logger, MODULE_MAAT_RULE, log_fatal(maat_inst->logger, MODULE_MAAT_RULE,
"[%s:%d] At initiation: NO effective rule in %s", "[%s:%d] At initiation: NO effective rule in %s",
__FUNCTION__, __LINE__, maat_inst->opts.iris_ctx.full_idx_dir); __FUNCTION__, __LINE__, maat_inst->opts.iris_ctx.full_idx_dir);
} }
@@ -324,7 +324,7 @@ void maat_read_full_config(struct maat *maat_inst)
ret = load_maat_json_file(maat_inst, maat_inst->opts.json_ctx.json_file, ret = load_maat_json_file(maat_inst, maat_inst->opts.json_ctx.json_file,
err_str, sizeof(err_str)); err_str, sizeof(err_str));
if (ret < 0) { if (ret < 0) {
log_error(maat_inst->logger, MODULE_MAAT_RULE, log_fatal(maat_inst->logger, MODULE_MAAT_RULE,
"[%s:%d] Maat re-initiate with JSON file %s failed: %s", "[%s:%d] Maat re-initiate with JSON file %s failed: %s",
__FUNCTION__, __LINE__, maat_inst->opts.json_ctx.json_file, err_str); __FUNCTION__, __LINE__, maat_inst->opts.json_ctx.json_file, err_str);
} }
@@ -335,7 +335,7 @@ void maat_read_full_config(struct maat *maat_inst)
maat_inst, maat_inst->opts.decrypt_key, maat_inst, maat_inst->opts.decrypt_key,
maat_inst->logger); maat_inst->logger);
if (NULL == maat_inst->creating_maat_rt) { if (NULL == maat_inst->creating_maat_rt) {
log_error(maat_inst->logger, MODULE_MAAT_RULE, log_fatal(maat_inst->logger, MODULE_MAAT_RULE,
"[%s:%d] At initiation: NO effective rule in %s", "[%s:%d] At initiation: NO effective rule in %s",
__FUNCTION__, __LINE__, maat_inst->opts.json_ctx.iris_file); __FUNCTION__, __LINE__, maat_inst->opts.json_ctx.iris_file);
} }
@@ -449,7 +449,7 @@ void *rule_monitor_loop(void *arg)
ret = load_maat_json_file(maat_inst, maat_inst->opts.json_ctx.json_file, ret = load_maat_json_file(maat_inst, maat_inst->opts.json_ctx.json_file,
err_str, sizeof(err_str)); err_str, sizeof(err_str));
if (ret < 0) { if (ret < 0) {
log_error(maat_inst->logger, MODULE_MAAT_RULE, log_fatal(maat_inst->logger, MODULE_MAAT_RULE,
"[%s:%d] Maat re-initiate with JSON file %s (md5=%s)failed: %s\n", "[%s:%d] Maat re-initiate with JSON file %s (md5=%s)failed: %s\n",
__FUNCTION__, __LINE__, maat_inst->opts.json_ctx.json_file, __FUNCTION__, __LINE__, maat_inst->opts.json_ctx.json_file,
md5_tmp, err_str); md5_tmp, err_str);

View File

@@ -114,7 +114,7 @@ static int maat_fieldstat_table_row_register(struct maat_stat *stat,
int ret = fieldstat_register_table_row(stat->fs_handle, table_id, "Sum", NULL, 0, int ret = fieldstat_register_table_row(stat->fs_handle, table_id, "Sum", NULL, 0,
stat->total_stat_id); stat->total_stat_id);
if (ret < 0) { if (ret < 0) {
log_error(stat->logger, MODULE_MAAT_STAT, "fieldstat_register_table_row Sum failed."); log_fatal(stat->logger, MODULE_MAAT_STAT, "fieldstat_register_table_row Sum failed.");
return -1; return -1;
} }
@@ -122,7 +122,7 @@ static int maat_fieldstat_table_row_register(struct maat_stat *stat,
stat->total_stat_id[COLUMN_SCAN_BYTES], stat->total_stat_id[COLUMN_SCAN_BYTES],
stat->total_stat_id[COLUMN_CPU_TIME], 1000000000); stat->total_stat_id[COLUMN_CPU_TIME], 1000000000);
if (ret < 0) { if (ret < 0) {
log_error(stat->logger, MODULE_MAAT_STAT, "fieldstat set IN_Bps for Sum failed."); log_fatal(stat->logger, MODULE_MAAT_STAT, "fieldstat set IN_Bps for Sum failed.");
return -1; return -1;
} }
@@ -130,7 +130,7 @@ static int maat_fieldstat_table_row_register(struct maat_stat *stat,
stat->total_stat_id[COLUMN_SCAN_CNT], stat->total_stat_id[COLUMN_SCAN_CNT],
stat->total_stat_id[COLUMN_CPU_TIME], 1000000000); stat->total_stat_id[COLUMN_CPU_TIME], 1000000000);
if (ret < 0) { if (ret < 0) {
log_error(stat->logger, MODULE_MAAT_STAT, "fieldstat set IN_Tps for Sum failed."); log_fatal(stat->logger, MODULE_MAAT_STAT, "fieldstat set IN_Tps for Sum failed.");
return -1; return -1;
} }
@@ -138,7 +138,7 @@ static int maat_fieldstat_table_row_register(struct maat_stat *stat,
stat->total_stat_id[COLUMN_HIT_CNT], stat->total_stat_id[COLUMN_HIT_CNT],
stat->total_stat_id[COLUMN_SCAN_CNT], 1); stat->total_stat_id[COLUMN_SCAN_CNT], 1);
if (ret < 0) { if (ret < 0) {
log_error(stat->logger, MODULE_MAAT_STAT, "fieldstat set hit_rate for Sum failed."); log_fatal(stat->logger, MODULE_MAAT_STAT, "fieldstat set hit_rate for Sum failed.");
return -1; return -1;
} }
@@ -159,7 +159,7 @@ static int maat_fieldstat_table_row_register(struct maat_stat *stat,
ret = fieldstat_register_table_row(stat->fs_handle, table_id, table_name, NULL, 0, ret = fieldstat_register_table_row(stat->fs_handle, table_id, table_name, NULL, 0,
stat->fs_column_id[i]); stat->fs_column_id[i]);
if (ret < 0) { if (ret < 0) {
log_error(stat->logger, MODULE_MAAT_STAT, log_fatal(stat->logger, MODULE_MAAT_STAT,
"fieldstat_register_table_row %s failed.", table_name); "fieldstat_register_table_row %s failed.", table_name);
return -1; return -1;
} }
@@ -168,7 +168,7 @@ static int maat_fieldstat_table_row_register(struct maat_stat *stat,
stat->fs_column_id[i][COLUMN_SCAN_BYTES], stat->fs_column_id[i][COLUMN_SCAN_BYTES],
stat->fs_column_id[i][COLUMN_CPU_TIME], 1000000000); stat->fs_column_id[i][COLUMN_CPU_TIME], 1000000000);
if (ret < 0) { if (ret < 0) {
log_error(stat->logger, MODULE_MAAT_STAT, log_fatal(stat->logger, MODULE_MAAT_STAT,
"fieldstat set IN_Bps for %s failed.", table_name); "fieldstat set IN_Bps for %s failed.", table_name);
return -1; return -1;
} }
@@ -177,7 +177,7 @@ static int maat_fieldstat_table_row_register(struct maat_stat *stat,
stat->fs_column_id[i][COLUMN_SCAN_CNT], stat->fs_column_id[i][COLUMN_SCAN_CNT],
stat->fs_column_id[i][COLUMN_CPU_TIME], 1000000000); stat->fs_column_id[i][COLUMN_CPU_TIME], 1000000000);
if (ret < 0) { if (ret < 0) {
log_error(stat->logger, MODULE_MAAT_STAT, log_fatal(stat->logger, MODULE_MAAT_STAT,
"fieldstat set IN_Tps for %s failed.", table_name); "fieldstat set IN_Tps for %s failed.", table_name);
return -1; return -1;
} }
@@ -186,7 +186,7 @@ static int maat_fieldstat_table_row_register(struct maat_stat *stat,
stat->fs_column_id[i][COLUMN_HIT_CNT], stat->fs_column_id[i][COLUMN_HIT_CNT],
stat->fs_column_id[i][COLUMN_SCAN_CNT], 1); stat->fs_column_id[i][COLUMN_SCAN_CNT], 1);
if (ret < 0) { if (ret < 0) {
log_error(stat->logger, MODULE_MAAT_STAT, log_fatal(stat->logger, MODULE_MAAT_STAT,
"fieldstat set hit_rate for %s failed.", table_name); "fieldstat set hit_rate for %s failed.", table_name);
return -1; return -1;
} }
@@ -275,19 +275,19 @@ int maat_stat_init(struct maat_stat *stat, struct table_manager *tbl_mgr,
const char *instance_name = "maat_stat"; const char *instance_name = "maat_stat";
stat->fs_handle = fieldstat_instance_new(instance_name); stat->fs_handle = fieldstat_instance_new(instance_name);
if (NULL == stat->fs_handle) { if (NULL == stat->fs_handle) {
log_error(stat->logger, MODULE_MAAT_STAT, "fieldstat_instance_new failed."); log_fatal(stat->logger, MODULE_MAAT_STAT, "fieldstat_instance_new failed.");
return -1; return -1;
} }
int ret = fieldstat_set_local_output(stat->fs_handle, stat->stat_file, "default"); int ret = fieldstat_set_local_output(stat->fs_handle, stat->stat_file, "default");
if (ret < 0) { if (ret < 0) {
log_error(stat->logger, MODULE_MAAT_STAT, "fieldstat_set_local_output failed."); log_fatal(stat->logger, MODULE_MAAT_STAT, "fieldstat_set_local_output failed.");
return -1; return -1;
} }
ret = fieldstat_disable_background_thread(stat->fs_handle); ret = fieldstat_disable_background_thread(stat->fs_handle);
if (ret < 0) { if (ret < 0) {
log_error(stat->logger, MODULE_MAAT_STAT, log_fatal(stat->logger, MODULE_MAAT_STAT,
"fieldstat_disable_background_thread failed."); "fieldstat_disable_background_thread failed.");
return -1; return -1;
} }
@@ -301,7 +301,7 @@ int maat_stat_init(struct maat_stat *stat, struct table_manager *tbl_mgr,
common_column_name, common_column_type, common_column_name, common_column_type,
n_column); n_column);
if (fs_table_id < 0) { if (fs_table_id < 0) {
log_error(stat->logger, MODULE_MAAT_STAT, "fieldstat_register_table failed."); log_fatal(stat->logger, MODULE_MAAT_STAT, "fieldstat_register_table failed.");
return -1; return -1;
} }

View File

@@ -301,7 +301,7 @@ static size_t parse_accept_tag(const char *value, struct rule_tag **result,
cJSON *json = cJSON_Parse(value); cJSON *json = cJSON_Parse(value);
if (!json) { if (!json) {
log_error(logger, MODULE_TABLE, log_fatal(logger, MODULE_TABLE,
"[%s:%d] parse accept tag Error before: %-200.200s", "[%s:%d] parse accept tag Error before: %-200.200s",
__FUNCTION__, __LINE__, cJSON_GetErrorPtr()); __FUNCTION__, __LINE__, cJSON_GetErrorPtr());
return 0; return 0;
@@ -509,7 +509,7 @@ maat_table_new(cJSON *json, struct maat_kv_store *reserved_word_map,
} }
if (item->valueint >= MAX_TABLE_NUM) { if (item->valueint >= MAX_TABLE_NUM) {
log_error(logger, MODULE_TABLE, log_fatal(logger, MODULE_TABLE,
"[%s:%d] table(table_id:%d) exceed maxium %d", "[%s:%d] table(table_id:%d) exceed maxium %d",
__FUNCTION__, __LINE__, MAX_TABLE_NUM); __FUNCTION__, __LINE__, MAX_TABLE_NUM);
goto error; goto error;
@@ -529,7 +529,7 @@ maat_table_new(cJSON *json, struct maat_kv_store *reserved_word_map,
item = cJSON_GetObjectItem(json, "table_type"); item = cJSON_GetObjectItem(json, "table_type");
if (NULL == item || item->type != cJSON_String) { if (NULL == item || item->type != cJSON_String) {
log_error(logger, MODULE_TABLE, log_fatal(logger, MODULE_TABLE,
"[%s:%d] table:%s has no table_type column", "[%s:%d] table:%s has no table_type column",
__FUNCTION__, __LINE__, ptable->table_name); __FUNCTION__, __LINE__, ptable->table_name);
goto error; goto error;
@@ -538,7 +538,7 @@ maat_table_new(cJSON *json, struct maat_kv_store *reserved_word_map,
ret = maat_kv_read(reserved_word_map, item->valuestring, ret = maat_kv_read(reserved_word_map, item->valuestring,
(long long *)&(ptable->table_type), 1); (long long *)&(ptable->table_type), 1);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_TABLE, log_fatal(logger, MODULE_TABLE,
"[%s:%d] table:%s table_type %s is illegal", "[%s:%d] table:%s table_type %s is illegal",
__FUNCTION__, __LINE__, ptable->table_name, __FUNCTION__, __LINE__, ptable->table_name,
item->valuestring); item->valuestring);
@@ -548,7 +548,7 @@ maat_table_new(cJSON *json, struct maat_kv_store *reserved_word_map,
item = cJSON_GetObjectItem(json, "valid_column"); item = cJSON_GetObjectItem(json, "valid_column");
if (NULL == item || item->type != cJSON_Number) { if (NULL == item || item->type != cJSON_Number) {
if (ptable->table_type != TABLE_TYPE_VIRTUAL) { if (ptable->table_type != TABLE_TYPE_VIRTUAL) {
log_error(logger, MODULE_TABLE, log_fatal(logger, MODULE_TABLE,
"[%s:%d] table:%s has no valid column", "[%s:%d] table:%s has no valid column",
__FUNCTION__, __LINE__, ptable->table_name); __FUNCTION__, __LINE__, ptable->table_name);
goto error; goto error;
@@ -603,7 +603,7 @@ static int register_single_tbl_name2id(struct maat_kv_store *tbl_name2id_map,
struct log_handle *logger) struct log_handle *logger)
{ {
if (strlen(table_name) >= NAME_MAX) { if (strlen(table_name) >= NAME_MAX) {
log_error(logger, MODULE_TABLE, log_fatal(logger, MODULE_TABLE,
"[%s:%d] table:<%s> name length exceed maxium:%d", "[%s:%d] table:<%s> name length exceed maxium:%d",
__FUNCTION__, __LINE__, table_name, NAME_MAX); __FUNCTION__, __LINE__, table_name, NAME_MAX);
return -1; return -1;
@@ -612,7 +612,7 @@ static int register_single_tbl_name2id(struct maat_kv_store *tbl_name2id_map,
long long tmp_table_id = -1; long long tmp_table_id = -1;
int ret = maat_kv_read(tbl_name2id_map, table_name, &tmp_table_id, 1); int ret = maat_kv_read(tbl_name2id_map, table_name, &tmp_table_id, 1);
if (ret > 0 && tmp_table_id != table_id) { if (ret > 0 && tmp_table_id != table_id) {
log_error(logger, MODULE_TABLE, log_fatal(logger, MODULE_TABLE,
"[%s:%d] table:<%s>(table_id:%lld) has already been registered" "[%s:%d] table:<%s>(table_id:%lld) has already been registered"
", can't register again", ", can't register again",
__FUNCTION__, __LINE__, table_name, tmp_table_id); __FUNCTION__, __LINE__, table_name, tmp_table_id);
@@ -642,7 +642,7 @@ static int register_conjunction_tbl_name2id(struct maat_kv_store *conj_tbl_name2
for (int j = 0; j < n_table_name; j++) { for (int j = 0; j < n_table_name; j++) {
cJSON *tmp_item = cJSON_GetArrayItem(item, j); cJSON *tmp_item = cJSON_GetArrayItem(item, j);
if (NULL == tmp_item || tmp_item->type != cJSON_String) { if (NULL == tmp_item || tmp_item->type != cJSON_String) {
log_error(logger, MODULE_TABLE, log_fatal(logger, MODULE_TABLE,
"[%s:%d] table(table_id:%d) db_tables element format invalid" "[%s:%d] table(table_id:%d) db_tables element format invalid"
", should be string", __FUNCTION__, __LINE__, table_id); ", should be string", __FUNCTION__, __LINE__, table_id);
return -1; return -1;
@@ -668,7 +668,7 @@ static int register_tbl_name2id(struct maat_kv_store *tbl_name2id_map, cJSON *ro
for (i = 0; i < json_array_size; i++) { for (i = 0; i < json_array_size; i++) {
cJSON *json = cJSON_GetArrayItem(root, i); cJSON *json = cJSON_GetArrayItem(root, i);
if (NULL == json || json->type != cJSON_Object) { if (NULL == json || json->type != cJSON_Object) {
log_error(logger, MODULE_TABLE, log_fatal(logger, MODULE_TABLE,
"[%s:%d] %s has invalid json object", "[%s:%d] %s has invalid json object",
__FUNCTION__, __LINE__, table_info_path); __FUNCTION__, __LINE__, table_info_path);
return -1; return -1;
@@ -676,7 +676,7 @@ static int register_tbl_name2id(struct maat_kv_store *tbl_name2id_map, cJSON *ro
cJSON *item = cJSON_GetObjectItem(json, "table_id"); cJSON *item = cJSON_GetObjectItem(json, "table_id");
if (NULL == item || item->type != cJSON_Number) { if (NULL == item || item->type != cJSON_Number) {
log_error(logger, MODULE_TABLE, log_fatal(logger, MODULE_TABLE,
"[%s:%d] %s has invalid json object, happened in table_id column ", "[%s:%d] %s has invalid json object, happened in table_id column ",
__FUNCTION__, __LINE__, table_info_path); __FUNCTION__, __LINE__, table_info_path);
return -1; return -1;
@@ -685,7 +685,7 @@ static int register_tbl_name2id(struct maat_kv_store *tbl_name2id_map, cJSON *ro
item = cJSON_GetObjectItem(json, "table_name"); item = cJSON_GetObjectItem(json, "table_name");
if (NULL == item || item->type != cJSON_String) { if (NULL == item || item->type != cJSON_String) {
log_error(logger, MODULE_TABLE, log_fatal(logger, MODULE_TABLE,
"[%s:%d] %s has invalid json object, happened in table_name column", "[%s:%d] %s has invalid json object, happened in table_name column",
__FUNCTION__, __LINE__, table_info_path); __FUNCTION__, __LINE__, table_info_path);
return -1; return -1;
@@ -713,7 +713,7 @@ static int register_tbl_name2id(struct maat_kv_store *tbl_name2id_map, cJSON *ro
for (int j = 0; j < n_table_name; j++) { for (int j = 0; j < n_table_name; j++) {
cJSON *tmp_item = cJSON_GetArrayItem(item, j); cJSON *tmp_item = cJSON_GetArrayItem(item, j);
if (NULL == tmp_item || tmp_item->type != cJSON_String) { if (NULL == tmp_item || tmp_item->type != cJSON_String) {
log_error(logger, MODULE_TABLE, log_fatal(logger, MODULE_TABLE,
"[%s:%d] table(table_id:%d) db_tables element format invalid" "[%s:%d] table(table_id:%d) db_tables element format invalid"
", should be string", __FUNCTION__, __LINE__, table_id); ", should be string", __FUNCTION__, __LINE__, table_id);
return -1; return -1;
@@ -761,7 +761,7 @@ table_manager_create(const char *table_info_path, const char *accept_tags,
size_t json_buff_sz = 0; size_t json_buff_sz = 0;
int ret = load_file_to_memory(table_info_path, &json_buff, &json_buff_sz); int ret = load_file_to_memory(table_info_path, &json_buff, &json_buff_sz);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_TABLE, log_fatal(logger, MODULE_TABLE,
"[%s:%d] Maat read table info %s error.", "[%s:%d] Maat read table info %s error.",
__FUNCTION__, __LINE__, table_info_path); __FUNCTION__, __LINE__, table_info_path);
return NULL; return NULL;
@@ -771,7 +771,7 @@ table_manager_create(const char *table_info_path, const char *accept_tags,
cJSON *json = NULL; cJSON *json = NULL;
root = cJSON_Parse((const char *)json_buff); root = cJSON_Parse((const char *)json_buff);
if (!root) { if (!root) {
log_error(logger, MODULE_TABLE, log_fatal(logger, MODULE_TABLE,
"[%s:%d] error message: %-200.200s", "[%s:%d] error message: %-200.200s",
__FUNCTION__, __LINE__, cJSON_GetErrorPtr()); __FUNCTION__, __LINE__, cJSON_GetErrorPtr());
FREE(json_buff); FREE(json_buff);
@@ -780,7 +780,7 @@ table_manager_create(const char *table_info_path, const char *accept_tags,
int json_array_size = cJSON_GetArraySize(root); int json_array_size = cJSON_GetArraySize(root);
if (json_array_size <= 0) { if (json_array_size <= 0) {
log_error(logger, MODULE_TABLE, log_fatal(logger, MODULE_TABLE,
"[%s:%d] invalid json content in %s", "[%s:%d] invalid json content in %s",
__FUNCTION__, __LINE__, table_info_path); __FUNCTION__, __LINE__, table_info_path);
FREE(json_buff); FREE(json_buff);
@@ -798,7 +798,7 @@ table_manager_create(const char *table_info_path, const char *accept_tags,
ret = register_tbl_name2id(tbl_mgr->tbl_name2id_map, root, table_info_path, logger); ret = register_tbl_name2id(tbl_mgr->tbl_name2id_map, root, table_info_path, logger);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_TABLE, log_fatal(logger, MODULE_TABLE,
"[%s:%d] register_tbl_name2id failed.", __FUNCTION__, __LINE__); "[%s:%d] register_tbl_name2id failed.", __FUNCTION__, __LINE__);
FREE(json_buff); FREE(json_buff);
cJSON_Delete(root); cJSON_Delete(root);
@@ -808,7 +808,7 @@ table_manager_create(const char *table_info_path, const char *accept_tags,
ret = register_conjunction_tbl_name2id(tbl_mgr->conj_tbl_name2id_map, root, logger); ret = register_conjunction_tbl_name2id(tbl_mgr->conj_tbl_name2id_map, root, logger);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_TABLE, log_fatal(logger, MODULE_TABLE,
"[%s:%d] register_conjunction_tbl_name2id failed.", __FUNCTION__, __LINE__); "[%s:%d] register_conjunction_tbl_name2id failed.", __FUNCTION__, __LINE__);
FREE(json_buff); FREE(json_buff);
cJSON_Delete(root); cJSON_Delete(root);
@@ -840,7 +840,7 @@ table_manager_create(const char *table_info_path, const char *accept_tags,
maat_tbl->schema = maat_table_schema_new(json, maat_tbl->table_name, maat_tbl->table_type, maat_tbl->schema = maat_table_schema_new(json, maat_tbl->table_name, maat_tbl->table_type,
tbl_mgr, logger); tbl_mgr, logger);
if (NULL == maat_tbl->schema) { if (NULL == maat_tbl->schema) {
log_error(logger, MODULE_TABLE, log_fatal(logger, MODULE_TABLE,
"[%s:%d] Maat table schema new failed, table_name:%s", "[%s:%d] Maat table schema new failed, table_name:%s",
__FUNCTION__, __LINE__, maat_tbl->table_name); __FUNCTION__, __LINE__, maat_tbl->table_name);
ret = -1; ret = -1;
@@ -949,7 +949,7 @@ int table_manager_runtime_create(struct table_manager *tbl_mgr, size_t max_threa
void *schema = table_manager_get_schema(tbl_mgr, i); void *schema = table_manager_get_schema(tbl_mgr, i);
if (NULL == schema) { if (NULL == schema) {
log_error(tbl_mgr->logger, MODULE_TABLE, log_fatal(tbl_mgr->logger, MODULE_TABLE,
"[%s:%d] group2compile table(table_id:%d) schema is null", "[%s:%d] group2compile table(table_id:%d) schema is null",
__FUNCTION__, __LINE__, i); __FUNCTION__, __LINE__, i);
continue; continue;
@@ -1208,7 +1208,7 @@ int table_manager_update_runtime(struct table_manager *tbl_mgr, const char *tabl
int valid_column = table_manager_get_valid_column(tbl_mgr, table_id); int valid_column = table_manager_get_valid_column(tbl_mgr, table_id);
if (valid_column < 0) { if (valid_column < 0) {
log_error(tbl_mgr->logger, MODULE_TABLE, log_fatal(tbl_mgr->logger, MODULE_TABLE,
"[%s:%d] table:%s has no valid column, can't update runtime", "[%s:%d] table:%s has no valid column, can't update runtime",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
return -1; return -1;
@@ -1216,14 +1216,14 @@ int table_manager_update_runtime(struct table_manager *tbl_mgr, const char *tabl
enum table_type table_type = table_manager_get_table_type(tbl_mgr, table_id); enum table_type table_type = table_manager_get_table_type(tbl_mgr, table_id);
if (table_type == TABLE_TYPE_INVALID) { if (table_type == TABLE_TYPE_INVALID) {
log_error(tbl_mgr->logger, MODULE_TABLE, log_fatal(tbl_mgr->logger, MODULE_TABLE,
"[%s:%d] table:%s table_type is invalid, can't update runtime", "[%s:%d] table:%s table_type is invalid, can't update runtime",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
return -1; return -1;
} }
if (NULL == table_ops[table_type].update_runtime) { if (NULL == table_ops[table_type].update_runtime) {
log_error(tbl_mgr->logger, MODULE_TABLE, log_fatal(tbl_mgr->logger, MODULE_TABLE,
"[%s:%d] table:%s has no update_runtime function, can't update runtime", "[%s:%d] table:%s has no update_runtime function, can't update runtime",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
return -1; return -1;
@@ -1243,7 +1243,7 @@ void table_commit_updating_runtime(struct table_manager *tbl_mgr, int table_id,
enum table_type table_type = table_manager_get_table_type(tbl_mgr, table_id); enum table_type table_type = table_manager_get_table_type(tbl_mgr, table_id);
if (table_type == TABLE_TYPE_INVALID) { if (table_type == TABLE_TYPE_INVALID) {
log_error(tbl_mgr->logger, MODULE_TABLE, log_fatal(tbl_mgr->logger, MODULE_TABLE,
"[%s:%d] table(table_id:%d) table_type is invalid, can't commit runtime", "[%s:%d] table(table_id:%d) table_type is invalid, can't commit runtime",
__FUNCTION__, __LINE__, table_id); __FUNCTION__, __LINE__, table_id);
return; return;
@@ -1277,7 +1277,7 @@ void table_commit_runtime(struct table_manager *tbl_mgr, int table_id,
enum table_type table_type = table_manager_get_table_type(tbl_mgr, table_id); enum table_type table_type = table_manager_get_table_type(tbl_mgr, table_id);
if (table_type == TABLE_TYPE_INVALID) { if (table_type == TABLE_TYPE_INVALID) {
log_error(tbl_mgr->logger, MODULE_TABLE, log_fatal(tbl_mgr->logger, MODULE_TABLE,
"[%s:%d] table(table_id:%d) table_type is invalid, can't commit runtime", "[%s:%d] table(table_id:%d) table_type is invalid, can't commit runtime",
__FUNCTION__, __LINE__, table_id); __FUNCTION__, __LINE__, table_id);
return; return;
@@ -1312,7 +1312,7 @@ long long table_manager_runtime_rule_count(struct table_manager *tbl_mgr, int ta
enum table_type table_type = table_manager_get_table_type(tbl_mgr, table_id); enum table_type table_type = table_manager_get_table_type(tbl_mgr, table_id);
if (table_type == TABLE_TYPE_INVALID) { if (table_type == TABLE_TYPE_INVALID) {
log_error(tbl_mgr->logger, MODULE_TABLE, log_fatal(tbl_mgr->logger, MODULE_TABLE,
"[%s:%d] table(table_id:%d) table_type is invalid, can't update runtime", "[%s:%d] table(table_id:%d) table_type is invalid, can't update runtime",
__FUNCTION__, __LINE__, table_id); __FUNCTION__, __LINE__, table_id);
return 0; return 0;
@@ -1334,7 +1334,7 @@ long long table_manager_runtime_scan_count(struct table_manager *tbl_mgr, int ta
enum table_type table_type = table_manager_get_table_type(tbl_mgr, table_id); enum table_type table_type = table_manager_get_table_type(tbl_mgr, table_id);
if (table_type == TABLE_TYPE_INVALID) { if (table_type == TABLE_TYPE_INVALID) {
log_error(tbl_mgr->logger, MODULE_TABLE, log_fatal(tbl_mgr->logger, MODULE_TABLE,
"[%s:%d] table(table_id:%d) table_type is invalid, can't get scan count", "[%s:%d] table(table_id:%d) table_type is invalid, can't get scan count",
__FUNCTION__, __LINE__, table_id); __FUNCTION__, __LINE__, table_id);
return 0; return 0;
@@ -1356,7 +1356,7 @@ long long table_manager_runtime_scan_cpu_time(struct table_manager *tbl_mgr, int
enum table_type table_type = table_manager_get_table_type(tbl_mgr, table_id); enum table_type table_type = table_manager_get_table_type(tbl_mgr, table_id);
if (table_type == TABLE_TYPE_INVALID) { if (table_type == TABLE_TYPE_INVALID) {
log_error(tbl_mgr->logger, MODULE_TABLE, log_fatal(tbl_mgr->logger, MODULE_TABLE,
"[%s:%d] table(table_id:%d) table_type is invalid, can't get scan cpu time", "[%s:%d] table(table_id:%d) table_type is invalid, can't get scan cpu time",
__FUNCTION__, __LINE__, table_id); __FUNCTION__, __LINE__, table_id);
return 0; return 0;
@@ -1378,7 +1378,7 @@ long long table_manager_runtime_hit_count(struct table_manager *tbl_mgr, int tab
enum table_type table_type = table_manager_get_table_type(tbl_mgr, table_id); enum table_type table_type = table_manager_get_table_type(tbl_mgr, table_id);
if (table_type == TABLE_TYPE_INVALID) { if (table_type == TABLE_TYPE_INVALID) {
log_error(tbl_mgr->logger, MODULE_TABLE, log_fatal(tbl_mgr->logger, MODULE_TABLE,
"[%s:%d] table(table_id:%d) table_type is invalid, can't get hit count", "[%s:%d] table(table_id:%d) table_type is invalid, can't get hit count",
__FUNCTION__, __LINE__, table_id); __FUNCTION__, __LINE__, table_id);
return 0; return 0;
@@ -1400,7 +1400,7 @@ long long table_manager_runtime_update_err_count(struct table_manager *tbl_mgr,
enum table_type table_type = table_manager_get_table_type(tbl_mgr, table_id); enum table_type table_type = table_manager_get_table_type(tbl_mgr, table_id);
if (table_type == TABLE_TYPE_INVALID) { if (table_type == TABLE_TYPE_INVALID) {
log_error(tbl_mgr->logger, MODULE_TABLE, log_fatal(tbl_mgr->logger, MODULE_TABLE,
"[%s:%d] table(table_id:%d) table_type is invalid, can't get hit count", "[%s:%d] table(table_id:%d) table_type is invalid, can't get hit count",
__FUNCTION__, __LINE__, table_id); __FUNCTION__, __LINE__, table_id);
return 0; return 0;

View File

@@ -32,7 +32,7 @@ void *virtual_schema_new(cJSON *json, struct table_manager *tbl_mgr,
cJSON *item = cJSON_GetObjectItem(json, "table_id"); cJSON *item = cJSON_GetObjectItem(json, "table_id");
if (NULL == item || item->type != cJSON_Number) { if (NULL == item || item->type != cJSON_Number) {
log_error(logger, MODULE_VIRTUAL, log_fatal(logger, MODULE_VIRTUAL,
"[%s:%d] virtual table:<%s> schema has no table_id column", "[%s:%d] virtual table:<%s> schema has no table_id column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -41,7 +41,7 @@ void *virtual_schema_new(cJSON *json, struct table_manager *tbl_mgr,
item = cJSON_GetObjectItem(json, "physical_table"); item = cJSON_GetObjectItem(json, "physical_table");
if (NULL == item || item->type != cJSON_String) { if (NULL == item || item->type != cJSON_String) {
log_error(logger, MODULE_VIRTUAL, log_fatal(logger, MODULE_VIRTUAL,
"[%s:%d] virtual table:<%s> schema has no physical_table column", "[%s:%d] virtual table:<%s> schema has no physical_table column",
__FUNCTION__, __LINE__, table_name); __FUNCTION__, __LINE__, table_name);
goto error; goto error;
@@ -49,7 +49,7 @@ void *virtual_schema_new(cJSON *json, struct table_manager *tbl_mgr,
schema->physical_table_id = table_manager_get_table_id(tbl_mgr, item->valuestring); schema->physical_table_id = table_manager_get_table_id(tbl_mgr, item->valuestring);
if (schema->physical_table_id < 0) { if (schema->physical_table_id < 0) {
log_error(logger, MODULE_VIRTUAL, log_fatal(logger, MODULE_VIRTUAL,
"[%s:%d] virtual table:<%s>'s physical table:<%s> unregistered.", "[%s:%d] virtual table:<%s>'s physical table:<%s> unregistered.",
__FUNCTION__, __LINE__, table_name, item->valuestring); __FUNCTION__, __LINE__, table_name, item->valuestring);
goto error; goto error;

View File

@@ -56,7 +56,7 @@ void generate_expr_sample(const char *table_name, int sample_count)
{ {
FILE *fp = fopen(table_name, "w+"); FILE *fp = fopen(table_name, "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", table_name); log_fatal(g_logger, "open file %s failed", table_name);
return; return;
} }
@@ -76,7 +76,7 @@ void generate_ip_sample(const char *table_name, int sample_count)
{ {
FILE *fp = fopen(table_name, "w+"); FILE *fp = fopen(table_name, "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", table_name); log_fatal(g_logger, "open file %s failed", table_name);
return; return;
} }
@@ -99,7 +99,7 @@ void generate_integer_sample(const char *table_name, int sample_count)
{ {
FILE *fp = fopen(table_name, "w+"); FILE *fp = fopen(table_name, "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", table_name); log_fatal(g_logger, "open file %s failed", table_name);
return; return;
} }
@@ -117,7 +117,7 @@ void generate_flag_sample(const char *table_name, int sample_count)
{ {
FILE *fp = fopen(table_name, "w+"); FILE *fp = fopen(table_name, "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", table_name); log_fatal(g_logger, "open file %s failed", table_name);
return; return;
} }
@@ -135,7 +135,7 @@ void generate_compile_sample(const char *table_name, int sample_count)
{ {
FILE *fp = fopen(table_name, "w+"); FILE *fp = fopen(table_name, "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", table_name); log_fatal(g_logger, "open file %s failed", table_name);
return; return;
} }
@@ -152,7 +152,7 @@ void generate_group2compile_sample(const char *table_name, int sample_count)
{ {
FILE *fp = fopen(table_name, "w+"); FILE *fp = fopen(table_name, "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", table_name); log_fatal(g_logger, "open file %s failed", table_name);
return; return;
} }
@@ -534,7 +534,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "REGEX_100\t100\t./regex_rules/REGEX_100\n"); fprintf(fp, "REGEX_100\t100\t./regex_rules/REGEX_100\n");
@@ -619,7 +619,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "REGEX_200\t200\t./regex_rules/REGEX_200\n"); fprintf(fp, "REGEX_200\t200\t./regex_rules/REGEX_200\n");
@@ -704,7 +704,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "REGEX_300\t300\t./regex_rules/REGEX_300\n"); fprintf(fp, "REGEX_300\t300\t./regex_rules/REGEX_300\n");
@@ -789,7 +789,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "REGEX_500\t500\t./regex_rules/REGEX_500\n"); fprintf(fp, "REGEX_500\t500\t./regex_rules/REGEX_500\n");
@@ -874,7 +874,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "REGEX_1K\t1000\t./regex_rules/REGEX_1K\n"); fprintf(fp, "REGEX_1K\t1000\t./regex_rules/REGEX_1K\n");
@@ -959,7 +959,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "REGEX_2K\t2000\t./regex_rules/REGEX_2K\n"); fprintf(fp, "REGEX_2K\t2000\t./regex_rules/REGEX_2K\n");
@@ -1044,7 +1044,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "REGEX_3K\t3000\t./regex_rules/REGEX_3K\n"); fprintf(fp, "REGEX_3K\t3000\t./regex_rules/REGEX_3K\n");
@@ -1129,7 +1129,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "REGEX_5K\t5000\t./regex_rules/REGEX_5K\n"); fprintf(fp, "REGEX_5K\t5000\t./regex_rules/REGEX_5K\n");
@@ -1214,7 +1214,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "REGEX_10K\t10000\t./regex_rules/REGEX_10K\n"); fprintf(fp, "REGEX_10K\t10000\t./regex_rules/REGEX_10K\n");
@@ -1299,7 +1299,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "REGEX_15K\t15000\t./regex_rules/REGEX_15K\n"); fprintf(fp, "REGEX_15K\t15000\t./regex_rules/REGEX_15K\n");
@@ -1385,7 +1385,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "EXPR_LITERAL_1K 1000 ./EXPR_LITERAL_1K\n"); fprintf(fp, "EXPR_LITERAL_1K 1000 ./EXPR_LITERAL_1K\n");
@@ -1471,7 +1471,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "EXPR_LITERAL_5K 5000 ./EXPR_LITERAL_5K\n"); fprintf(fp, "EXPR_LITERAL_5K 5000 ./EXPR_LITERAL_5K\n");
@@ -1557,7 +1557,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "EXPR_LITERAL_10K 10000 ./EXPR_LITERAL_10K\n"); fprintf(fp, "EXPR_LITERAL_10K 10000 ./EXPR_LITERAL_10K\n");
@@ -1643,7 +1643,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "EXPR_LITERAL_50K 50000 ./EXPR_LITERAL_50K\n"); fprintf(fp, "EXPR_LITERAL_50K 50000 ./EXPR_LITERAL_50K\n");
@@ -1729,7 +1729,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "EXPR_LITERAL_100K 100000 ./EXPR_LITERAL_100K\n"); fprintf(fp, "EXPR_LITERAL_100K 100000 ./EXPR_LITERAL_100K\n");
@@ -1815,7 +1815,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "EXPR_LITERAL_500K 500000 ./EXPR_LITERAL_500K\n"); fprintf(fp, "EXPR_LITERAL_500K 500000 ./EXPR_LITERAL_500K\n");
@@ -1901,7 +1901,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "EXPR_LITERAL_1M 1000000 ./EXPR_LITERAL_1M\n"); fprintf(fp, "EXPR_LITERAL_1M 1000000 ./EXPR_LITERAL_1M\n");
@@ -1987,7 +1987,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "EXPR_LITERAL_2M 2000000 ./EXPR_LITERAL_2M\n"); fprintf(fp, "EXPR_LITERAL_2M 2000000 ./EXPR_LITERAL_2M\n");
@@ -2073,7 +2073,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "STREAM_1K 1000 ./STREAM_1K\n"); fprintf(fp, "STREAM_1K 1000 ./STREAM_1K\n");
@@ -2156,7 +2156,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "STREAM_5K 5000 ./STREAM_5K\n"); fprintf(fp, "STREAM_5K 5000 ./STREAM_5K\n");
@@ -2239,7 +2239,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "STREAM_10K 10000 ./STREAM_10K\n"); fprintf(fp, "STREAM_10K 10000 ./STREAM_10K\n");
@@ -2322,7 +2322,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "STREAM_50K 50000 ./STREAM_50K\n"); fprintf(fp, "STREAM_50K 50000 ./STREAM_50K\n");
@@ -2405,7 +2405,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "STREAM_100K 100000 ./STREAM_100K\n"); fprintf(fp, "STREAM_100K 100000 ./STREAM_100K\n");
@@ -2488,7 +2488,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "STREAM_500K 500000 ./STREAM_500K\n"); fprintf(fp, "STREAM_500K 500000 ./STREAM_500K\n");
@@ -2571,7 +2571,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "STREAM_1M 1000000 ./STREAM_1M\n"); fprintf(fp, "STREAM_1M 1000000 ./STREAM_1M\n");
@@ -2654,7 +2654,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "STREAM_2M 2000000 ./STREAM_2M\n"); fprintf(fp, "STREAM_2M 2000000 ./STREAM_2M\n");
@@ -2737,7 +2737,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "IP_1K 1000 ./IP_1K\n"); fprintf(fp, "IP_1K 1000 ./IP_1K\n");
@@ -2823,7 +2823,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "IP_5K 5000 ./IP_5K\n"); fprintf(fp, "IP_5K 5000 ./IP_5K\n");
@@ -2909,7 +2909,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "IP_10K 10000 ./IP_10K\n"); fprintf(fp, "IP_10K 10000 ./IP_10K\n");
@@ -2995,7 +2995,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "IP_50K 50000 ./IP_50K\n"); fprintf(fp, "IP_50K 50000 ./IP_50K\n");
@@ -3081,7 +3081,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "IP_100K 100000 ./IP_100K\n"); fprintf(fp, "IP_100K 100000 ./IP_100K\n");
@@ -3167,7 +3167,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "IP_500K 500000 ./IP_500K\n"); fprintf(fp, "IP_500K 500000 ./IP_500K\n");
@@ -3253,7 +3253,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "IP_1M 1000000 ./IP_1M\n"); fprintf(fp, "IP_1M 1000000 ./IP_1M\n");
@@ -3339,7 +3339,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "IP_5M 5000000 ./IP_5M\n"); fprintf(fp, "IP_5M 5000000 ./IP_5M\n");
@@ -3425,7 +3425,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "IP_10M 10000000 ./IP_10M\n"); fprintf(fp, "IP_10M 10000000 ./IP_10M\n");
@@ -3511,7 +3511,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "INTEGER_1K 1000 ./INTEGER_1K\n"); fprintf(fp, "INTEGER_1K 1000 ./INTEGER_1K\n");
@@ -3597,7 +3597,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "INTEGER_5K 5000 ./INTEGER_5K\n"); fprintf(fp, "INTEGER_5K 5000 ./INTEGER_5K\n");
@@ -3683,7 +3683,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "INTEGER_10K 10000 ./INTEGER_10K\n"); fprintf(fp, "INTEGER_10K 10000 ./INTEGER_10K\n");
@@ -3769,7 +3769,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "FLAG_1K 1000 ./FLAG_1K\n"); fprintf(fp, "FLAG_1K 1000 ./FLAG_1K\n");
@@ -3855,7 +3855,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "FLAG_5K 5000 ./FLAG_5K\n"); fprintf(fp, "FLAG_5K 5000 ./FLAG_5K\n");
@@ -3941,7 +3941,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "FLAG_10K 10000 ./FLAG_10K\n"); fprintf(fp, "FLAG_10K 10000 ./FLAG_10K\n");

View File

@@ -56,7 +56,7 @@ void generate_expr_sample(const char *table_name, int sample_count)
{ {
FILE *fp = fopen(table_name, "w+"); FILE *fp = fopen(table_name, "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", table_name); log_fatal(g_logger, "open file %s failed", table_name);
return; return;
} }
@@ -76,7 +76,7 @@ void generate_ip_sample(const char *table_name, int sample_count)
{ {
FILE *fp = fopen(table_name, "w+"); FILE *fp = fopen(table_name, "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", table_name); log_fatal(g_logger, "open file %s failed", table_name);
return; return;
} }
@@ -99,7 +99,7 @@ void generate_integer_sample(const char *table_name, int sample_count)
{ {
FILE *fp = fopen(table_name, "w+"); FILE *fp = fopen(table_name, "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", table_name); log_fatal(g_logger, "open file %s failed", table_name);
return; return;
} }
@@ -117,7 +117,7 @@ void generate_flag_sample(const char *table_name, int sample_count)
{ {
FILE *fp = fopen(table_name, "w+"); FILE *fp = fopen(table_name, "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", table_name); log_fatal(g_logger, "open file %s failed", table_name);
return; return;
} }
@@ -135,7 +135,7 @@ void generate_compile_sample(const char *table_name, int sample_count)
{ {
FILE *fp = fopen(table_name, "w+"); FILE *fp = fopen(table_name, "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", table_name); log_fatal(g_logger, "open file %s failed", table_name);
return; return;
} }
@@ -152,7 +152,7 @@ void generate_group2compile_sample(const char *table_name, int sample_count)
{ {
FILE *fp = fopen(table_name, "w+"); FILE *fp = fopen(table_name, "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", table_name); log_fatal(g_logger, "open file %s failed", table_name);
return; return;
} }
@@ -534,7 +534,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "REGEX_100\t100\t./regex_rules/REGEX_100\n"); fprintf(fp, "REGEX_100\t100\t./regex_rules/REGEX_100\n");
@@ -620,7 +620,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "REGEX_200\t200\t./regex_rules/REGEX_200\n"); fprintf(fp, "REGEX_200\t200\t./regex_rules/REGEX_200\n");
@@ -706,7 +706,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "REGEX_300\t300\t./regex_rules/REGEX_300\n"); fprintf(fp, "REGEX_300\t300\t./regex_rules/REGEX_300\n");
@@ -793,7 +793,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "EXPR_LITERAL_1K 1000 ./EXPR_LITERAL_1K\n"); fprintf(fp, "EXPR_LITERAL_1K 1000 ./EXPR_LITERAL_1K\n");
@@ -880,7 +880,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "EXPR_LITERAL_5K 5000 ./EXPR_LITERAL_5K\n"); fprintf(fp, "EXPR_LITERAL_5K 5000 ./EXPR_LITERAL_5K\n");
@@ -967,7 +967,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "EXPR_LITERAL_10K 10000 ./EXPR_LITERAL_10K\n"); fprintf(fp, "EXPR_LITERAL_10K 10000 ./EXPR_LITERAL_10K\n");
@@ -1054,7 +1054,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "EXPR_LITERAL_50K 50000 ./EXPR_LITERAL_50K\n"); fprintf(fp, "EXPR_LITERAL_50K 50000 ./EXPR_LITERAL_50K\n");
@@ -1141,7 +1141,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "EXPR_LITERAL_100K 100000 ./EXPR_LITERAL_100K\n"); fprintf(fp, "EXPR_LITERAL_100K 100000 ./EXPR_LITERAL_100K\n");
@@ -1228,7 +1228,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "EXPR_LITERAL_500K 500000 ./EXPR_LITERAL_500K\n"); fprintf(fp, "EXPR_LITERAL_500K 500000 ./EXPR_LITERAL_500K\n");
@@ -1315,7 +1315,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "EXPR_LITERAL_1M 1000000 ./EXPR_LITERAL_1M\n"); fprintf(fp, "EXPR_LITERAL_1M 1000000 ./EXPR_LITERAL_1M\n");
@@ -1402,7 +1402,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "EXPR_LITERAL_2M 2000000 ./EXPR_LITERAL_2M\n"); fprintf(fp, "EXPR_LITERAL_2M 2000000 ./EXPR_LITERAL_2M\n");
@@ -1489,7 +1489,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "STREAM_1K 1000 ./STREAM_1K\n"); fprintf(fp, "STREAM_1K 1000 ./STREAM_1K\n");
@@ -1573,7 +1573,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "STREAM_5K 5000 ./STREAM_5K\n"); fprintf(fp, "STREAM_5K 5000 ./STREAM_5K\n");
@@ -1657,7 +1657,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "STREAM_10K 10000 ./STREAM_10K\n"); fprintf(fp, "STREAM_10K 10000 ./STREAM_10K\n");
@@ -1741,7 +1741,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "STREAM_50K 50000 ./STREAM_50K\n"); fprintf(fp, "STREAM_50K 50000 ./STREAM_50K\n");
@@ -1825,7 +1825,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "STREAM_100K 100000 ./STREAM_100K\n"); fprintf(fp, "STREAM_100K 100000 ./STREAM_100K\n");
@@ -1909,7 +1909,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "STREAM_500K 500000 ./STREAM_500K\n"); fprintf(fp, "STREAM_500K 500000 ./STREAM_500K\n");
@@ -1993,7 +1993,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "STREAM_1M 1000000 ./STREAM_1M\n"); fprintf(fp, "STREAM_1M 1000000 ./STREAM_1M\n");
@@ -2077,7 +2077,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "STREAM_2M 2000000 ./STREAM_2M\n"); fprintf(fp, "STREAM_2M 2000000 ./STREAM_2M\n");
@@ -2161,7 +2161,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "IP_1K 1000 ./IP_1K\n"); fprintf(fp, "IP_1K 1000 ./IP_1K\n");
@@ -2248,7 +2248,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "IP_5K 5000 ./IP_5K\n"); fprintf(fp, "IP_5K 5000 ./IP_5K\n");
@@ -2335,7 +2335,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "IP_10K 10000 ./IP_10K\n"); fprintf(fp, "IP_10K 10000 ./IP_10K\n");
@@ -2422,7 +2422,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "IP_50K 50000 ./IP_50K\n"); fprintf(fp, "IP_50K 50000 ./IP_50K\n");
@@ -2509,7 +2509,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "IP_100K 100000 ./IP_100K\n"); fprintf(fp, "IP_100K 100000 ./IP_100K\n");
@@ -2596,7 +2596,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "IP_500K 500000 ./IP_500K\n"); fprintf(fp, "IP_500K 500000 ./IP_500K\n");
@@ -2683,7 +2683,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "IP_1M 1000000 ./IP_1M\n"); fprintf(fp, "IP_1M 1000000 ./IP_1M\n");
@@ -2770,7 +2770,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "IP_5M 5000000 ./IP_5M\n"); fprintf(fp, "IP_5M 5000000 ./IP_5M\n");
@@ -2857,7 +2857,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "IP_10M 10000000 ./IP_10M\n"); fprintf(fp, "IP_10M 10000000 ./IP_10M\n");
@@ -2944,7 +2944,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "INTEGER_1K 1000 ./INTEGER_1K\n"); fprintf(fp, "INTEGER_1K 1000 ./INTEGER_1K\n");
@@ -3031,7 +3031,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "INTEGER_5K 5000 ./INTEGER_5K\n"); fprintf(fp, "INTEGER_5K 5000 ./INTEGER_5K\n");
@@ -3118,7 +3118,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "INTEGER_10K 10000 ./INTEGER_10K\n"); fprintf(fp, "INTEGER_10K 10000 ./INTEGER_10K\n");
@@ -3205,7 +3205,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "FLAG_1K 1000 ./FLAG_1K\n"); fprintf(fp, "FLAG_1K 1000 ./FLAG_1K\n");
@@ -3292,7 +3292,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "FLAG_5K 5000 ./FLAG_5K\n"); fprintf(fp, "FLAG_5K 5000 ./FLAG_5K\n");
@@ -3379,7 +3379,7 @@ protected:
FILE *fp = fopen("full_config_index.0000001", "w+"); FILE *fp = fopen("full_config_index.0000001", "w+");
if (NULL == fp) { if (NULL == fp) {
log_error(g_logger, "open file %s failed", "full_config_index.0000001"); log_fatal(g_logger, "open file %s failed", "full_config_index.0000001");
return; return;
} }
fprintf(fp, "FLAG_10K 10000 ./FLAG_10K\n"); fprintf(fp, "FLAG_10K 10000 ./FLAG_10K\n");

View File

@@ -122,13 +122,13 @@ protected:
int ret = load_file_to_memory(table_info_path, &json_buff, &json_buff_size); int ret = load_file_to_memory(table_info_path, &json_buff, &json_buff_size);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_GROUP_EXCLUDE_GTEST, "load_file_to_memory failed."); log_fatal(logger, MODULE_GROUP_EXCLUDE_GTEST, "load_file_to_memory failed.");
assert(0); assert(0);
} }
cJSON *root = cJSON_Parse((const char *)json_buff); cJSON *root = cJSON_Parse((const char *)json_buff);
if (!root) { if (!root) {
log_error(logger, MODULE_GROUP_EXCLUDE_GTEST, "cJSON_Parse failed."); log_fatal(logger, MODULE_GROUP_EXCLUDE_GTEST, "cJSON_Parse failed.");
assert(0); assert(0);
} }
@@ -137,7 +137,7 @@ protected:
cJSON_Delete(root); cJSON_Delete(root);
if (NULL == g2g_schema) { if (NULL == g2g_schema) {
log_error(logger, MODULE_GROUP_EXCLUDE_GTEST, "group2group_schema_new failed."); log_fatal(logger, MODULE_GROUP_EXCLUDE_GTEST, "group2group_schema_new failed.");
assert(0); assert(0);
} }
} }
@@ -164,7 +164,7 @@ TEST_F(MaatGroupExclude, level_3_function) {
void *g2g_runtime = group2group_runtime_new(g2g_schema, 1, garbage_bin, logger); void *g2g_runtime = group2group_runtime_new(g2g_schema, 1, garbage_bin, logger);
if (NULL == g2g_runtime) { if (NULL == g2g_runtime) {
log_error(logger, MODULE_GROUP_EXCLUDE_GTEST, "group2group_runtime_new failed."); log_fatal(logger, MODULE_GROUP_EXCLUDE_GTEST, "group2group_runtime_new failed.");
assert(0); assert(0);
} }
@@ -228,7 +228,7 @@ TEST_F(MaatGroupExclude, level_3_perf) {
void *g2g_runtime = group2group_runtime_new(g2g_schema, 1, garbage_bin, logger); void *g2g_runtime = group2group_runtime_new(g2g_schema, 1, garbage_bin, logger);
if (NULL == g2g_runtime) { if (NULL == g2g_runtime) {
log_error(logger, MODULE_GROUP_EXCLUDE_GTEST, "group2group_runtime_new failed."); log_fatal(logger, MODULE_GROUP_EXCLUDE_GTEST, "group2group_runtime_new failed.");
assert(0); assert(0);
} }
@@ -304,7 +304,7 @@ TEST_F(MaatGroupExclude, level_4_function) {
void *g2g_runtime = group2group_runtime_new(g2g_schema, 1, garbage_bin, logger); void *g2g_runtime = group2group_runtime_new(g2g_schema, 1, garbage_bin, logger);
if (NULL == g2g_runtime) { if (NULL == g2g_runtime) {
log_error(logger, MODULE_GROUP_EXCLUDE_GTEST, "group2group_runtime_new failed."); log_fatal(logger, MODULE_GROUP_EXCLUDE_GTEST, "group2group_runtime_new failed.");
assert(0); assert(0);
} }
@@ -360,7 +360,7 @@ TEST_F(MaatGroupExclude, level_4_perf) {
void *g2g_runtime = group2group_runtime_new(g2g_schema, 1, garbage_bin, logger); void *g2g_runtime = group2group_runtime_new(g2g_schema, 1, garbage_bin, logger);
if (NULL == g2g_runtime) { if (NULL == g2g_runtime) {
log_error(logger, MODULE_GROUP_EXCLUDE_GTEST, "group2group_runtime_new failed."); log_fatal(logger, MODULE_GROUP_EXCLUDE_GTEST, "group2group_runtime_new failed.");
assert(0); assert(0);
} }
@@ -419,7 +419,7 @@ TEST_F(MaatGroupExclude, level_exceed_function) {
void *g2g_runtime = group2group_runtime_new(g2g_schema, 1, garbage_bin, logger); void *g2g_runtime = group2group_runtime_new(g2g_schema, 1, garbage_bin, logger);
if (NULL == g2g_runtime) { if (NULL == g2g_runtime) {
log_error(logger, MODULE_GROUP_EXCLUDE_GTEST, "group2group_runtime_new failed."); log_fatal(logger, MODULE_GROUP_EXCLUDE_GTEST, "group2group_runtime_new failed.");
assert(0); assert(0);
} }

File diff suppressed because it is too large Load Diff

View File

@@ -384,7 +384,7 @@ protected:
logger = log_handle_create("./maat_framework_perf_gtest.log", 0); logger = log_handle_create("./maat_framework_perf_gtest.log", 0);
int ret = write_config_to_redis(json_iris_path, redis_ip, redis_port, redis_db, logger); int ret = write_config_to_redis(json_iris_path, redis_ip, redis_port, redis_db, logger);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_FRAMEWORK_PERF_GTEST, log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] write config to redis failed.", __FUNCTION__, __LINE__); "[%s:%d] write config to redis failed.", __FUNCTION__, __LINE__);
} }
@@ -399,7 +399,7 @@ protected:
_shared_maat_inst = maat_new(opts, table_info_path); _shared_maat_inst = maat_new(opts, table_info_path);
maat_options_free(opts); maat_options_free(opts);
if (NULL == _shared_maat_inst) { if (NULL == _shared_maat_inst) {
log_error(logger, MODULE_FRAMEWORK_PERF_GTEST, log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] create maat instance in MaatStringScan failed.", "[%s:%d] create maat instance in MaatStringScan failed.",
__FUNCTION__, __LINE__); __FUNCTION__, __LINE__);
} }
@@ -534,7 +534,7 @@ protected:
logger = log_handle_create("./maat_framework_perf_gtest.log", 0); logger = log_handle_create("./maat_framework_perf_gtest.log", 0);
int ret = write_config_to_redis(json_iris_path, redis_ip, redis_port, redis_db, logger); int ret = write_config_to_redis(json_iris_path, redis_ip, redis_port, redis_db, logger);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_FRAMEWORK_PERF_GTEST, log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] write config to redis failed.", __FUNCTION__, __LINE__); "[%s:%d] write config to redis failed.", __FUNCTION__, __LINE__);
} }
@@ -549,7 +549,7 @@ protected:
_shared_maat_inst = maat_new(opts, table_info_path); _shared_maat_inst = maat_new(opts, table_info_path);
maat_options_free(opts); maat_options_free(opts);
if (NULL == _shared_maat_inst) { if (NULL == _shared_maat_inst) {
log_error(logger, MODULE_FRAMEWORK_PERF_GTEST, log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] create maat instance in MaatRegexScan failed.", "[%s:%d] create maat instance in MaatRegexScan failed.",
__FUNCTION__, __LINE__); __FUNCTION__, __LINE__);
} }
@@ -737,7 +737,7 @@ protected:
logger = log_handle_create("./maat_framework_perf_gtest.log", 0); logger = log_handle_create("./maat_framework_perf_gtest.log", 0);
int ret = write_config_to_redis(json_iris_path, redis_ip, redis_port, redis_db, logger); int ret = write_config_to_redis(json_iris_path, redis_ip, redis_port, redis_db, logger);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_FRAMEWORK_PERF_GTEST, log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] write config to redis failed.", __FUNCTION__, __LINE__); "[%s:%d] write config to redis failed.", __FUNCTION__, __LINE__);
} }
@@ -752,7 +752,7 @@ protected:
_shared_maat_inst = maat_new(opts, table_info_path); _shared_maat_inst = maat_new(opts, table_info_path);
maat_options_free(opts); maat_options_free(opts);
if (NULL == _shared_maat_inst) { if (NULL == _shared_maat_inst) {
log_error(logger, MODULE_FRAMEWORK_PERF_GTEST, log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] create maat instance in MaatStreamScan failed.", "[%s:%d] create maat instance in MaatStreamScan failed.",
__FUNCTION__, __LINE__); __FUNCTION__, __LINE__);
} }
@@ -867,7 +867,7 @@ protected:
logger = log_handle_create("./maat_framework_perf_gtest.log", 0); logger = log_handle_create("./maat_framework_perf_gtest.log", 0);
int ret = write_config_to_redis(json_iris_path, redis_ip, redis_port, redis_db, logger); int ret = write_config_to_redis(json_iris_path, redis_ip, redis_port, redis_db, logger);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_FRAMEWORK_PERF_GTEST, log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] write config to redis failed.", __FUNCTION__, __LINE__); "[%s:%d] write config to redis failed.", __FUNCTION__, __LINE__);
} }
@@ -882,7 +882,7 @@ protected:
_shared_maat_inst = maat_new(opts, table_info_path); _shared_maat_inst = maat_new(opts, table_info_path);
maat_options_free(opts); maat_options_free(opts);
if (NULL == _shared_maat_inst) { if (NULL == _shared_maat_inst) {
log_error(logger, MODULE_FRAMEWORK_PERF_GTEST, log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] create maat instance in MaatIPScan failed.", "[%s:%d] create maat instance in MaatIPScan failed.",
__FUNCTION__, __LINE__); __FUNCTION__, __LINE__);
} }
@@ -1034,7 +1034,7 @@ protected:
logger = log_handle_create("./maat_framework_perf_gtest.log", 0); logger = log_handle_create("./maat_framework_perf_gtest.log", 0);
int ret = write_config_to_redis(json_iris_path, redis_ip, redis_port, redis_db, logger); int ret = write_config_to_redis(json_iris_path, redis_ip, redis_port, redis_db, logger);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_FRAMEWORK_PERF_GTEST, log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] write config to redis failed.", __FUNCTION__, __LINE__); "[%s:%d] write config to redis failed.", __FUNCTION__, __LINE__);
} }
@@ -1049,7 +1049,7 @@ protected:
_shared_maat_inst = maat_new(opts, table_info_path); _shared_maat_inst = maat_new(opts, table_info_path);
maat_options_free(opts); maat_options_free(opts);
if (NULL == _shared_maat_inst) { if (NULL == _shared_maat_inst) {
log_error(logger, MODULE_FRAMEWORK_PERF_GTEST, log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] create maat instance in MaatIntegerScan failed.", "[%s:%d] create maat instance in MaatIntegerScan failed.",
__FUNCTION__, __LINE__); __FUNCTION__, __LINE__);
} }
@@ -1129,7 +1129,7 @@ protected:
logger = log_handle_create("./maat_framework_perf_gtest.log", 0); logger = log_handle_create("./maat_framework_perf_gtest.log", 0);
int ret = write_config_to_redis(json_iris_path, redis_ip, redis_port, redis_db, logger); int ret = write_config_to_redis(json_iris_path, redis_ip, redis_port, redis_db, logger);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_FRAMEWORK_PERF_GTEST, log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] write config to redis failed.", __FUNCTION__, __LINE__); "[%s:%d] write config to redis failed.", __FUNCTION__, __LINE__);
} }
@@ -1144,7 +1144,7 @@ protected:
_shared_maat_inst = maat_new(opts, table_info_path); _shared_maat_inst = maat_new(opts, table_info_path);
maat_options_free(opts); maat_options_free(opts);
if (NULL == _shared_maat_inst) { if (NULL == _shared_maat_inst) {
log_error(logger, MODULE_FRAMEWORK_PERF_GTEST, log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] create maat instance in MaatFlagScan failed.", "[%s:%d] create maat instance in MaatFlagScan failed.",
__FUNCTION__, __LINE__); __FUNCTION__, __LINE__);
} }
@@ -1277,7 +1277,7 @@ protected:
logger = log_handle_create("./maat_framework_perf_gtest.log", 0); logger = log_handle_create("./maat_framework_perf_gtest.log", 0);
int ret = write_config_to_redis(json_iris_path, redis_ip, redis_port, redis_db, logger); int ret = write_config_to_redis(json_iris_path, redis_ip, redis_port, redis_db, logger);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_FRAMEWORK_PERF_GTEST, log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] write config to redis failed.", __FUNCTION__, __LINE__); "[%s:%d] write config to redis failed.", __FUNCTION__, __LINE__);
} }
@@ -1292,7 +1292,7 @@ protected:
_shared_maat_inst = maat_new(opts, table_info_path); _shared_maat_inst = maat_new(opts, table_info_path);
maat_options_free(opts); maat_options_free(opts);
if (NULL == _shared_maat_inst) { if (NULL == _shared_maat_inst) {
log_error(logger, MODULE_FRAMEWORK_PERF_GTEST, log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] create maat instance in MaatFQDNPluginScan failed.", "[%s:%d] create maat instance in MaatFQDNPluginScan failed.",
__FUNCTION__, __LINE__); __FUNCTION__, __LINE__);
} }
@@ -1505,7 +1505,7 @@ protected:
logger = log_handle_create("./maat_framework_perf_gtest.log", 0); logger = log_handle_create("./maat_framework_perf_gtest.log", 0);
int ret = write_config_to_redis(json_iris_path, redis_ip, redis_port, redis_db, logger); int ret = write_config_to_redis(json_iris_path, redis_ip, redis_port, redis_db, logger);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_FRAMEWORK_PERF_GTEST, log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] write config to redis failed.", __FUNCTION__, __LINE__); "[%s:%d] write config to redis failed.", __FUNCTION__, __LINE__);
} }
@@ -1520,7 +1520,7 @@ protected:
_shared_maat_inst = maat_new(opts, table_info_path); _shared_maat_inst = maat_new(opts, table_info_path);
maat_options_free(opts); maat_options_free(opts);
if (NULL == _shared_maat_inst) { if (NULL == _shared_maat_inst) {
log_error(logger, MODULE_FRAMEWORK_PERF_GTEST, log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] create maat instance in BoolPluginScan failed.", "[%s:%d] create maat instance in BoolPluginScan failed.",
__FUNCTION__, __LINE__); __FUNCTION__, __LINE__);
} }
@@ -1716,7 +1716,7 @@ protected:
_shared_maat_inst = maat_new(opts, table_info); _shared_maat_inst = maat_new(opts, table_info);
maat_options_free(opts); maat_options_free(opts);
if (NULL == _shared_maat_inst) { if (NULL == _shared_maat_inst) {
log_error(logger, MODULE_FRAMEWORK_PERF_GTEST, log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] create maat instance in MaatPerfFileScan failed.", "[%s:%d] create maat instance in MaatPerfFileScan failed.",
__FUNCTION__, __LINE__); __FUNCTION__, __LINE__);
} }
@@ -1852,7 +1852,7 @@ protected:
logger = log_handle_create("./maat_framework_perf_gtest.log", 0); logger = log_handle_create("./maat_framework_perf_gtest.log", 0);
int ret = write_config_to_redis(json_iris_path, redis_ip, redis_port, redis_db, logger); int ret = write_config_to_redis(json_iris_path, redis_ip, redis_port, redis_db, logger);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_FRAMEWORK_PERF_GTEST, log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] write config to redis failed.", __FUNCTION__, __LINE__); "[%s:%d] write config to redis failed.", __FUNCTION__, __LINE__);
} }
@@ -1865,7 +1865,7 @@ protected:
_shared_maat_inst = maat_new(opts, tsg_table_info); _shared_maat_inst = maat_new(opts, tsg_table_info);
maat_options_free(opts); maat_options_free(opts);
if (NULL == _shared_maat_inst) { if (NULL == _shared_maat_inst) {
log_error(logger, MODULE_FRAMEWORK_PERF_GTEST, log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] create maat instance in MaatTSGFqdnScan failed.", "[%s:%d] create maat instance in MaatTSGFqdnScan failed.",
__FUNCTION__, __LINE__); __FUNCTION__, __LINE__);
} }
@@ -1924,7 +1924,7 @@ protected:
logger = log_handle_create("./maat_framework_perf_gtest.log", 0); logger = log_handle_create("./maat_framework_perf_gtest.log", 0);
int ret = write_config_to_redis(json_iris_path, redis_ip, redis_port, redis_db, logger); int ret = write_config_to_redis(json_iris_path, redis_ip, redis_port, redis_db, logger);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_FRAMEWORK_PERF_GTEST, log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] write config to redis failed.", __FUNCTION__, __LINE__); "[%s:%d] write config to redis failed.", __FUNCTION__, __LINE__);
} }
@@ -1939,7 +1939,7 @@ protected:
_shared_maat_inst = maat_new(opts, table_info_path); _shared_maat_inst = maat_new(opts, table_info_path);
maat_options_free(opts); maat_options_free(opts);
if (NULL == _shared_maat_inst) { if (NULL == _shared_maat_inst) {
log_error(logger, MODULE_FRAMEWORK_PERF_GTEST, log_fatal(logger, MODULE_FRAMEWORK_PERF_GTEST,
"[%s:%d] create maat instance in MaatFlagScan failed.", "[%s:%d] create maat instance in MaatFlagScan failed.",
__FUNCTION__, __LINE__); __FUNCTION__, __LINE__);
} }

File diff suppressed because it is too large Load Diff

View File

@@ -293,7 +293,7 @@ int rollback_redis_version(redisContext *c, struct log_handle *logger)
{ {
redisReply *reply = maat_wrap_redis_command(c, "SET MAAT_VERSION 0"); redisReply *reply = maat_wrap_redis_command(c, "SET MAAT_VERSION 0");
if (NULL == reply) { if (NULL == reply) {
log_error(logger, MODULE_REDIS_TOOL, log_fatal(logger, MODULE_REDIS_TOOL,
"[%s:%d] set MAAT_VERSION failed, Redis Communication error: %s", "[%s:%d] set MAAT_VERSION failed, Redis Communication error: %s",
__FUNCTION__, __LINE__, c->errstr); __FUNCTION__, __LINE__, c->errstr);
return -1; return -1;
@@ -310,7 +310,7 @@ int clear_config_in_redis(redisContext *c, struct log_handle *logger)
redisReply *reply = maat_wrap_redis_command(c, "GET MAAT_VERSION"); redisReply *reply = maat_wrap_redis_command(c, "GET MAAT_VERSION");
if (reply != NULL) { if (reply != NULL) {
if (reply->type == REDIS_REPLY_NIL || reply->type == REDIS_REPLY_ERROR) { if (reply->type == REDIS_REPLY_NIL || reply->type == REDIS_REPLY_ERROR) {
log_error(logger, MODULE_REDIS_TOOL, log_fatal(logger, MODULE_REDIS_TOOL,
"[%s:%d] GET MAAT_VERSION failed, maybe Redis is busy", "[%s:%d] GET MAAT_VERSION failed, maybe Redis is busy",
__FUNCTION__, __LINE__); __FUNCTION__, __LINE__);
freeReplyObject(reply); freeReplyObject(reply);
@@ -318,7 +318,7 @@ int clear_config_in_redis(redisContext *c, struct log_handle *logger)
return -1; return -1;
} }
} else { } else {
log_error(logger, MODULE_REDIS_TOOL, log_fatal(logger, MODULE_REDIS_TOOL,
"[%s:%d] GET MAAT_VERSION failed with NULL reply, error: %s", "[%s:%d] GET MAAT_VERSION failed with NULL reply, error: %s",
__FUNCTION__, __LINE__, c->errstr); __FUNCTION__, __LINE__, c->errstr);
return -1; return -1;
@@ -327,7 +327,7 @@ int clear_config_in_redis(redisContext *c, struct log_handle *logger)
redis_version = maat_read_redis_integer(reply); redis_version = maat_read_redis_integer(reply);
if (redis_version < 0) { if (redis_version < 0) {
if (reply->type == REDIS_REPLY_ERROR) { if (reply->type == REDIS_REPLY_ERROR) {
log_error(logger, MODULE_REDIS_TOOL, log_fatal(logger, MODULE_REDIS_TOOL,
"[%s:%d] Redis Communication error: %s", "[%s:%d] Redis Communication error: %s",
__FUNCTION__, __LINE__, reply->str); __FUNCTION__, __LINE__, reply->str);
} }
@@ -449,27 +449,27 @@ int main(int argc, char * argv[])
size_t json_buff_sz = 0; size_t json_buff_sz = 0;
int ret = load_file_to_memory(json_file, (unsigned char**)&json_buff, &json_buff_sz); int ret = load_file_to_memory(json_file, (unsigned char**)&json_buff, &json_buff_sz);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_REDIS_TOOL, "open file:%s failed.", json_file); log_fatal(logger, MODULE_REDIS_TOOL, "open file:%s failed.", json_file);
return -1; return -1;
} }
ret = json2iris(json_buff, json_file, c, tmp_iris_path, sizeof(tmp_iris_path), NULL, NULL, logger); ret = json2iris(json_buff, json_file, c, tmp_iris_path, sizeof(tmp_iris_path), NULL, NULL, logger);
FREE(json_buff); FREE(json_buff);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_REDIS_TOOL, "Invalid json format."); log_fatal(logger, MODULE_REDIS_TOOL, "Invalid json format.");
return -1; return -1;
} }
size_t total_line_cnt = 0; size_t total_line_cnt = 0;
config_monitor_traverse(0, tmp_iris_path, NULL, count_line_num_cb, NULL, &total_line_cnt, NULL, logger); config_monitor_traverse(0, tmp_iris_path, NULL, count_line_num_cb, NULL, &total_line_cnt, NULL, logger);
log_error(logger, MODULE_REDIS_TOOL, "Serialize %s to %zu lines, write temp file to %s .", log_fatal(logger, MODULE_REDIS_TOOL, "Serialize %s to %zu lines, write temp file to %s .",
json_file, total_line_cnt, tmp_iris_path); json_file, total_line_cnt, tmp_iris_path);
struct serial_rule *s_rule = ALLOC(struct serial_rule, total_line_cnt); struct serial_rule *s_rule = ALLOC(struct serial_rule, total_line_cnt);
s_rule->ref_ctx = c; s_rule->ref_ctx = c;
long long server_time = maat_redis_server_time_s(c); long long server_time = maat_redis_server_time_s(c);
if (!server_time) { if (!server_time) {
log_error(logger, MODULE_REDIS_TOOL, "Get Redis Time failed."); log_fatal(logger, MODULE_REDIS_TOOL, "Get Redis Time failed.");
FREE(s_rule); FREE(s_rule);
return -1; return -1;
} }
@@ -487,7 +487,7 @@ int main(int argc, char * argv[])
} while(success_cnt < 0); } while(success_cnt < 0);
if (success_cnt != (int)total_line_cnt) { if (success_cnt != (int)total_line_cnt) {
log_error(logger, MODULE_REDIS_TOOL, "Only Add %d of %zu, rule id maybe conflicts.", log_fatal(logger, MODULE_REDIS_TOOL, "Only Add %d of %zu, rule id maybe conflicts.",
success_cnt, total_line_cnt); success_cnt, total_line_cnt);
} }
@@ -499,19 +499,19 @@ int main(int argc, char * argv[])
} else if (mode == WORK_MODE_UPLOAD) { } else if (mode == WORK_MODE_UPLOAD) {
int ret = clear_config_in_redis(c, logger); int ret = clear_config_in_redis(c, logger);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_REDIS_TOOL, "clear config in redis failed."); log_fatal(logger, MODULE_REDIS_TOOL, "clear config in redis failed.");
return -1; return -1;
} }
ret = write_config_to_redis(c, upload_file, logger); ret = write_config_to_redis(c, upload_file, logger);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_REDIS_TOOL, "write config to redis failed."); log_fatal(logger, MODULE_REDIS_TOOL, "write config to redis failed.");
return -1; return -1;
} }
ret = rollback_redis_version(c, logger); ret = rollback_redis_version(c, logger);
if (ret < 0) { if (ret < 0) {
log_error(logger, MODULE_REDIS_TOOL, "rollback redis version failed."); log_fatal(logger, MODULE_REDIS_TOOL, "rollback redis version failed.");
return -1; return -1;
} }
redisFree(c); redisFree(c);