diff options
| -rw-r--r-- | tunnat/src/runtime.cc | 9 | ||||
| -rw-r--r-- | tunnat/src/session.cc | 11 |
2 files changed, 17 insertions, 3 deletions
diff --git a/tunnat/src/runtime.cc b/tunnat/src/runtime.cc index f17689e..9143cf1 100644 --- a/tunnat/src/runtime.cc +++ b/tunnat/src/runtime.cc @@ -101,13 +101,18 @@ static void __phy_to_virt_link_info_check(TunnatInstance * instance, TunnatThrea marsio_buff_t * mbuf, TunnelContainerArray &tun_array) { LinkInfoTable * link_info_table = th_instance->link_info_table; - tunnat_link_id_t link_id; + tunnat_link_id_t link_id = (tunnat_link_id_t)(-1); /* 未找到Link-ID */ - if(link_info_table->LookupLinkID(tun_array, link_id) < 0) + if(link_info_table->LookupLinkID(tun_array, link_id) == -ENOENT) { link_info_table->AddTunnel(tun_array, link_id); } + /* 失败,直接返回 */ + else + { + return; + } auto * ctrlzone = static_cast<mr_tunnat_ctrlzone *>(marsio_buff_ctrlzone(mbuf, g_ctrlzone_id)); ctrlzone->virtual_link_id = link_id; diff --git a/tunnat/src/session.cc b/tunnat/src/session.cc index bdf2108..3047735 100644 --- a/tunnat/src/session.cc +++ b/tunnat/src/session.cc @@ -235,10 +235,19 @@ int LinkInfoTable::LookupLinkID(const TunnelContainerArray &tun_array, tunnat_li char tun_array_hash_key[TUN_ARRAY_HASH_KEY_SIZE]; size_t sz_tun_array_hash_key = tun_array.LinkTunnelToHashKey(tun_array_hash_key, sizeof(tun_array_hash_key)); + if(sz_tun_array_hash_key <= 0) + { + return -EINVAL; + } + auto * result = (IndexTunnelTableEntry *)MESA_htable_search(tb_tunnel_index_by_tunnel, (const uchar *)tun_array_hash_key, (uint)sz_tun_array_hash_key); - if(!result) return -ENOENT; + if(!result) + { + return -ENOENT; + } + out_tunnat_link_id = result->link_id; /* 再次查询Store表,避免表项由于长时间仅在Index表查询而未在Store表查询引起Store的超时淘汰 */ |
