rename terminology "virtual table(vtable)" to "attribute"

This commit is contained in:
root
2024-08-22 06:42:37 +00:00
parent 678ddd718a
commit f660e6b2ac
38 changed files with 691 additions and 701 deletions

View File

@@ -14,7 +14,7 @@ add_definitions(-fPIC)
set(MAAT_SRC alignment.c json2iris.c maat_api.c rcu_hash.c maat_garbage_collection.c maat_config_monitor.c
maat_core.c maat_kv.c maat_ex_data.c maat_utils.c maat_command.c maat_redis_monitor.c maat_table.c
maat_rule.c maat_group.c maat_ip.c maat_flag.c maat_interval.c maat_expr.c maat_plugin.c
maat_ip_plugin.c maat_ipport_plugin.c maat_bool_plugin.c maat_fqdn_plugin.c maat_virtual.c maat_stat.c)
maat_ip_plugin.c maat_ipport_plugin.c maat_bool_plugin.c maat_fqdn_plugin.c maat_attribute.c maat_stat.c)
set(LIB_SOURCE_FILES
${PROJECT_SOURCE_DIR}/deps/cJSON/cJSON.c ${PROJECT_SOURCE_DIR}/deps/log/log.c)

View File

@@ -0,0 +1,63 @@
/*
**********************************************************************************************
* File: maat_attribute.h
* Description:
* Authors: Liu WenTan <liuwentan@geedgenetworks.com>
* Date: 2022-10-31
* Copyright: (c) Since 2022 Geedge Networks, Ltd. All rights reserved.
***********************************************************************************************
*/
#ifndef _MAAT_ATTRIBUTE_H_
#define _MAAT_ATTRIBUTE_H_
#ifdef __cplusplus
extern "C"
{
#endif
#include "cJSON/cJSON.h"
#include "maat_table.h"
struct attribute_runtime;
void *attribute_schema_new(cJSON *json, struct table_manager *tbl_mgr,
const char *table_name, struct log_handle *logger);
void attribute_schema_free(void *attribute_schema);
void *attribute_runtime_new(void *attribute_schema, size_t max_thread_num,
struct maat_garbage_bin *garbage_bin,
struct log_handle *logger);
void attribute_runtime_free(void *attribute_runtime);
void attribute_runtime_scan_times_inc(struct attribute_runtime *virt_rt,
int thread_id);
void attribute_runtime_scan_bytes_add(struct attribute_runtime *virt_rt,
int thread_id, long long val);
long long attribute_runtime_scan_bytes(void *virt_rt);
long long attribute_runtime_scan_times(void *attribute_runtime);
long long attribute_runtime_scan_cpu_time(void *attribute_runtime);
void attribute_runtime_hit_times_inc(struct attribute_runtime *virt_rt,
int thread_id);
long long attribute_runtime_hit_times(void *attribute_runtime);
void attribute_runtime_hit_item_num_add(struct attribute_runtime *virt_rt,
int thread_id, long long val);
long long attribute_runtime_hit_item_num(void *attribute_runtime);
int attribute_get_physical_table_id(struct table_manager *tbl_mgr, int attribute_id);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -31,7 +31,7 @@ extern "C"
#include "maat.h"
#include "maat_kv.h"
#include "maat_table.h"
#include "maat_virtual.h"
#include "maat_attribute.h"
#include "maat_stat.h"
#include "hiredis/hiredis.h"

View File

@@ -50,12 +50,12 @@ long long expr_runtime_get_version(void *expr_runtime);
* @retval the num of hit group_id
*/
int expr_runtime_scan(struct expr_runtime *expr_rt, int thread_id, const char *data,
size_t data_len, int vtable_id, struct maat_state *state);
size_t data_len, int attribute_id, struct maat_state *state);
struct expr_runtime_stream *expr_runtime_stream_open(struct expr_runtime *expr_rt, int thread_id);
int expr_runtime_stream_scan(struct expr_runtime_stream *expr_rt_stream, const char *data,
size_t data_len, int vtable_id, struct maat_state *state);
size_t data_len, int attribute_id, struct maat_state *state);
void expr_runtime_stream_close(struct expr_runtime_stream *expr_rt_stream);

View File

@@ -48,7 +48,7 @@ long long flag_runtime_rule_count(void *flag_runtime);
* @retval the num of hit group_id
*/
int flag_runtime_scan(struct flag_runtime *flag_rt, int thread_id, long long flag,
int vtable_id, struct maat_state *state);
int attribute_id, struct maat_state *state);
int flag_runtime_set_scan_district(struct flag_runtime *flag_rt, const char *district,
size_t district_len, long long *district_id);

View File

@@ -49,7 +49,7 @@ long long interval_runtime_rule_count(void *interval_runtime);
* @retval the num of hit group_id
*/
int interval_runtime_scan(struct interval_runtime *interval_rt, int thread_id,
long long integer, int vtable_id, struct maat_state *state);
long long integer, int attribute_id, struct maat_state *state);
int interval_runtime_set_scan_district(struct interval_runtime *interval_rt,
const char *district, size_t district_len,

View File

@@ -42,7 +42,7 @@ long long ip_runtime_ipv6_rule_count(void *ip_runtime);
/* ip runtime scan API */
int ip_runtime_scan(struct ip_runtime *ip_rt, int thread_id, int ip_type,
uint8_t *ip_addr, int port, int vtable_id, struct maat_state *state);
uint8_t *ip_addr, int port, int attribute_id, struct maat_state *state);
void ip_runtime_perf_stat(struct ip_runtime *ip_rt, struct timespec *start,
struct timespec *end, int thread_id);

View File

@@ -93,14 +93,14 @@ void rule_state_free(struct rule_state *rule_state,
struct maat *maat_instance, int thread_id);
int rule_state_update(struct rule_state *rule_state, struct maat *maat_inst,
int vtable_id, int custom_rule_tbl_id, int Nth_scan,
int attribute_id, int custom_rule_tbl_id, int Nth_scan,
struct maat_item *hit_items, size_t n_hit_item);
void rule_state_clear_last_hit_group(struct rule_state *rule_state);
void rule_state_not_logic_update(struct rule_state *rule_state,
struct rule_runtime *rule_rt,
struct maat *maat_inst, int vtable_id,
struct maat *maat_inst, int attribute_id,
int Nth_scan);
size_t rule_state_get_internal_hit_paths(struct rule_state *rule_state,

View File

@@ -38,7 +38,7 @@ enum table_type {
TABLE_TYPE_FQDN_PLUGIN,
TABLE_TYPE_BOOL_PLUGIN,
//above are physical table
TABLE_TYPE_VIRTUAL,
TABLE_TYPE_ATTRIBUTE,
TABLE_TYPE_RULE,
TABLE_TYPE_GROUP2GROUP,
TABLE_TYPE_GROUP2RULE,

View File

@@ -1,63 +0,0 @@
/*
**********************************************************************************************
* File: maat_virtual.h
* Description:
* Authors: Liu WenTan <liuwentan@geedgenetworks.com>
* Date: 2022-10-31
* Copyright: (c) Since 2022 Geedge Networks, Ltd. All rights reserved.
***********************************************************************************************
*/
#ifndef _MAAT_VIRTUAL_H_
#define _MAAT_VIRTUAL_H_
#ifdef __cplusplus
extern "C"
{
#endif
#include "cJSON/cJSON.h"
#include "maat_table.h"
struct virtual_runtime;
void *virtual_schema_new(cJSON *json, struct table_manager *tbl_mgr,
const char *table_name, struct log_handle *logger);
void virtual_schema_free(void *virtual_schema);
void *virtual_runtime_new(void *virtual_schema, size_t max_thread_num,
struct maat_garbage_bin *garbage_bin,
struct log_handle *logger);
void virtual_runtime_free(void *virtual_runtime);
void virtual_runtime_scan_times_inc(struct virtual_runtime *virt_rt,
int thread_id);
void virtual_runtime_scan_bytes_add(struct virtual_runtime *virt_rt,
int thread_id, long long val);
long long virtual_runtime_scan_bytes(void *virt_rt);
long long virtual_runtime_scan_times(void *virtual_runtime);
long long virtual_runtime_scan_cpu_time(void *virtual_runtime);
void virtual_runtime_hit_times_inc(struct virtual_runtime *virt_rt,
int thread_id);
long long virtual_runtime_hit_times(void *virtual_runtime);
void virtual_runtime_hit_item_num_add(struct virtual_runtime *virt_rt,
int thread_id, long long val);
long long virtual_runtime_hit_item_num(void *virtual_runtime);
int vtable_get_physical_table_id(struct table_manager *tbl_mgr, int vtable_id);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -644,7 +644,7 @@ write_region_rule(cJSON *region_json, int rule_id, int group_id,
static int
write_group2rule_line(int *group_ids, size_t n_group_id,
int rule_id, int group_not_flag,
int clause_index, const char *vtable,
int clause_index, const char *attribute,
struct iris_description *p_iris,
struct iris_table *g2c_table)
{
@@ -670,10 +670,10 @@ write_group2rule_line(int *group_ids, size_t n_group_id,
}
group_id_str[strlen(group_id_str) - 1] = '\0';
snprintf(buff, sizeof(buff), "%s\t%d\t%d\t%s\t%d\t1\n", group_id_str,
rule_id, group_not_flag, vtable, clause_index);
rule_id, group_not_flag, attribute, clause_index);
} else {
snprintf(buff, sizeof(buff), "%d\t%d\t%d\t%s\t%d\t1\n", group_ids[0],
rule_id, group_not_flag, vtable, clause_index);
rule_id, group_not_flag, attribute, clause_index);
}
table->write_pos += memcat(&(table->buff), table->write_pos,
@@ -759,7 +759,7 @@ write_group_rule(cJSON *group_json, int parent_id,
char group_name_array[32][MAX_NAME_STR_LEN];
size_t group_name_cnt = 0;
long long group_id = -1;
const char *virtual_table = NULL;
const char *attribute = NULL;
struct iris_table *g2c_table = NULL;
cJSON *item = cJSON_GetObjectItem(group_json, "group_name");
@@ -790,11 +790,11 @@ write_group_rule(cJSON *group_json, int parent_id,
}
if (parent_type == PARENT_TYPE_RULE) {
item = cJSON_GetObjectItem(group_json, "virtual_table");
item = cJSON_GetObjectItem(group_json, "attribute");
if (NULL == item || item->type != cJSON_String) {
virtual_table = "null";
attribute = "null";
} else {
virtual_table = item->valuestring;
attribute = item->valuestring;
}
item = cJSON_GetObjectItem(group_json, "not_flag");
@@ -834,7 +834,7 @@ write_group_rule(cJSON *group_json, int parent_id,
assert(parent_type == PARENT_TYPE_RULE);
ret = write_group2rule_line(group_ids, group_name_cnt, parent_id,
group_not_flag, clause_index,
virtual_table, p_iris, g2c_table);
attribute, p_iris, g2c_table);
} else {
struct group_info *group_info =
@@ -895,7 +895,7 @@ write_group_rule(cJSON *group_json, int parent_id,
if (parent_type == PARENT_TYPE_RULE) {
ret = write_group2rule_line(&(group_info->group_id), 1, parent_id,
group_not_flag, clause_index,
virtual_table, p_iris, g2c_table);
attribute, p_iris, g2c_table);
if (ret < 0) {
log_fatal(logger, MODULE_JSON2IRIS,
"[%s:%d] rule:%d write group error",

View File

@@ -39,7 +39,7 @@
#include "maat_ipport_plugin.h"
#include "maat_fqdn_plugin.h"
#include "maat_bool_plugin.h"
#include "maat_virtual.h"
#include "maat_attribute.h"
#include "maat_stat.h"
#include "uthash/utarray.h"
@@ -62,7 +62,7 @@ struct maat_stream {
long long expr_rt_version;
struct log_handle *logger;
int thread_id;
int vtable_id;
int attribute_id;
int phy_table_id;
};
@@ -1050,7 +1050,7 @@ int maat_bool_plugin_table_get_ex_data(struct maat *maat_inst, int table_id,
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 attribute_id, struct maat_state *state)
{
enum table_type table_type =
table_manager_get_table_type(tbl_mgr, phy_table_id);
@@ -1072,26 +1072,26 @@ flag_scan(struct table_manager *tbl_mgr, int thread_id, long long flag,
flag_runtime_scan_times_inc((struct flag_runtime *)flag_rt, thread_id);
void *virt_rt = NULL;
table_type = table_manager_get_table_type(tbl_mgr, vtable_id);
if (table_type == TABLE_TYPE_VIRTUAL) {
virt_rt = table_manager_get_runtime(tbl_mgr, vtable_id);
table_type = table_manager_get_table_type(tbl_mgr, attribute_id);
if (table_type == TABLE_TYPE_ATTRIBUTE) {
virt_rt = table_manager_get_runtime(tbl_mgr, attribute_id);
if (virt_rt != NULL) {
virtual_runtime_scan_times_inc((struct virtual_runtime *)virt_rt,
attribute_runtime_scan_times_inc((struct attribute_runtime *)virt_rt,
thread_id);
}
}
int group_hit_cnt = flag_runtime_scan((struct flag_runtime *)flag_rt,
thread_id, flag, vtable_id, state);
thread_id, flag, attribute_id, state);
if (group_hit_cnt <= 0) {
return group_hit_cnt;
}
if (virt_rt != NULL) {
//Note: group_hit_cnt is equivalent to item_hit_cnt
virtual_runtime_hit_item_num_add((struct virtual_runtime *)virt_rt,
attribute_runtime_hit_item_num_add((struct attribute_runtime *)virt_rt,
thread_id, group_hit_cnt);
virtual_runtime_hit_times_inc((struct virtual_runtime *)virt_rt, thread_id);
attribute_runtime_hit_times_inc((struct attribute_runtime *)virt_rt, thread_id);
}
flag_runtime_hit_times_inc((struct flag_runtime *)flag_rt, thread_id);
@@ -1101,7 +1101,7 @@ flag_scan(struct table_manager *tbl_mgr, int thread_id, long long flag,
static int
interval_scan(struct table_manager *tbl_mgr, int thread_id, long long integer,
int phy_table_id, int vtable_id, struct maat_state *state)
int phy_table_id, int attribute_id, struct maat_state *state)
{
enum table_type table_type =
@@ -1124,26 +1124,26 @@ interval_scan(struct table_manager *tbl_mgr, int thread_id, long long integer,
interval_runtime_scan_times_inc((struct interval_runtime *)interval_rt, thread_id);
void *virt_rt = NULL;
table_type = table_manager_get_table_type(tbl_mgr, vtable_id);
if (table_type == TABLE_TYPE_VIRTUAL) {
virt_rt = table_manager_get_runtime(tbl_mgr, vtable_id);
table_type = table_manager_get_table_type(tbl_mgr, attribute_id);
if (table_type == TABLE_TYPE_ATTRIBUTE) {
virt_rt = table_manager_get_runtime(tbl_mgr, attribute_id);
if (virt_rt != NULL) {
virtual_runtime_scan_times_inc((struct virtual_runtime *)virt_rt,
attribute_runtime_scan_times_inc((struct attribute_runtime *)virt_rt,
thread_id);
}
}
int group_hit_cnt = interval_runtime_scan((struct interval_runtime *)interval_rt,
thread_id, integer, vtable_id, state);
thread_id, integer, attribute_id, state);
if (group_hit_cnt <= 0) {
return group_hit_cnt;
}
if (virt_rt != NULL) {
//Note: group_hit_cnt is equivalent to item_hit_cnt
virtual_runtime_hit_item_num_add((struct virtual_runtime *)virt_rt,
attribute_runtime_hit_item_num_add((struct attribute_runtime *)virt_rt,
thread_id, group_hit_cnt);
virtual_runtime_hit_times_inc((struct virtual_runtime *)virt_rt, thread_id);
attribute_runtime_hit_times_inc((struct attribute_runtime *)virt_rt, thread_id);
}
interval_runtime_hit_times_inc((struct interval_runtime *)interval_rt, thread_id);
@@ -1153,7 +1153,7 @@ interval_scan(struct table_manager *tbl_mgr, int thread_id, long long integer,
static int
ipv4_scan(struct table_manager *tbl_mgr, int thread_id, uint32_t ip_addr,
int port, int phy_table_id, int vtable_id, struct maat_state *state)
int port, int phy_table_id, int attribute_id, struct maat_state *state)
{
enum table_type table_type =
@@ -1170,26 +1170,26 @@ ipv4_scan(struct table_manager *tbl_mgr, int thread_id, uint32_t ip_addr,
ip_runtime_scan_times_inc(ip_rt, thread_id);
void *virt_rt = NULL;
table_type = table_manager_get_table_type(tbl_mgr, vtable_id);
if (table_type == TABLE_TYPE_VIRTUAL) {
virt_rt = table_manager_get_runtime(tbl_mgr, vtable_id);
table_type = table_manager_get_table_type(tbl_mgr, attribute_id);
if (table_type == TABLE_TYPE_ATTRIBUTE) {
virt_rt = table_manager_get_runtime(tbl_mgr, attribute_id);
if (virt_rt != NULL) {
virtual_runtime_scan_times_inc((struct virtual_runtime *)virt_rt,
attribute_runtime_scan_times_inc((struct attribute_runtime *)virt_rt,
thread_id);
}
}
int group_hit_cnt = ip_runtime_scan((struct ip_runtime *)ip_rt, thread_id, IPv4,
(uint8_t *)&ip_addr, port, vtable_id, state);
(uint8_t *)&ip_addr, port, attribute_id, state);
if (group_hit_cnt <= 0) {
return group_hit_cnt;
}
if (virt_rt != NULL) {
//Note: group_hit_cnt is equivalent to item_hit_cnt
virtual_runtime_hit_item_num_add((struct virtual_runtime *)virt_rt,
attribute_runtime_hit_item_num_add((struct attribute_runtime *)virt_rt,
thread_id, group_hit_cnt);
virtual_runtime_hit_times_inc((struct virtual_runtime *)virt_rt, thread_id);
attribute_runtime_hit_times_inc((struct attribute_runtime *)virt_rt, thread_id);
}
ip_runtime_hit_times_inc((struct ip_runtime *)ip_rt, thread_id);
@@ -1199,7 +1199,7 @@ ipv4_scan(struct table_manager *tbl_mgr, int thread_id, uint32_t ip_addr,
static int
ipv6_scan(struct table_manager *tbl_mgr, int thread_id, uint8_t *ip_addr,
int port, int phy_table_id, int vtable_id, struct maat_state *state)
int port, int phy_table_id, int attribute_id, struct maat_state *state)
{
enum table_type table_type =
@@ -1216,26 +1216,26 @@ ipv6_scan(struct table_manager *tbl_mgr, int thread_id, uint8_t *ip_addr,
ip_runtime_scan_times_inc(ip_rt, thread_id);
void *virt_rt = NULL;
table_type = table_manager_get_table_type(tbl_mgr, vtable_id);
if (table_type == TABLE_TYPE_VIRTUAL) {
virt_rt = table_manager_get_runtime(tbl_mgr, vtable_id);
table_type = table_manager_get_table_type(tbl_mgr, attribute_id);
if (table_type == TABLE_TYPE_ATTRIBUTE) {
virt_rt = table_manager_get_runtime(tbl_mgr, attribute_id);
if (virt_rt != NULL) {
virtual_runtime_scan_times_inc((struct virtual_runtime *)virt_rt,
attribute_runtime_scan_times_inc((struct attribute_runtime *)virt_rt,
thread_id);
}
}
int group_hit_cnt = ip_runtime_scan((struct ip_runtime *)ip_rt, thread_id, IPv6,
ip_addr, port, vtable_id, state);
ip_addr, port, attribute_id, state);
if (group_hit_cnt <= 0) {
return group_hit_cnt;
}
if (virt_rt != NULL) {
//Note: group_hit_cnt is equivalent to item_hit_cnt
virtual_runtime_hit_item_num_add((struct virtual_runtime *)virt_rt,
attribute_runtime_hit_item_num_add((struct attribute_runtime *)virt_rt,
thread_id, group_hit_cnt);
virtual_runtime_hit_times_inc((struct virtual_runtime *)virt_rt, thread_id);
attribute_runtime_hit_times_inc((struct attribute_runtime *)virt_rt, thread_id);
}
ip_runtime_hit_times_inc((struct ip_runtime *)ip_rt, thread_id);
@@ -1246,7 +1246,7 @@ ipv6_scan(struct table_manager *tbl_mgr, int thread_id, uint8_t *ip_addr,
static int
string_scan(struct table_manager *tbl_mgr, int thread_id,
const char *data, size_t data_len, int phy_table_id,
int vtable_id, struct maat_state *state)
int attribute_id, struct maat_state *state)
{
enum table_type table_type =
table_manager_get_table_type(tbl_mgr, phy_table_id);
@@ -1269,29 +1269,29 @@ string_scan(struct table_manager *tbl_mgr, int thread_id,
expr_runtime_scan_bytes_add(expr_rt, thread_id, data_len);
void *virt_rt = NULL;
table_type = table_manager_get_table_type(tbl_mgr, vtable_id);
if (table_type == TABLE_TYPE_VIRTUAL) {
virt_rt = table_manager_get_runtime(tbl_mgr, vtable_id);
table_type = table_manager_get_table_type(tbl_mgr, attribute_id);
if (table_type == TABLE_TYPE_ATTRIBUTE) {
virt_rt = table_manager_get_runtime(tbl_mgr, attribute_id);
if (virt_rt != NULL) {
virtual_runtime_scan_times_inc((struct virtual_runtime *)virt_rt,
attribute_runtime_scan_times_inc((struct attribute_runtime *)virt_rt,
thread_id);
virtual_runtime_scan_bytes_add((struct virtual_runtime *)virt_rt,
attribute_runtime_scan_bytes_add((struct attribute_runtime *)virt_rt,
thread_id, data_len);
}
}
int group_hit_cnt = expr_runtime_scan((struct expr_runtime *)expr_rt,
thread_id, data, data_len,
vtable_id, state);
attribute_id, state);
if (group_hit_cnt <= 0) {
return group_hit_cnt;
}
if (virt_rt != NULL) {
//Note: group_hit_cnt is equivalent to item_hit_cnt
virtual_runtime_hit_item_num_add((struct virtual_runtime *)virt_rt,
attribute_runtime_hit_item_num_add((struct attribute_runtime *)virt_rt,
thread_id, group_hit_cnt);
virtual_runtime_hit_times_inc((struct virtual_runtime *)virt_rt, thread_id);
attribute_runtime_hit_times_inc((struct attribute_runtime *)virt_rt, thread_id);
}
expr_runtime_hit_times_inc((struct expr_runtime *)expr_rt, thread_id);
@@ -1342,13 +1342,13 @@ int maat_scan_flag(struct maat *maat_inst, int table_id,
return MAAT_SCAN_OK;
}
int vtable_id = table_id;
int attribute_id = table_id;
int phy_table_id = table_id;
enum table_type table_type = TABLE_TYPE_INVALID;
table_type = table_manager_get_table_type(maat_inst->tbl_mgr, table_id);
if (table_type == TABLE_TYPE_VIRTUAL) {
phy_table_id = vtable_get_physical_table_id(maat_inst->tbl_mgr, table_id);
if (table_type == TABLE_TYPE_ATTRIBUTE) {
phy_table_id = attribute_get_physical_table_id(maat_inst->tbl_mgr, table_id);
}
if (phy_table_id < 0) {
@@ -1364,7 +1364,7 @@ int maat_scan_flag(struct maat *maat_inst, int table_id,
alignment_int64_array_add(maat_inst->stat->thread_call_cnt, state->thread_id, 1);
int hit_group_cnt = flag_scan(maat_inst->tbl_mgr, state->thread_id, flag,
phy_table_id, vtable_id, state);
phy_table_id, attribute_id, state);
if (hit_group_cnt < 0) {
maat_inst->stat->scan_err_cnt++;
return MAAT_SCAN_ERR;
@@ -1426,13 +1426,13 @@ int maat_scan_integer(struct maat *maat_inst, int table_id,
return MAAT_SCAN_OK;
}
int vtable_id = table_id;
int attribute_id = table_id;
int phy_table_id = table_id;
enum table_type table_type = TABLE_TYPE_INVALID;
table_type = table_manager_get_table_type(maat_inst->tbl_mgr, table_id);
if (table_type == TABLE_TYPE_VIRTUAL) {
phy_table_id = vtable_get_physical_table_id(maat_inst->tbl_mgr, table_id);
if (table_type == TABLE_TYPE_ATTRIBUTE) {
phy_table_id = attribute_get_physical_table_id(maat_inst->tbl_mgr, table_id);
}
if (phy_table_id < 0) {
@@ -1449,7 +1449,7 @@ int maat_scan_integer(struct maat *maat_inst, int table_id,
alignment_int64_array_add(maat_inst->stat->thread_call_cnt, state->thread_id, 1);
int hit_group_cnt = interval_scan(maat_inst->tbl_mgr, state->thread_id, integer,
phy_table_id, vtable_id, state);
phy_table_id, attribute_id, state);
if (hit_group_cnt < 0) {
maat_inst->stat->scan_err_cnt++;
return MAAT_SCAN_ERR;
@@ -1511,13 +1511,13 @@ int maat_scan_ipv4_port(struct maat *maat_inst, int table_id, uint32_t ip_addr,
return MAAT_SCAN_OK;
}
int vtable_id = table_id;
int attribute_id = table_id;
int phy_table_id = table_id;
enum table_type table_type = TABLE_TYPE_INVALID;
table_type = table_manager_get_table_type(maat_inst->tbl_mgr, table_id);
if (table_type == TABLE_TYPE_VIRTUAL) {
phy_table_id = vtable_get_physical_table_id(maat_inst->tbl_mgr, table_id);
if (table_type == TABLE_TYPE_ATTRIBUTE) {
phy_table_id = attribute_get_physical_table_id(maat_inst->tbl_mgr, table_id);
}
if (phy_table_id < 0) {
@@ -1533,7 +1533,7 @@ int maat_scan_ipv4_port(struct maat *maat_inst, int table_id, uint32_t ip_addr,
alignment_int64_array_add(maat_inst->stat->thread_call_cnt, state->thread_id, 1);
int hit_group_cnt = ipv4_scan(maat_inst->tbl_mgr, state->thread_id, ip_addr, port,
phy_table_id, vtable_id, state);
phy_table_id, attribute_id, state);
if (hit_group_cnt < 0) {
maat_inst->stat->scan_err_cnt++;
return MAAT_SCAN_ERR;
@@ -1595,13 +1595,13 @@ int maat_scan_ipv6_port(struct maat *maat_inst, int table_id, uint8_t *ip_addr,
return MAAT_SCAN_OK;
}
int vtable_id = table_id;
int attribute_id = table_id;
int phy_table_id = table_id;
enum table_type table_type = TABLE_TYPE_INVALID;
table_type = table_manager_get_table_type(maat_inst->tbl_mgr, table_id);
if (table_type == TABLE_TYPE_VIRTUAL) {
phy_table_id = vtable_get_physical_table_id(maat_inst->tbl_mgr, table_id);
if (table_type == TABLE_TYPE_ATTRIBUTE) {
phy_table_id = attribute_get_physical_table_id(maat_inst->tbl_mgr, table_id);
}
if (phy_table_id < 0) {
@@ -1617,7 +1617,7 @@ int maat_scan_ipv6_port(struct maat *maat_inst, int table_id, uint8_t *ip_addr,
alignment_int64_array_add(maat_inst->stat->thread_call_cnt, state->thread_id, 1);
int hit_group_cnt = ipv6_scan(maat_inst->tbl_mgr, state->thread_id, ip_addr, port,
phy_table_id, vtable_id, state);
phy_table_id, attribute_id, state);
if (hit_group_cnt < 0) {
maat_inst->stat->scan_err_cnt++;
return MAAT_SCAN_ERR;
@@ -1698,13 +1698,13 @@ int maat_scan_string(struct maat *maat_inst, int table_id,
return MAAT_SCAN_OK;
}
int vtable_id = table_id;
int attribute_id = table_id;
int phy_table_id = table_id;
enum table_type table_type = TABLE_TYPE_INVALID;
table_type = table_manager_get_table_type(maat_inst->tbl_mgr, table_id);
if (table_type == TABLE_TYPE_VIRTUAL) {
phy_table_id = vtable_get_physical_table_id(maat_inst->tbl_mgr, table_id);
if (table_type == TABLE_TYPE_ATTRIBUTE) {
phy_table_id = attribute_get_physical_table_id(maat_inst->tbl_mgr, table_id);
}
if (phy_table_id < 0) {
@@ -1720,7 +1720,7 @@ int maat_scan_string(struct maat *maat_inst, int table_id,
alignment_int64_array_add(maat_inst->stat->thread_call_cnt, state->thread_id, 1);
int hit_group_cnt = string_scan(maat_inst->tbl_mgr, state->thread_id, data,
data_len, phy_table_id, vtable_id, state);
data_len, phy_table_id, attribute_id, state);
if (hit_group_cnt < 0) {
maat_inst->stat->scan_err_cnt++;
return MAAT_SCAN_ERR;
@@ -1840,18 +1840,18 @@ int maat_scan_group(struct maat *maat_inst, int table_id,
return MAAT_SCAN_OK;
}
int vtable_id = table_id;
int attribute_id = table_id;
enum table_type table_type = TABLE_TYPE_INVALID;
table_type = table_manager_get_table_type(maat_inst->tbl_mgr, table_id);
if (table_type == TABLE_TYPE_VIRTUAL) {
void *virt_rt = table_manager_get_runtime(maat_inst->tbl_mgr, vtable_id);
if (table_type == TABLE_TYPE_ATTRIBUTE) {
void *virt_rt = table_manager_get_runtime(maat_inst->tbl_mgr, attribute_id);
if (virt_rt != NULL) {
virtual_runtime_scan_times_inc((struct virtual_runtime *)virt_rt,
attribute_runtime_scan_times_inc((struct attribute_runtime *)virt_rt,
state->thread_id);
virtual_runtime_hit_times_inc((struct virtual_runtime *)virt_rt,
attribute_runtime_hit_times_inc((struct attribute_runtime *)virt_rt,
state->thread_id);
virtual_runtime_hit_item_num_add((struct virtual_runtime *)virt_rt,
attribute_runtime_hit_item_num_add((struct attribute_runtime *)virt_rt,
state->thread_id, n_group);
}
}
@@ -1922,14 +1922,14 @@ struct maat_stream *maat_stream_new(struct maat *maat_inst, int table_id,
stream->last_full_version = maat_inst->last_full_version;
stream->thread_id = state->thread_id;
stream->phy_table_id = table_id;
stream->vtable_id = table_id;
stream->attribute_id = table_id;
stream->logger = maat_inst->logger;
enum table_type table_type = TABLE_TYPE_INVALID;
table_type = table_manager_get_table_type(maat_inst->tbl_mgr, table_id);
if (table_type == TABLE_TYPE_VIRTUAL) {
stream->phy_table_id = vtable_get_physical_table_id(maat_inst->tbl_mgr,
if (table_type == TABLE_TYPE_ATTRIBUTE) {
stream->phy_table_id = attribute_get_physical_table_id(maat_inst->tbl_mgr,
table_id);
}
@@ -1993,28 +1993,28 @@ static int expr_stream_scan(struct maat_stream *stream, const char *data,
data_len);
void *virt_rt = NULL;
table_type = table_manager_get_table_type(tbl_mgr, stream->vtable_id);
if (table_type == TABLE_TYPE_VIRTUAL) {
virt_rt = table_manager_get_runtime(tbl_mgr, stream->vtable_id);
table_type = table_manager_get_table_type(tbl_mgr, stream->attribute_id);
if (table_type == TABLE_TYPE_ATTRIBUTE) {
virt_rt = table_manager_get_runtime(tbl_mgr, stream->attribute_id);
if (virt_rt != NULL) {
virtual_runtime_scan_times_inc((struct virtual_runtime *)virt_rt,
attribute_runtime_scan_times_inc((struct attribute_runtime *)virt_rt,
stream->thread_id);
virtual_runtime_scan_bytes_add((struct virtual_runtime *)virt_rt,
attribute_runtime_scan_bytes_add((struct attribute_runtime *)virt_rt,
stream->thread_id, data_len);
}
}
int group_hit_cnt = expr_runtime_stream_scan(stream->expr_rt_stream, data,
data_len, stream->vtable_id, state);
data_len, stream->attribute_id, state);
if (group_hit_cnt <= 0) {
return group_hit_cnt;
}
if (virt_rt != NULL) {
//Note: group_hit_cnt is equivalent to item_hit_cnt
virtual_runtime_hit_item_num_add((struct virtual_runtime *)virt_rt,
attribute_runtime_hit_item_num_add((struct attribute_runtime *)virt_rt,
stream->thread_id, group_hit_cnt);
virtual_runtime_hit_times_inc((struct virtual_runtime *)virt_rt, stream->thread_id);
attribute_runtime_hit_times_inc((struct attribute_runtime *)virt_rt, stream->thread_id);
}
expr_runtime_stream_hit_times_inc(stream->expr_rt_stream, stream->thread_id);
@@ -2200,13 +2200,13 @@ int maat_state_set_scan_district(struct maat_state *state, int table_id,
enum table_type table_type = TABLE_TYPE_INVALID;
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 &&
table_type != TABLE_TYPE_INTERVAL_PLUS && table_type != TABLE_TYPE_VIRTUAL) {
table_type != TABLE_TYPE_INTERVAL_PLUS && table_type != TABLE_TYPE_ATTRIBUTE) {
return -1;
}
int phy_table_id = table_id;
if (table_type == TABLE_TYPE_VIRTUAL) {
phy_table_id = vtable_get_physical_table_id(maat_inst->tbl_mgr, table_id);
if (table_type == TABLE_TYPE_ATTRIBUTE) {
phy_table_id = attribute_get_physical_table_id(maat_inst->tbl_mgr, table_id);
}
int ret = -1;

View File

@@ -1,6 +1,6 @@
/*
**********************************************************************************************
* File: maat_virtual.c
* File: maat_attribute.c
* Description:
* Authors: Liu WenTan <liuwentan@geedgenetworks.com>
* Date: 2022-10-31
@@ -17,15 +17,15 @@
#include "maat_core.h"
#include "maat_table.h"
#define MODULE_VIRTUAL module_name_str("maat.virtual")
#define MODULE_ATTRIBUTE module_name_str("maat.attribute")
struct virtual_schema {
int vtable_id;
struct attribute_schema {
int attribute_id;
int physical_table_id;
struct table_manager *ref_tbl_mgr;
};
struct virtual_runtime {
struct attribute_runtime {
size_t n_worker_thread;
long long *scan_times;
long long *scan_bytes;
@@ -34,33 +34,33 @@ struct virtual_runtime {
long long *hit_item_num;
};
void *virtual_schema_new(cJSON *json, struct table_manager *tbl_mgr,
void *attribute_schema_new(cJSON *json, struct table_manager *tbl_mgr,
const char *table_name, struct log_handle *logger)
{
struct virtual_schema *schema = ALLOC(struct virtual_schema, 1);
struct attribute_schema *schema = ALLOC(struct attribute_schema, 1);
schema->ref_tbl_mgr = tbl_mgr;
cJSON *item = cJSON_GetObjectItem(json, "table_id");
if (NULL == item || item->type != cJSON_Number) {
log_fatal(logger, MODULE_VIRTUAL,
"[%s:%d] virtual table:<%s> schema has no table_id column",
log_fatal(logger, MODULE_ATTRIBUTE,
"[%s:%d] attribute:<%s> schema has no table_id column",
__FUNCTION__, __LINE__, table_name);
goto error;
}
schema->vtable_id = item->valueint;
schema->attribute_id = item->valueint;
item = cJSON_GetObjectItem(json, "physical_table");
if (NULL == item || item->type != cJSON_String) {
log_fatal(logger, MODULE_VIRTUAL,
"[%s:%d] virtual table:<%s> schema has no physical_table column",
log_fatal(logger, MODULE_ATTRIBUTE,
"[%s:%d] attribute:<%s> schema has no physical_table column",
__FUNCTION__, __LINE__, table_name);
goto error;
}
schema->physical_table_id = table_manager_get_table_id(tbl_mgr, item->valuestring);
if (schema->physical_table_id < 0) {
log_fatal(logger, MODULE_VIRTUAL,
"[%s:%d] virtual table:<%s>'s physical table:<%s> unregistered.",
log_fatal(logger, MODULE_ATTRIBUTE,
"[%s:%d] attribute:<%s>'s physical table:<%s> unregistered.",
__FUNCTION__, __LINE__, table_name, item->valuestring);
goto error;
}
@@ -71,20 +71,20 @@ error:
return NULL;
}
void virtual_schema_free(void *virtual_schema)
void attribute_schema_free(void *attribute_schema)
{
FREE(virtual_schema);
FREE(attribute_schema);
}
void *virtual_runtime_new(void *virtual_schema, size_t max_thread_num,
void *attribute_runtime_new(void *attribute_schema, size_t max_thread_num,
struct maat_garbage_bin *garbage_bin,
struct log_handle *logger)
{
if (NULL == virtual_schema) {
if (NULL == attribute_schema) {
return NULL;
}
struct virtual_runtime *virt_rt = ALLOC(struct virtual_runtime, 1);
struct attribute_runtime *virt_rt = ALLOC(struct attribute_runtime, 1);
virt_rt->n_worker_thread = max_thread_num;
virt_rt->scan_times = alignment_int64_array_alloc(max_thread_num);
@@ -96,13 +96,13 @@ void *virtual_runtime_new(void *virtual_schema, size_t max_thread_num,
return virt_rt;
}
void virtual_runtime_free(void *virtual_runtime)
void attribute_runtime_free(void *attribute_runtime)
{
if (NULL == virtual_runtime) {
if (NULL == attribute_runtime) {
return;
}
struct virtual_runtime *virt_rt = (struct virtual_runtime *)virtual_runtime;
struct attribute_runtime *virt_rt = (struct attribute_runtime *)attribute_runtime;
if (virt_rt->scan_times != NULL) {
alignment_int64_array_free(virt_rt->scan_times);
@@ -132,7 +132,7 @@ void virtual_runtime_free(void *virtual_runtime)
FREE(virt_rt);
}
void virtual_runtime_scan_bytes_add(struct virtual_runtime *virt_rt,
void attribute_runtime_scan_bytes_add(struct attribute_runtime *virt_rt,
int thread_id, long long val)
{
if (NULL == virt_rt || thread_id < 0) {
@@ -142,13 +142,13 @@ void virtual_runtime_scan_bytes_add(struct virtual_runtime *virt_rt,
alignment_int64_array_add(virt_rt->scan_bytes, thread_id, val);
}
long long virtual_runtime_scan_bytes(void *virtual_runtime)
long long attribute_runtime_scan_bytes(void *attribute_runtime)
{
if (NULL == virtual_runtime) {
if (NULL == attribute_runtime) {
return 0;
}
struct virtual_runtime *virt_rt = (struct virtual_runtime *)virtual_runtime;
struct attribute_runtime *virt_rt = (struct attribute_runtime *)attribute_runtime;
long long sum = alignment_int64_array_sum(virt_rt->scan_bytes,
virt_rt->n_worker_thread);
alignment_int64_array_reset(virt_rt->scan_bytes,
@@ -157,7 +157,7 @@ long long virtual_runtime_scan_bytes(void *virtual_runtime)
return sum;
}
void virtual_runtime_scan_times_inc(struct virtual_runtime *virt_rt,
void attribute_runtime_scan_times_inc(struct attribute_runtime *virt_rt,
int thread_id)
{
if (NULL == virt_rt || thread_id < 0) {
@@ -167,13 +167,13 @@ void virtual_runtime_scan_times_inc(struct virtual_runtime *virt_rt,
alignment_int64_array_add(virt_rt->scan_times, thread_id, 1);
}
long long virtual_runtime_scan_times(void *virtual_runtime)
long long attribute_runtime_scan_times(void *attribute_runtime)
{
if (NULL == virtual_runtime) {
if (NULL == attribute_runtime) {
return 0;
}
struct virtual_runtime *virt_rt = (struct virtual_runtime *)virtual_runtime;
struct attribute_runtime *virt_rt = (struct attribute_runtime *)attribute_runtime;
long long sum = alignment_int64_array_sum(virt_rt->scan_times,
virt_rt->n_worker_thread);
alignment_int64_array_reset(virt_rt->scan_times,
@@ -182,13 +182,13 @@ long long virtual_runtime_scan_times(void *virtual_runtime)
return sum;
}
long long virtual_runtime_scan_cpu_time(void *virtual_runtime)
long long attribute_runtime_scan_cpu_time(void *attribute_runtime)
{
if (NULL == virtual_runtime) {
if (NULL == attribute_runtime) {
return 0;
}
struct virtual_runtime *virt_rt = (struct virtual_runtime *)virtual_runtime;
struct attribute_runtime *virt_rt = (struct attribute_runtime *)attribute_runtime;
long long sum = alignment_int64_array_sum(virt_rt->scan_cpu_time,
virt_rt->n_worker_thread);
alignment_int64_array_reset(virt_rt->scan_cpu_time,
@@ -197,7 +197,7 @@ long long virtual_runtime_scan_cpu_time(void *virtual_runtime)
return sum;
}
void virtual_runtime_hit_times_inc(struct virtual_runtime *virt_rt,
void attribute_runtime_hit_times_inc(struct attribute_runtime *virt_rt,
int thread_id)
{
if (NULL == virt_rt || thread_id < 0) {
@@ -207,13 +207,13 @@ void virtual_runtime_hit_times_inc(struct virtual_runtime *virt_rt,
alignment_int64_array_add(virt_rt->hit_times, thread_id, 1);
}
long long virtual_runtime_hit_times(void *virtual_runtime)
long long attribute_runtime_hit_times(void *attribute_runtime)
{
if (NULL == virtual_runtime) {
if (NULL == attribute_runtime) {
return 0;
}
struct virtual_runtime *virt_rt = (struct virtual_runtime *)virtual_runtime;
struct attribute_runtime *virt_rt = (struct attribute_runtime *)attribute_runtime;
long long sum = alignment_int64_array_sum(virt_rt->hit_times,
virt_rt->n_worker_thread);
alignment_int64_array_reset(virt_rt->hit_times,
@@ -222,7 +222,7 @@ long long virtual_runtime_hit_times(void *virtual_runtime)
return sum;
}
void virtual_runtime_hit_item_num_add(struct virtual_runtime *virt_rt,
void attribute_runtime_hit_item_num_add(struct attribute_runtime *virt_rt,
int thread_id, long long val)
{
if (NULL == virt_rt || thread_id < 0) {
@@ -232,13 +232,13 @@ void virtual_runtime_hit_item_num_add(struct virtual_runtime *virt_rt,
alignment_int64_array_add(virt_rt->hit_item_num, thread_id, val);
}
long long virtual_runtime_hit_item_num(void *virtual_runtime)
long long attribute_runtime_hit_item_num(void *attribute_runtime)
{
if (NULL == virtual_runtime) {
if (NULL == attribute_runtime) {
return 0;
}
struct virtual_runtime *virt_rt = (struct virtual_runtime *)virtual_runtime;
struct attribute_runtime *virt_rt = (struct attribute_runtime *)attribute_runtime;
long long sum = alignment_int64_array_sum(virt_rt->hit_item_num,
virt_rt->n_worker_thread);
alignment_int64_array_reset(virt_rt->hit_item_num,
@@ -247,27 +247,17 @@ long long virtual_runtime_hit_item_num(void *virtual_runtime)
return sum;
}
static int virtual_table_get_physical_table_id(void *virtual_schema)
{
if (NULL == virtual_schema) {
return 0;
}
struct virtual_schema *schema = (struct virtual_schema *)virtual_schema;
return schema->physical_table_id;
}
int vtable_get_physical_table_id(struct table_manager *tbl_mgr, int table_id)
int attribute_get_physical_table_id(struct table_manager *tbl_mgr, int table_id)
{
enum table_type table_type = table_manager_get_table_type(tbl_mgr, table_id);
if (table_type != TABLE_TYPE_VIRTUAL) {
if (table_type != TABLE_TYPE_ATTRIBUTE) {
return -1;
}
// find physical table id
void *virtual_schema = table_manager_get_schema(tbl_mgr, table_id);
assert(virtual_schema != NULL);
return virtual_table_get_physical_table_id(virtual_schema);
struct attribute_schema *attribute_schema = table_manager_get_schema(tbl_mgr, table_id);
assert(attribute_schema != NULL);
return attribute_schema->physical_table_id;
}

View File

@@ -951,7 +951,7 @@ long long expr_runtime_get_version(void *expr_runtime)
int expr_runtime_scan(struct expr_runtime *expr_rt, int thread_id,
const char *data, size_t data_len,
int vtable_id, struct maat_state *state)
int attribute_id, struct maat_state *state)
{
//clear rule_state->last_hit_group
if (state != NULL && state->rule_state != NULL) {
@@ -1019,7 +1019,7 @@ next:
state->thread_id, 1);
}
return rule_state_update(state->rule_state, state->maat_inst, vtable_id,
return rule_state_update(state->rule_state, state->maat_inst, attribute_id,
state->rule_table_id, state->Nth_scan,
hit_maat_items, real_hit_item_num);
}
@@ -1045,7 +1045,7 @@ expr_runtime_stream_open(struct expr_runtime *expr_rt, int thread_id)
int expr_runtime_stream_scan(struct expr_runtime_stream *expr_rt_stream,
const char *data, size_t data_len,
int vtable_id, struct maat_state *state)
int attribute_id, struct maat_state *state)
{
struct expr_runtime *expr_rt = expr_rt_stream->ref_expr_rt;
@@ -1113,7 +1113,7 @@ next:
state->thread_id, 1);
}
return rule_state_update(state->rule_state, state->maat_inst, vtable_id,
return rule_state_update(state->rule_state, state->maat_inst, attribute_id,
state->rule_table_id, state->Nth_scan,
hit_maat_items, real_hit_item_cnt);
}

View File

@@ -553,7 +553,7 @@ long long flag_runtime_rule_count(void *flag_runtime)
}
int flag_runtime_scan(struct flag_runtime *flag_rt, int thread_id,
long long flag, int vtable_id, struct maat_state *state)
long long flag, int attribute_id, struct maat_state *state)
{
//clear rule_state->last_hit_group
if (state != NULL && state->rule_state != NULL) {
@@ -615,7 +615,7 @@ next:
state->thread_id, 1);
}
return rule_state_update(state->rule_state, state->maat_inst, vtable_id,
return rule_state_update(state->rule_state, state->maat_inst, attribute_id,
state->rule_table_id, state->Nth_scan,
hit_maat_items, real_hit_item_cnt);
}

View File

@@ -542,7 +542,7 @@ long long interval_runtime_rule_count(void *interval_runtime)
}
int interval_runtime_scan(struct interval_runtime *interval_rt, int thread_id,
long long integer, int vtable_id, struct maat_state *state)
long long integer, int attribute_id, struct maat_state *state)
{
//clear rule_state->last_hit_group
if (state != NULL && state->rule_state != NULL) {
@@ -604,7 +604,7 @@ next:
state->thread_id, 1);
}
return rule_state_update(state->rule_state, state->maat_inst, vtable_id,
return rule_state_update(state->rule_state, state->maat_inst, attribute_id,
state->rule_table_id, state->Nth_scan,
hit_maat_items, real_hit_item_cnt);
}

View File

@@ -520,7 +520,7 @@ long long ip_runtime_ipv6_rule_count(void *ip_runtime)
}
int ip_runtime_scan(struct ip_runtime *ip_rt, int thread_id, int ip_type,
uint8_t *ip_addr, int port, int vtable_id, struct maat_state *state)
uint8_t *ip_addr, int port, int attribute_id, struct maat_state *state)
{
//clear rule_state->last_hit_group
if (state != NULL && state->rule_state != NULL) {
@@ -599,7 +599,7 @@ next:
state->thread_id, 1);
}
return rule_state_update(state->rule_state, state->maat_inst, vtable_id,
return rule_state_update(state->rule_state, state->maat_inst, attribute_id,
state->rule_table_id, state->Nth_scan,
hit_maat_items, real_hit_item_cnt);
}

View File

@@ -22,7 +22,7 @@
#include "maat_config_monitor.h"
#include "maat_redis_monitor.h"
#include "maat_plugin.h"
#include "maat_virtual.h"
#include "maat_attribute.h"
#define MODULE_REDIS_MONITOR module_name_str("maat.redis_monitor")

View File

@@ -48,7 +48,7 @@ struct group2rule_schema {
int group_id_column;
int rule_id_column;
int not_flag_column;
int vtable_name_column;
int attribute_name_column;
int clause_index_column;
int asso_rule_table_id; //asso is abbreviation for associated
int table_id;
@@ -66,13 +66,13 @@ struct group2rule_item {
UT_array *group_ids;
long long rule_id;
int not_flag;
int vtable_id;
int attribute_id;
int clause_index;
};
struct clause_query_key {
long long group_id;
int vtable_id;
int attribute_id;
int not_flag;
};
@@ -83,7 +83,7 @@ struct clause_id_kv {
};
struct table_clause {
int vtable_id;
int attribute_id;
int actual_clause_num;
UT_array *clause_ids;
UT_array *group_ids;
@@ -91,7 +91,7 @@ struct table_clause {
};
struct table_group {
int vtable_id;
int attribute_id;
UT_array *group_ids;
UT_hash_handle hh;
};
@@ -117,13 +117,13 @@ struct group2rule_runtime {
long long rule_num;
long long update_err_cnt;
struct rule_runtime *ref_rule_rt;
struct table_clause *tbl_not_clause_hash; //each virtual table's not clause number <= MAX_NOT_CLAUSE_NUM
struct table_clause *tbl_not_clause_hash; //each attribute's not clause number <= MAX_NOT_CLAUSE_NUM
};
struct clause_literal {
long long group_ids[MAX_GROUP_CNT];
int group_cnt;
int vtable_id;
int attribute_id;
};
struct rule_clause {
@@ -154,7 +154,7 @@ struct internal_hit_path {
long long item_id;
long long group_id;
int Nth_scan;
int vtable_id;
int attribute_id;
int NOT_flag; // 1 means NOT clause
};
@@ -479,12 +479,12 @@ void *group2rule_schema_new(cJSON *json, struct table_manager *tbl_mgr,
goto error;
}
custom_item = cJSON_GetObjectItem(item, "virtual_table_name");
custom_item = cJSON_GetObjectItem(item, "attribute_name");
if (custom_item != NULL && custom_item->type == cJSON_Number) {
g2c_schema->vtable_name_column = custom_item->valueint;
g2c_schema->attribute_name_column = custom_item->valueint;
} else {
log_fatal(logger, MODULE_RULE,
"[%s:%d] table: <%s> schema has no virtual_table_name column",
"[%s:%d] table: <%s> schema has no attribute_name column",
__FUNCTION__, __LINE__, table_name);
goto error;
}
@@ -691,7 +691,7 @@ group2rule_item_new(const char *line, struct group2rule_schema *g2c_schema,
{
size_t column_offset = 0;
size_t column_len = 0;
char vtable_name[MAX_NAME_STR_LEN + 1] = {0};
char attribute_name[MAX_NAME_STR_LEN + 1] = {0};
struct group2rule_item *g2c_item = ALLOC(struct group2rule_item, 1);
utarray_new(g2c_item->group_ids, &ut_rule_group_id_icd);
@@ -750,33 +750,33 @@ group2rule_item_new(const char *line, struct group2rule_schema *g2c_schema,
goto error;
}
ret = get_column_pos(line, g2c_schema->vtable_name_column, &column_offset,
ret = get_column_pos(line, g2c_schema->attribute_name_column, &column_offset,
&column_len);
if (ret < 0) {
log_fatal(logger, MODULE_RULE,
"[%s:%d] g2c table:<%s> has no virtual_table_name in line:%s",
"[%s:%d] g2c table:<%s> has no attribute_name in line:%s",
__FUNCTION__, __LINE__, table_name, line);
goto error;
}
if (column_len > MAX_NAME_STR_LEN) {
log_fatal(logger, MODULE_RULE,
"[%s:%d] g2c table:<%s> virtual_table_name length exceed "
"[%s:%d] g2c table:<%s> attribute_name length exceed "
"maxium:%d in line:%s", __FUNCTION__, __LINE__, table_name,
MAX_NAME_STR_LEN, line);
goto error;
}
memset(vtable_name, 0, sizeof(vtable_name));
memcpy(vtable_name, (line + column_offset), column_len);
memset(attribute_name, 0, sizeof(attribute_name));
memcpy(attribute_name, (line + column_offset), column_len);
if (is_valid_table_name(vtable_name)) {
g2c_item->vtable_id = table_manager_get_table_id(g2c_schema->ref_tbl_mgr,
vtable_name);
if (g2c_item->vtable_id < 0) {
if (is_valid_table_name(attribute_name)) {
g2c_item->attribute_id = table_manager_get_table_id(g2c_schema->ref_tbl_mgr,
attribute_name);
if (g2c_item->attribute_id < 0) {
log_fatal(logger, MODULE_RULE,
"[%s:%d] g2c table:<%s> has unknown virtual table:%s in line:%s",
__FUNCTION__, __LINE__, table_name, vtable_name, line);
"[%s:%d] g2c table:<%s> has unknown attribute:%s in line:%s",
__FUNCTION__, __LINE__, table_name, attribute_name, line);
goto error;
}
}
@@ -823,7 +823,7 @@ static void rule_clause_add_literal(struct rule_clause *clause,
struct group2rule_item *g2c_item)
{
struct clause_literal tmp_literal;
tmp_literal.vtable_id = g2c_item->vtable_id;
tmp_literal.attribute_id = g2c_item->attribute_id;
tmp_literal.group_cnt = utarray_len(g2c_item->group_ids);
utarray_sort(g2c_item->group_ids, compare_group_id);
@@ -840,7 +840,7 @@ void rule_clause_remove_literal(struct rule_clause *clause,
for (size_t i = 0; i < utarray_len(clause->literals); i++) {
tmp_literal = (struct clause_literal *)utarray_eltptr(clause->literals, i);
if (tmp_literal->vtable_id == g2c_item->vtable_id) {
if (tmp_literal->attribute_id == g2c_item->attribute_id) {
size_t remove_idx = utarray_eltidx(clause->literals, tmp_literal);
utarray_erase(clause->literals, remove_idx, 1);
break;
@@ -857,7 +857,7 @@ static int maat_rule_clause_find_literal(struct maat_rule *rule,
for (size_t i = 0; i < utarray_len(clause->literals); i++) {
tmp_literal = (struct clause_literal *)utarray_eltptr(clause->literals, i);
if (tmp_literal->vtable_id == g2c_item->vtable_id) {
if (tmp_literal->attribute_id == g2c_item->attribute_id) {
found = 1;
}
}
@@ -944,7 +944,7 @@ maat_rule_bool_matcher_new(struct rule_runtime *rule_rt,
for (size_t it = 0; it < tmp_cl->group_cnt; it++) {
printf("<before bool_matcher_new> rule_rt:%p rule_id:%lld, clause_id:%llu, clause_query_key{%lld: %d, %d}\n",
rule_rt, iter_rule->rule_id, iter_rule->clauses[i].clause_id, tmp_cl->group_ids[it],
tmp_cl->vtable_id, iter_rule->clauses[i].not_flag);
tmp_cl->attribute_id, iter_rule->clauses[i].not_flag);
}
}
#endif
@@ -1011,7 +1011,7 @@ static inline int compare_hit_group(const void *pa, const void *pb)
if (0 == ret) {
ret = la->group_id - lb->group_id;
if (0 == ret) {
ret = la->vtable_id - lb->vtable_id;
ret = la->attribute_id - lb->attribute_id;
}
}
@@ -1076,7 +1076,7 @@ build_clause_id_kv_hash(struct rule_runtime *rule_rt, int not_flag)
for (size_t k = 0; k < tmp_cl->group_cnt; k++) {
struct clause_query_key key =
{tmp_cl->group_ids[k], tmp_cl->vtable_id, clause->not_flag};
{tmp_cl->group_ids[k], tmp_cl->attribute_id, clause->not_flag};
struct clause_id_kv *clause_id_kv = NULL;
HASH_FIND(hh, clause_id_kv_hash, &key, sizeof(struct clause_query_key),
@@ -1283,9 +1283,9 @@ static int maat_add_group_to_rule(struct rcu_hash_table *hash_tbl,
ret = maat_rule_clause_find_literal(rule, g2c_item);
if (ret > 0) {
log_fatal(logger, MODULE_RULE,
"[%s:%d]rule:%lld clause(index:%d) already has vtable_id:%d's "
"[%s:%d]rule:%lld clause(index:%d) already has attribute_id:%d's "
"literal, can't add again", __FUNCTION__, __LINE__, rule->rule_id,
g2c_item->clause_index, g2c_item->vtable_id);
g2c_item->clause_index, g2c_item->attribute_id);
return -1;
}
/* rule found in updating hash(added by rule runtime), it can
@@ -1314,9 +1314,9 @@ static int maat_add_group_to_rule(struct rcu_hash_table *hash_tbl,
ret = maat_rule_clause_find_literal(rule, g2c_item);
if (ret > 0) {
log_fatal(logger, MODULE_RULE,
"[%s:%d]rule:%lld clause(index:%d) already has vtable_id:%d's "
"[%s:%d]rule:%lld clause(index:%d) already has attribute_id:%d's "
"literal, can't add again", __FUNCTION__, __LINE__, rule->rule_id,
g2c_item->clause_index, g2c_item->vtable_id);
g2c_item->clause_index, g2c_item->attribute_id);
return -1;
}
@@ -1362,9 +1362,9 @@ static int maat_remove_group_from_rule(struct rcu_hash_table *hash_tbl,
ret = maat_rule_clause_find_literal(rule, g2c_item);
if (0 == ret) {
log_fatal(logger, MODULE_RULE,
"[%s:%d]rule:%lld clause(index:%d) has no vtable_id:%d's "
"[%s:%d]rule:%lld clause(index:%d) has no attribute_id:%d's "
"literal, can't be removed", __FUNCTION__, __LINE__,
rule->rule_id, g2c_item->clause_index, g2c_item->vtable_id);
rule->rule_id, g2c_item->clause_index, g2c_item->attribute_id);
return -1;
}
@@ -1381,9 +1381,9 @@ static int maat_remove_group_from_rule(struct rcu_hash_table *hash_tbl,
ret = maat_rule_clause_find_literal(rule, g2c_item);
if (0 == ret) {
log_fatal(logger, MODULE_RULE,
"[%s:%d]rule:%lld clause(index:%d) has no vtable_id:%d's "
"[%s:%d]rule:%lld clause(index:%d) has no attribute_id:%d's "
"literal, can't be removed", __FUNCTION__, __LINE__,
rule->rule_id, g2c_item->clause_index, g2c_item->vtable_id);
rule->rule_id, g2c_item->clause_index, g2c_item->attribute_id);
return -1;
}
@@ -1570,7 +1570,7 @@ void rule_state_free(struct rule_state *rule_state,
static void
rule_state_add_internal_hit_path(struct rule_state *rule_state,
long long item_id, long long group_id,
int vtable_id, int NOT_flag, int Nth_scan)
int attribute_id, int NOT_flag, int Nth_scan)
{
if (NULL == rule_state) {
return;
@@ -1580,7 +1580,7 @@ rule_state_add_internal_hit_path(struct rule_state *rule_state,
new_path.item_id = item_id;
new_path.Nth_scan = Nth_scan;
new_path.group_id = group_id;
new_path.vtable_id = vtable_id;
new_path.attribute_id = attribute_id;
new_path.NOT_flag = NOT_flag;
utarray_push_back(rule_state->internal_hit_paths, &new_path);
@@ -1598,7 +1598,7 @@ static int maat_rule_has_clause_query_key(struct maat_rule *rule,
struct clause_literal *tmp_cl = NULL;
for (size_t j = 0; j < utarray_len(clause->literals); j++) {
tmp_cl = (struct clause_literal *)utarray_eltptr(clause->literals, j);
if (tmp_cl->vtable_id != key->vtable_id) {
if (tmp_cl->attribute_id != key->attribute_id) {
continue;
}
@@ -1620,7 +1620,7 @@ static int maat_rule_has_clause_query_key(struct maat_rule *rule,
static size_t
maat_rule_get_hit_clause_index(struct maat_rule *rule,
int vtable_id, long long hit_group_id,
int attribute_id, long long hit_group_id,
int *clause_idx_array, size_t array_size)
{
size_t hit_clause_cnt = 0;
@@ -1635,7 +1635,7 @@ maat_rule_get_hit_clause_index(struct maat_rule *rule,
struct clause_literal *tmp_cl = NULL;
for (size_t j = 0; j < utarray_len(tmp_clause->literals); j++) {
tmp_cl = (struct clause_literal *)utarray_eltptr(tmp_clause->literals, j);
if (tmp_cl->vtable_id != vtable_id) {
if (tmp_cl->attribute_id != attribute_id) {
continue;
}
@@ -1685,7 +1685,7 @@ void populate_hit_path_with_rule(struct maat_hit_path *hit_path_array,
hit_path_array[idx].rule_id = rule->rule_id;
// find out which clause in rule hit
n_clause_index =
maat_rule_get_hit_clause_index(rule, hit_path_array[idx].vtable_id,
maat_rule_get_hit_clause_index(rule, hit_path_array[idx].attribute_id,
hit_path_array[idx].top_group_id,
clause_index_array,
MAX_ITEMS_PER_BOOL_EXPR);
@@ -1706,7 +1706,7 @@ void populate_hit_path_with_rule(struct maat_hit_path *hit_path_array,
hit_path_array[n_hit_path + new_hit_path_cnt] = tmp_path;
new_hit_path_cnt++;
n_clause_index =
maat_rule_get_hit_clause_index(rule, tmp_path.vtable_id, tmp_path.top_group_id,
maat_rule_get_hit_clause_index(rule, tmp_path.attribute_id, tmp_path.top_group_id,
clause_index_array, MAX_ITEMS_PER_BOOL_EXPR);
hit_path_array[n_hit_path + new_hit_path_cnt - 1].clause_index = clause_index_array[0];
if (n_clause_index > 1) {
@@ -1760,7 +1760,7 @@ size_t rule_runtime_get_hit_paths(struct rule_runtime *rule_rt, int thread_id,
key.group_id = hit_path_array[j].top_group_id;
}
key.vtable_id = hit_path_array[j].vtable_id;
key.attribute_id = hit_path_array[j].attribute_id;
key.not_flag = hit_path_array[j].NOT_flag;
if (maat_rule_has_clause_query_key(rule, &key)) {
populate_hit_path_with_rule(hit_path_array, j, n_hit_path,
@@ -1775,7 +1775,7 @@ size_t rule_runtime_get_hit_paths(struct rule_runtime *rule_rt, int thread_id,
static void
rule_state_add_direct_hit_groups(struct rule_state *rule_state,
struct maat_item *hit_items,
size_t n_hit_items, int vtable_id)
size_t n_hit_items, int attribute_id)
{
if (NULL == rule_state || NULL == hit_items) {
return;
@@ -1785,7 +1785,7 @@ rule_state_add_direct_hit_groups(struct rule_state *rule_state,
for (size_t i = 0; i < n_hit_items; i++) {
hit_group.item_id = hit_items[i].item_id;
hit_group.group_id = hit_items[i].group_id;
hit_group.vtable_id = vtable_id;
hit_group.attribute_id = attribute_id;
utarray_push_back(rule_state->direct_hit_groups, &hit_group);
}
}
@@ -1793,7 +1793,7 @@ rule_state_add_direct_hit_groups(struct rule_state *rule_state,
static void
rule_state_add_indirect_hit_groups(struct rule_state *rule_state,
long long *group_ids,
size_t n_group_ids, int vtable_id)
size_t n_group_ids, int attribute_id)
{
if (NULL == rule_state || NULL == group_ids) {
return;
@@ -1803,7 +1803,7 @@ rule_state_add_indirect_hit_groups(struct rule_state *rule_state,
for (size_t i = 0; i < n_group_ids; i++) {
hit_group.item_id = 0;
hit_group.group_id = group_ids[i];
hit_group.vtable_id = vtable_id;
hit_group.attribute_id = attribute_id;
utarray_push_back(rule_state->indirect_hit_groups, &hit_group);
}
}
@@ -1887,13 +1887,13 @@ rule_state_add_hit_not_clauses(struct rule_state *rule_state,
static void
rule_state_update_hit_clauses(struct rule_state *rule_state,
struct rule_runtime *rule_rt,
long long group_id, int vtable_id)
long long group_id, int attribute_id)
{
if (NULL == rule_state || NULL == rule_rt) {
return;
}
struct clause_query_key key = {group_id, vtable_id, 0};
struct clause_query_key key = {group_id, attribute_id, 0};
struct clause_id_kv *clause_id_kv = NULL;
HASH_FIND(hh, rule_rt->clause_id_kv_hash, &key, sizeof(key), clause_id_kv);
@@ -1912,7 +1912,7 @@ static void
rule_state_cache_hit_not_groups(struct rule_state *rule_state,
struct rule_runtime *rule_rt,
long long *hit_group_ids,
size_t n_hit_group_id, int vtable_id)
size_t n_hit_group_id, int attribute_id)
{
if (NULL == rule_state || NULL == rule_rt) {
return;
@@ -1923,7 +1923,7 @@ rule_state_cache_hit_not_groups(struct rule_state *rule_state,
}
struct table_group *tbl_group = NULL;
HASH_FIND(hh, rule_state->hit_not_tbl_groups, &vtable_id, sizeof(int), tbl_group);
HASH_FIND(hh, rule_state->hit_not_tbl_groups, &attribute_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,
@@ -1939,7 +1939,7 @@ rule_state_cache_hit_not_groups(struct rule_state *rule_state,
struct clause_id_kv *clause_id_kv = NULL, *tmp_clause_id_kv = NULL;
HASH_ITER(hh, rule_rt->not_clause_id_kv_hash, clause_id_kv, tmp_clause_id_kv) {
if (clause_id_kv->key.vtable_id != vtable_id) {
if (clause_id_kv->key.attribute_id != attribute_id) {
continue;
}
@@ -1952,9 +1952,9 @@ rule_state_cache_hit_not_groups(struct rule_state *rule_state,
if (NULL == tbl_group) {
tbl_group = ALLOC(struct table_group, 1);
tbl_group->vtable_id = vtable_id;
tbl_group->attribute_id = attribute_id;
utarray_new(tbl_group->group_ids, &ut_rule_group_id_icd);
HASH_ADD_INT(rule_state->hit_not_tbl_groups, vtable_id, tbl_group);
HASH_ADD_INT(rule_state->hit_not_tbl_groups, attribute_id, tbl_group);
}
if (!utarray_find(tbl_group->group_ids, &(clause_id_kv->key.group_id),
@@ -2189,9 +2189,9 @@ static int validate_table_not_clause(struct group2rule_runtime *g2c_rt,
//add
if (NULL == not_clause) {
not_clause = ALLOC(struct table_clause, 1);
not_clause->vtable_id = table_id;
not_clause->attribute_id = table_id;
not_clause->actual_clause_num++;
HASH_ADD_INT(g2c_rt->tbl_not_clause_hash, vtable_id, not_clause);
HASH_ADD_INT(g2c_rt->tbl_not_clause_hash, attribute_id, not_clause);
} else {
if (not_clause->actual_clause_num >= MAX_NOT_CLAUSE_NUM) {
const char *table_name = table_manager_get_table_name(tbl_mgr, table_id);
@@ -2239,7 +2239,7 @@ int group2rule_runtime_update(void *g2c_runtime, void *g2c_schema,
if (1 == g2c_item->not_flag) {
ret = validate_table_not_clause(g2c_rt, schema->ref_tbl_mgr,
g2c_item->vtable_id, is_valid,
g2c_item->attribute_id, is_valid,
rule_rt->logger);
if (ret < 0) {
log_fatal(rule_rt->logger, MODULE_RULE,
@@ -2478,7 +2478,7 @@ int rule_runtime_match(struct rule_runtime *rule_rt, long long *rule_ids,
}
int rule_state_update(struct rule_state *rule_state, struct maat *maat_inst,
int vtable_id, int custom_rule_tbl_id, int Nth_scan,
int attribute_id, int custom_rule_tbl_id, int Nth_scan,
struct maat_item *hit_items, size_t n_hit_item)
{
size_t i = 0, j = 0;
@@ -2495,7 +2495,7 @@ int rule_state_update(struct rule_state *rule_state, struct maat *maat_inst,
hit_group.item_id = hit_items[i].item_id;
hit_group.group_id = hit_items[i].group_id;
hit_group.vtable_id = vtable_id;
hit_group.attribute_id = attribute_id;
utarray_push_back(rule_state->last_hit_groups, &hit_group);
}
@@ -2509,21 +2509,21 @@ int rule_state_update(struct rule_state *rule_state, struct maat *maat_inst,
for (i = 0; i < super_group_cnt; i++) {
hit_group.item_id = 0;
hit_group.group_id = super_group_ids[i];
hit_group.vtable_id = vtable_id;
hit_group.attribute_id = attribute_id;
utarray_push_back(rule_state->last_hit_groups, &hit_group);
}
if (1 == maat_inst->opts.hit_path_on && hit_cnt > 0) {
for (i = 0; i < hit_cnt; i++) {
rule_state_add_internal_hit_path(rule_state, hit_items[i].item_id,
hit_items[i].group_id, vtable_id, 0, Nth_scan);
hit_items[i].group_id, attribute_id, 0, Nth_scan);
}
}
if (1 == maat_inst->opts.hit_group_on) {
rule_state_add_direct_hit_groups(rule_state, hit_items, hit_cnt, vtable_id);
rule_state_add_direct_hit_groups(rule_state, hit_items, hit_cnt, attribute_id);
rule_state_add_indirect_hit_groups(rule_state, super_group_ids,
super_group_cnt, vtable_id);
super_group_cnt, attribute_id);
}
/* update hit clause */
@@ -2544,11 +2544,11 @@ int rule_state_update(struct rule_state *rule_state, struct maat *maat_inst,
for (i = 0; i < hit_cnt; i++) {
rule_state_update_hit_clauses(rule_state, rule_rt,
hit_group_ids[i], vtable_id);
hit_group_ids[i], attribute_id);
}
rule_state_cache_hit_not_groups(rule_state, rule_rt, hit_group_ids,
hit_cnt, vtable_id);
hit_cnt, attribute_id);
return hit_cnt;
}
@@ -2563,7 +2563,7 @@ void rule_state_clear_last_hit_group(struct rule_state *rule_state)
void rule_state_not_logic_update(struct rule_state *rule_state,
struct rule_runtime *rule_rt,
struct maat *maat_inst, int vtable_id,
struct maat *maat_inst, int attribute_id,
int Nth_scan)
{
if (NULL == rule_state || NULL == maat_inst) {
@@ -2575,7 +2575,7 @@ void rule_state_not_logic_update(struct rule_state *rule_state,
utarray_clear(rule_state->this_scan_hit_not_clauses);
struct table_group *tbl_group = NULL;
HASH_FIND(hh, rule_state->hit_not_tbl_groups, &vtable_id, sizeof(int), tbl_group);
HASH_FIND(hh, rule_state->hit_not_tbl_groups, &attribute_id, sizeof(int), tbl_group);
if (NULL == tbl_group) {
return;
}
@@ -2583,7 +2583,7 @@ void rule_state_not_logic_update(struct rule_state *rule_state,
struct clause_id_kv *clause_id_kv = 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 clause_query_key key = {*group_id, vtable_id, 1};
struct clause_query_key key = {*group_id, attribute_id, 1};
HASH_FIND(hh, rule_rt->not_clause_id_kv_hash, &key, sizeof(key), clause_id_kv);
if (NULL == clause_id_kv) {
@@ -2593,7 +2593,7 @@ void rule_state_not_logic_update(struct rule_state *rule_state,
rule_state_add_hit_not_clauses(rule_state, clause_id_kv->clause_ids);
if (1 == maat_inst->opts.hit_path_on) {
rule_state_add_internal_hit_path(rule_state, -1, *group_id,
vtable_id, 1, Nth_scan);
attribute_id, 1, Nth_scan);
}
}
}
@@ -2609,7 +2609,7 @@ size_t rule_state_get_indirect_hit_groups(struct rule_state *rule_state,
(struct maat_hit_group *)utarray_eltptr(rule_state->indirect_hit_groups, i);
group_array[i].item_id = hit_group->item_id;
group_array[i].group_id = hit_group->group_id;
group_array[i].vtable_id = hit_group->vtable_id;
group_array[i].attribute_id = hit_group->attribute_id;
}
utarray_clear(rule_state->indirect_hit_groups);
@@ -2653,7 +2653,7 @@ size_t rule_state_get_direct_hit_groups(struct rule_state *rule_state,
group = (struct maat_hit_group *)utarray_eltptr(direct_hit_group, i);
group_array[i].item_id = group->item_id;
group_array[i].group_id = group->group_id;
group_array[i].vtable_id = group->vtable_id;
group_array[i].attribute_id = group->attribute_id;
}
utarray_clear(rule_state->direct_hit_groups);
@@ -2712,7 +2712,7 @@ size_t rule_state_get_internal_hit_paths(struct rule_state *rule_state,
tmp_path.item_id = internal_path->item_id;
tmp_path.sub_group_id = internal_path->group_id;
tmp_path.top_group_id = *p;
tmp_path.vtable_id = internal_path->vtable_id;
tmp_path.attribute_id = internal_path->attribute_id;
tmp_path.NOT_flag = internal_path->NOT_flag;
tmp_path.clause_index = -1;
tmp_path.rule_id = -1;

View File

@@ -320,7 +320,7 @@ static void fs_table_row_refresh(struct maat_stat *stat, int perf_on)
fieldstat_easy_counter_set(stat->fs_handle, 0,
stat->fs_column_id[COLUMN_HIT_ITEM_NUM],
&cell_tag, 1, hit_item_num);
if (table_type != TABLE_TYPE_VIRTUAL) {
if (table_type != TABLE_TYPE_ATTRIBUTE) {
total_regv6_num += regex_rule_num;
total_regv6_num += ipv6_rule_num;
total_rule_num += rule_num;

View File

@@ -27,7 +27,7 @@
#include "maat_bool_plugin.h"
#include "maat_fqdn_plugin.h"
#include "maat_interval.h"
#include "maat_virtual.h"
#include "maat_attribute.h"
#include "expr_matcher/expr_matcher.h"
#define MODULE_TABLE module_name_str("maat.table")
@@ -264,18 +264,18 @@ struct table_operations table_ops[TABLE_TYPE_MAX] = {
.update_err_count = bool_plugin_runtime_update_err_count
},
{
.type = TABLE_TYPE_VIRTUAL,
.new_schema = virtual_schema_new,
.free_schema = virtual_schema_free,
.new_runtime = virtual_runtime_new,
.free_runtime = virtual_runtime_free,
.type = TABLE_TYPE_ATTRIBUTE,
.new_schema = attribute_schema_new,
.free_schema = attribute_schema_free,
.new_runtime = attribute_runtime_new,
.free_runtime = attribute_runtime_free,
.update_runtime = NULL,
.commit_runtime = NULL,
.scan_times = virtual_runtime_scan_times,
.scan_bytes = virtual_runtime_scan_bytes,
.scan_cpu_time = virtual_runtime_scan_cpu_time,
.hit_times = virtual_runtime_hit_times,
.hit_item_num = virtual_runtime_hit_item_num
.scan_times = attribute_runtime_scan_times,
.scan_bytes = attribute_runtime_scan_bytes,
.scan_cpu_time = attribute_runtime_scan_cpu_time,
.hit_times = attribute_runtime_hit_times,
.hit_item_num = attribute_runtime_hit_item_num
},
{
.type = TABLE_TYPE_RULE,
@@ -514,7 +514,7 @@ static void register_reserved_word(struct maat_kv_store *reserved_word_map)
maat_kv_register(reserved_word_map, "ipport_plugin", TABLE_TYPE_IPPORT_PLUGIN);
maat_kv_register(reserved_word_map, "bool_plugin", TABLE_TYPE_BOOL_PLUGIN);
maat_kv_register(reserved_word_map, "fqdn_plugin", TABLE_TYPE_FQDN_PLUGIN);
maat_kv_register(reserved_word_map, "virtual", TABLE_TYPE_VIRTUAL);
maat_kv_register(reserved_word_map, "attribute", TABLE_TYPE_ATTRIBUTE);
}
static struct maat_table *
@@ -598,7 +598,7 @@ maat_table_new(cJSON *json, struct maat_kv_store *reserved_word_map,
item = cJSON_GetObjectItem(json, "valid_column");
if (NULL == item || item->type != cJSON_Number) {
if (ptable->table_type != TABLE_TYPE_VIRTUAL) {
if (ptable->table_type != TABLE_TYPE_ATTRIBUTE) {
log_fatal(logger, MODULE_TABLE,
"[%s:%d] table:%s has no valid column",
__FUNCTION__, __LINE__, ptable->table_name);
@@ -912,10 +912,10 @@ table_manager_create(const char *table_info_path, const char *accept_tags,
tbl_mgr->tbl[maat_tbl->table_id] = maat_tbl;
tbl_mgr->n_table++;
if (maat_tbl->table_type == TABLE_TYPE_VIRTUAL) {
int phy_table_id = vtable_get_physical_table_id(tbl_mgr, maat_tbl->table_id);
if (maat_tbl->table_type == TABLE_TYPE_ATTRIBUTE) {
int phy_table_id = attribute_get_physical_table_id(tbl_mgr, maat_tbl->table_id);
log_info(logger, MODULE_TABLE,
"successfully register virtual table[%s]->vtable_id:%d,"
"successfully register attribute[%s]->attribute_id:%d,"
" physical_table_id:%d", maat_tbl->table_name, maat_tbl->table_id,
phy_table_id);
} else {