diff options
| author | 崔一鸣 <[email protected]> | 2018-12-18 13:51:41 +0800 |
|---|---|---|
| committer | 崔一鸣 <[email protected]> | 2018-12-18 13:51:41 +0800 |
| commit | abaa4322165f523736f9d847d1cffdf438d64968 (patch) | |
| tree | 569c281ce541d4bf5f2cce6b2a474ae613e55d2f | |
| parent | 887f5ff506f95af2316b3370d9c1c1d0c4ae91b1 (diff) | |
增加dnat_policy端口为0的情况
| -rw-r--r-- | access/src/ip_mgr.cpp | 23 | ||||
| -rw-r--r-- | access/test/test_maat_redis.cpp | 4 |
2 files changed, 22 insertions, 5 deletions
diff --git a/access/src/ip_mgr.cpp b/access/src/ip_mgr.cpp index 4894dfc..ccad08c 100644 --- a/access/src/ip_mgr.cpp +++ b/access/src/ip_mgr.cpp @@ -131,21 +131,38 @@ int ip_mgr_dnat_policy_query(struct ip_mgr_handle *handle, uint32_t orig_ip, uin struct dnat_policy_htable_value dup_value; MESA_htable_search_cb(handle->dnat_policy_htable, (const unsigned char *)key, sizeof(struct dnat_policy_htable_key), dnat_policy_query_cb, &dup_value, &cb_rtn); - FREE(&key); FS_operate(g_fs_handle->handle, g_fs_handle->line_dnat_policy, g_fs_handle->cloumn_query_num, FS_OP_ADD, 1); if(cb_rtn == MGW_HTABLE_KEY_NOT_EXISTED) { FS_operate(g_fs_handle->handle, g_fs_handle->line_dnat_policy, g_fs_handle->cloumn_cache_miss, FS_OP_ADD, 1); MGW_LOG_ERROR(logger, "MESA_htable: key not existed, table is %s, original dest is <%s:%d>", "dnat_policy_htable", orig_ip_str, ntohs(orig_port)); - return -1; + //port=0 + key->orig_port = 0; + MESA_htable_search_cb(handle->dnat_policy_htable, (const unsigned char *)key, sizeof(struct dnat_policy_htable_key), + dnat_policy_query_cb, &dup_value, &cb_rtn); + FS_operate(g_fs_handle->handle, g_fs_handle->line_dnat_policy, g_fs_handle->cloumn_query_num, FS_OP_ADD, 1); + if(cb_rtn == MGW_HTABLE_KEY_NOT_EXISTED) + { + FS_operate(g_fs_handle->handle, g_fs_handle->line_dnat_policy, g_fs_handle->cloumn_cache_miss, FS_OP_ADD, 1); + MGW_LOG_ERROR(logger, "MESA_htable: key not existed, table is %s, original dest is <%s:%d>", "dnat_policy_htable", orig_ip_str, 0); + FREE(&key); + return -1; + } + FS_operate(g_fs_handle->handle, g_fs_handle->line_dnat_policy, g_fs_handle->cloumn_cache_hit, FS_OP_ADD, 1); + MGW_LOG_INFO(logger, "MESA_htable: key existed, table is %s, original dest is <%s:%d>", "dnat_policy_htable", orig_ip_str, 0); + *trans_port = orig_port; + } + else + { + *trans_port = dup_value.trans_port; } *trans_ip = dup_value.trans_ip; - *trans_port = dup_value.trans_port; char trans_ip_str[MGW_SYMBOL_MAX]; mgw_utils_inet_ntoa(*trans_ip, trans_ip_str); FS_operate(g_fs_handle->handle, g_fs_handle->line_dnat_policy, g_fs_handle->cloumn_cache_hit, FS_OP_ADD, 1); MGW_LOG_INFO(logger, "MESA_htable: key existed, table is %s, original dest is <%s:%d>, translated dest is <%s:%d>", "dnat_policy_htable", orig_ip_str, ntohs(orig_port), trans_ip_str, ntohs(*trans_port)); + FREE(&key); return 0; } diff --git a/access/test/test_maat_redis.cpp b/access/test/test_maat_redis.cpp index 3c20497..838cdb9 100644 --- a/access/test/test_maat_redis.cpp +++ b/access/test/test_maat_redis.cpp @@ -17,9 +17,9 @@ void wrapped_Maat_set_feather_opt(Maat_feather_t feather, enum MAAT_INIT_OPT typ Maat_feather_t Maat_init() { // load conf - char *table_info_path = "./conf/table_info.conf"; + char *table_info_path = (char *)"./conf/table_info.conf"; int max_thread_num = 1; - char *Maat_redis_ip = "192.168.11.243"; + char *Maat_redis_ip = (char *)"192.168.11.243"; int Maat_redis_port = 6800; int Maat_redis_index = 5; |
