Merge branch 'bugfix-default-intercept-policy' into 'kni2a'
1.修复默认拦截策略不生效的bug; 2. 将maat生配置生效时间改为1秒。 See merge request tango/kni!10
This commit is contained in:
@@ -30,10 +30,21 @@ void kni_maat_destroy(struct kni_maat_handle *handle){
|
||||
|
||||
void compile_ex_param_new(int idx, const struct Maat_rule_t* rule, const char* srv_def_large, MAAT_RULE_EX_DATA* ad, long argl, void *argp){
|
||||
void *logger = argp;
|
||||
unsigned char tmp=0;
|
||||
KNI_LOG_DEBUG(logger, "call compile_ex_param_new");
|
||||
if(rule->config_id == 0){
|
||||
unsigned char action = (unsigned char)rule->action;
|
||||
g_maat_default_action = (enum kni_action)action;
|
||||
tmp=(unsigned char)rule->action;
|
||||
enum kni_action action = (enum kni_action)tmp;
|
||||
if(action==KNI_ACTION_INTERCEPT)
|
||||
{
|
||||
g_maat_default_action = KNI_ACTION_INTERCEPT;
|
||||
KNI_LOG_INFO(logger, "Set default intercept action to intercept.");
|
||||
}
|
||||
else
|
||||
{
|
||||
g_maat_default_action = KNI_ACTION_BYPASS;
|
||||
KNI_LOG_INFO(logger, "Set default intercept action to bypass.");
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -56,12 +67,13 @@ struct kni_maat_handle* kni_maat_init(const char* profile, void *logger){
|
||||
char tableinfo_path[KNI_PATH_MAX];
|
||||
char tablename_intercept_ip[KNI_SYMBOL_MAX];
|
||||
char tablename_intercept_domain[KNI_SYMBOL_MAX];
|
||||
char compile_alias[KNI_SYMBOL_MAX];
|
||||
char compile_table[KNI_SYMBOL_MAX];
|
||||
char maatjson_path[KNI_PATH_MAX];
|
||||
char redis_ip[INET_ADDRSTRLEN];
|
||||
int redis_port;
|
||||
int redis_index;
|
||||
Maat_feather_t feather = NULL;
|
||||
int effective_interval_ms=1000;//1s
|
||||
int tableid_intercept_ip = -1;
|
||||
int tableid_intercept_domain = -1;
|
||||
struct kni_maat_handle *handle = NULL;
|
||||
@@ -85,19 +97,14 @@ struct kni_maat_handle* kni_maat_init(const char* profile, void *logger){
|
||||
KNI_LOG_ERROR(logger, "MESA_prof_load: tablename_intercept_domain not set, profile is %s, section is %s", profile, section);
|
||||
goto error_out;
|
||||
}
|
||||
ret = MESA_load_profile_string_nodef(profile, section, "compile_alias", compile_alias, sizeof(compile_alias));
|
||||
if(ret < 0){
|
||||
KNI_LOG_ERROR(logger, "MESA_prof_load: compile_alias not set, profile is %s, section is %s", profile, section);
|
||||
goto error_out;
|
||||
}
|
||||
ret = MESA_load_profile_int_nodef(profile, section, "default_action", (int*)&g_maat_default_action);
|
||||
if(ret < 0){
|
||||
KNI_LOG_ERROR(logger, "MESA_prof_load: default_action not set, profile is %s, section is %s", profile, section);
|
||||
goto error_out;
|
||||
}
|
||||
KNI_LOG_ERROR(logger, "MESA_prof_load, [%s]:\n readconf_mode: %d\n tableinfo_path: %s\n tablename_intercept_ip: %s\n tablename_intercept_domain: %s\n"
|
||||
"compile_alias: %s\n default_action: %d", section, readconf_mode, tableinfo_path, tablename_intercept_ip,
|
||||
tablename_intercept_domain, compile_alias, g_maat_default_action);
|
||||
"compile_table: %s\n default_action: %d", section, readconf_mode, tableinfo_path, tablename_intercept_ip,
|
||||
tablename_intercept_domain, compile_table, g_maat_default_action);
|
||||
feather = Maat_feather(g_iThreadNum, tableinfo_path, logger);
|
||||
handle = ALLOC(struct kni_maat_handle, 1);
|
||||
handle->feather = feather;
|
||||
@@ -105,6 +112,7 @@ struct kni_maat_handle* kni_maat_init(const char* profile, void *logger){
|
||||
KNI_LOG_ERROR(logger, "Failed at Maat_feather, max_thread_num is %d, tableinfo_path is %s", g_iThreadNum, tableinfo_path);
|
||||
return NULL;
|
||||
}
|
||||
Maat_set_feather_opt(feather, MAAT_OPT_EFFECT_INVERVAL_MS, &effective_interval_ms, sizeof(effective_interval_ms));
|
||||
switch(readconf_mode){
|
||||
case KNI_MAAT_READCONF_JSON:
|
||||
ret = MESA_load_profile_string_nodef(profile, section, "maatjson_path", maatjson_path, sizeof(maatjson_path));
|
||||
@@ -159,7 +167,7 @@ struct kni_maat_handle* kni_maat_init(const char* profile, void *logger){
|
||||
tablename_intercept_domain, tableid_intercept_domain);
|
||||
goto error_out;
|
||||
}
|
||||
ret = Maat_rule_get_ex_new_index(feather, compile_alias, compile_ex_param_new, compile_ex_param_free, compile_ex_param_dup, 0, logger);
|
||||
ret = Maat_rule_get_ex_new_index(feather, "PXY_INTERCEPT_COMPILE", compile_ex_param_new, compile_ex_param_free, compile_ex_param_dup, 0, logger);
|
||||
if(ret < 0){
|
||||
KNI_LOG_ERROR(logger, "Failed at Maat_rule_get_ex_new_index, ret is %d", ret);
|
||||
kni_maat_destroy(handle);
|
||||
|
||||
Reference in New Issue
Block a user