From 696594ea83b82291cf068d6f6770414b7e453415 Mon Sep 17 00:00:00 2001 From: zhengchao Date: Wed, 19 Jun 2019 19:54:44 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BF=AE=E5=A4=8D=E9=BB=98=E8=AE=A4=E6=8B=A6?= =?UTF-8?q?=E6=88=AA=E7=AD=96=E7=95=A5=E4=B8=8D=E7=94=9F=E6=95=88=E7=9A=84?= =?UTF-8?q?bug=EF=BC=9B=202.=20=E5=B0=86maat=E7=94=9F=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E7=94=9F=E6=95=88=E6=97=B6=E9=97=B4=E6=94=B9=E4=B8=BA1?= =?UTF-8?q?=E7=A7=92=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/kni_maat.cpp | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/entry/src/kni_maat.cpp b/entry/src/kni_maat.cpp index 786cde9..84887b1 100644 --- a/entry/src/kni_maat.cpp +++ b/entry/src/kni_maat.cpp @@ -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);