diff options
| author | Qiuwen Lu <[email protected]> | 2020-06-17 13:47:51 +0800 |
|---|---|---|
| committer | Qiuwen Lu <[email protected]> | 2020-06-17 13:47:51 +0800 |
| commit | 84e98ad78bf64042dba3a16f08acc7438807432c (patch) | |
| tree | 221b0854744eff530849a10ae4105ca83cd4c384 | |
| parent | 5ef8dc166bcb20e6dee6d77362ee7e2e6665b34e (diff) | |
修正VlanFlipping模式下LinkInfo方向输出错误,控制域中方向未填写的问题。
* 原实现没有填写VlanFlipping类内的方向参数,导致LinkInfo输出错误;
* 现修正,填写了相关参数,实现了在控制域中填写方向的功能。
| -rw-r--r-- | tunnat/include/tunnel.h | 6 | ||||
| -rw-r--r-- | tunnat/src/runtime.cc | 22 | ||||
| -rw-r--r-- | tunnat/src/tunnel.cc | 15 |
3 files changed, 27 insertions, 16 deletions
diff --git a/tunnat/include/tunnel.h b/tunnat/include/tunnel.h index 1ee796a..2456ec1 100644 --- a/tunnat/include/tunnel.h +++ b/tunnat/include/tunnel.h @@ -199,10 +199,10 @@ public: void MbufMetaPreParse(marsio_buff_t * mbuf) override; void MbufMetaConstruct(marsio_buff_t * mbuf) override; - size_t ToHashKey(char * out_hashkey, size_t sz_hash_key) const override { return 0; } + size_t ToHashKey(char * out_hashkey, size_t sz_hash_key) const override; cJSON * ToJSON() const override; - - bool operator==(const TunVlanFlipping & rhs); + int GetAddressInfo(struct AddressInfo & info) override; + bool operator==(const TunVlanFlipping & rhs) const; public: static int PacketForwardModify(const char * pkt, unsigned int pkt_len); diff --git a/tunnat/src/runtime.cc b/tunnat/src/runtime.cc index 9143cf1..d91c773 100644 --- a/tunnat/src/runtime.cc +++ b/tunnat/src/runtime.cc @@ -101,15 +101,14 @@ 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)(-1); + tunnat_link_id_t link_id; + int ret = link_info_table->LookupLinkID(tun_array, link_id); - /* 未找到Link-ID */ - if(link_info_table->LookupLinkID(tun_array, link_id) == -ENOENT) + if(ret == -ENOENT) { link_info_table->AddTunnel(tun_array, link_id); } - /* 失败,直接返回 */ - else + else if(ret < 0) { return; } @@ -222,18 +221,13 @@ static void __phy_to_virt_pkt_fill_addressinfo(TunnatInstance * instance, switch(instance->ctrlzone_addr_info_type) { case MR_TUNNAT_CTRLZONE_ADDR_INFO_TUNNEL: - tunnel = tun_array.GetTunContainerWithType(TUNNEL_TYPE_G_VXLAN); break; + tunnel = &tun_array.GetOuterTunContainer(); break; case MR_TUNNAT_CTRLZONE_ADDR_INFO_REAL: tunnel = tun_array.GetTunContainerWithType(TUNNEL_TYPE_ETHER); break; default:return; } - if (unlikely(tunnel == nullptr)) - { - return; - } - - if (unlikely(tunnel->GetAddressInfo(addrinfo) < 0)) + if (unlikely(tunnel == nullptr || tunnel->GetAddressInfo(addrinfo))) { return; } @@ -252,6 +246,10 @@ static void __phy_to_virt_pkt_fill_addressinfo(TunnatInstance * instance, ctrlzone->g_device_linkpair = addrinfo.tun_link_id; ctrlzone->route_dir = addrinfo.dir; } + else if(tunnel->ThisTunType() == TUNNEL_TYPE_VLAN_FLIPPING) + { + ctrlzone->route_dir = addrinfo.dir; + } } diff --git a/tunnat/src/tunnel.cc b/tunnat/src/tunnel.cc index e843631..5d4fd16 100644 --- a/tunnat/src/tunnel.cc +++ b/tunnat/src/tunnel.cc @@ -489,14 +489,27 @@ bool TunVlanFlipping::flipping_map_lookup(uint16_t le_vlan_id, uint16_t & vlan_i vlan_id_out = result; en_mac_flipping = instance->mac_flipping[le_vlan_id]; + is_c_router = instance->vlan_flipping_map_is_c_router[le_vlan_id]; return true; } -bool TunVlanFlipping::operator==(const TunVlanFlipping & rhs) +bool TunVlanFlipping::operator==(const TunVlanFlipping & rhs) const { return vlan_id_ == rhs.vlan_id_ && vlan_id_map_ == rhs.vlan_id_map_; } +size_t TunVlanFlipping::ToHashKey(char * out_hashkey, size_t sz_hash_key) const +{ + *(uint16_t *)out_hashkey = vlan_id_; + return sizeof(uint16_t); +} + +int TunVlanFlipping::GetAddressInfo(AddressInfo & info) +{ + info.dir = is_c_router_ ? ADDRESS_INFO_C_TO_I : ADDRESS_INFO_I_TO_C; + return RT_SUCCESS; +} + cJSON * TunVlanFlipping::ToJSON() const { cJSON * j_object = cJSON_CreateObject(); |
