WIP: fixing collision in the the users_map

Signed-off-by: Carlo Galiotto <carlo@srs.io>
master
Carlo Galiotto 3 years ago committed by Andre Puschmann
parent c096270fc7
commit 284207dad6

@ -18,6 +18,7 @@
#include "srsran/common/rwlock_guard.h" #include "srsran/common/rwlock_guard.h"
#include "srsran/srslog/srslog.h" #include "srsran/srslog/srslog.h"
#include <map> #include <map>
#include <unordered_map>
#include <stdint.h> #include <stdint.h>
namespace srsran { namespace srsran {
@ -150,7 +151,7 @@ public:
private: private:
srslog::basic_logger& logger; srslog::basic_logger& logger;
srsenb::rnti_map_t<srsran::detail::ue_bearer_manager_impl> users_map; std::unordered_map<uint16_t, srsran::detail::ue_bearer_manager_impl> users_map;
}; };
} // namespace srsenb } // namespace srsenb

@ -118,12 +118,13 @@ void enb_bearer_manager::add_eps_bearer(uint16_t rnti, uint8_t eps_bearer_id, sr
auto user_it = users_map.find(rnti); auto user_it = users_map.find(rnti);
if (user_it == users_map.end()) { if (user_it == users_map.end()) {
// add empty bearer map // add empty bearer map
auto p = users_map.insert(rnti, srsran::detail::ue_bearer_manager_impl{}); // users_map.emplace( ) returns pair<iterator,bool>
if (!p) { auto p = users_map.emplace( rnti, srsran::detail::ue_bearer_manager_impl{});
if (!p.second) {
logger.error("Bearers: Unable to add a new bearer map for rnti=0x%x", rnti); logger.error("Bearers: Unable to add a new bearer map for rnti=0x%x", rnti);
return; return;
} }
user_it = p.value(); user_it = p.first;
} }
if (user_it->second.add_eps_bearer(eps_bearer_id, rat, lcid)) { if (user_it->second.add_eps_bearer(eps_bearer_id, rat, lcid)) {

@ -11,6 +11,7 @@
*/ */
#include <map> #include <map>
#include <unordered_map>
#include <string.h> #include <string.h>
#include "srsenb/hdr/common/common_enb.h" #include "srsenb/hdr/common/common_enb.h"
@ -122,7 +123,8 @@ private:
pdcp_interface_gtpu* pdcp = nullptr; pdcp_interface_gtpu* pdcp = nullptr;
srslog::basic_logger& logger; srslog::basic_logger& logger;
rnti_map_t<ue_bearer_tunnel_list> ue_teidin_db; std::unordered_map<uint16_t, ue_bearer_tunnel_list> ue_teidin_db;
rnti_map_t<ue_bearer_tunnel_list> ue_teidin_db_1;
tunnel_list_t tunnels; tunnel_list_t tunnels;
}; };

@ -50,10 +50,8 @@ const gtpu_tunnel_manager::tunnel* gtpu_tunnel_manager::find_tunnel(uint32_t tei
gtpu_tunnel_manager::ue_bearer_tunnel_list* gtpu_tunnel_manager::find_rnti_tunnels(uint16_t rnti) gtpu_tunnel_manager::ue_bearer_tunnel_list* gtpu_tunnel_manager::find_rnti_tunnels(uint16_t rnti)
{ {
if (not ue_teidin_db.contains(rnti)) { auto it = ue_teidin_db.find(rnti);
return nullptr; return it != ue_teidin_db.end() ? &ue_teidin_db[rnti] : nullptr;
}
return &ue_teidin_db[rnti];
} }
srsran::span<gtpu_tunnel_manager::bearer_teid_pair> srsran::span<gtpu_tunnel_manager::bearer_teid_pair>
@ -92,12 +90,18 @@ gtpu_tunnel_manager::add_tunnel(uint16_t rnti, uint32_t eps_bearer_id, uint32_t
tun->teid_out = teidout; tun->teid_out = teidout;
tun->spgw_addr = spgw_addr; tun->spgw_addr = spgw_addr;
if (not ue_teidin_db.contains(rnti)) { if (ue_teidin_db.find(rnti) != ue_teidin_db.end()) {
auto ret = ue_teidin_db.insert(rnti, ue_bearer_tunnel_list()); auto ret = ue_teidin_db.emplace(rnti, ue_bearer_tunnel_list());
if (!ret.second) {
logger.error("Failed to allocate rnti=0x%x", rnti);
return nullptr;
}
#if 0
if (ret.is_error()) { if (ret.is_error()) {
logger.error("Failed to allocate rnti=0x%x", rnti); logger.error("Failed to allocate rnti=0x%x", rnti);
return nullptr; return nullptr;
} }
#endif
} }
auto& ue_tunnels = ue_teidin_db[rnti]; auto& ue_tunnels = ue_teidin_db[rnti];
@ -133,7 +137,7 @@ bool gtpu_tunnel_manager::update_rnti(uint16_t old_rnti, uint16_t new_rnti)
logger.info("Modifying bearer rnti. Old rnti: 0x%x, new rnti: 0x%x", old_rnti, new_rnti); logger.info("Modifying bearer rnti. Old rnti: 0x%x, new rnti: 0x%x", old_rnti, new_rnti);
// create new RNTI and update TEIDs of old rnti to reflect new rnti // create new RNTI and update TEIDs of old rnti to reflect new rnti
if (new_rnti_ptr == nullptr and not ue_teidin_db.insert(new_rnti, ue_bearer_tunnel_list())) { if (new_rnti_ptr == nullptr and not ue_teidin_db.insert({new_rnti, ue_bearer_tunnel_list()}).second) {
logger.error("Failure to create new rnti=0x%x", new_rnti); logger.error("Failure to create new rnti=0x%x", new_rnti);
return false; return false;
} }
@ -186,7 +190,8 @@ bool gtpu_tunnel_manager::remove_tunnel(uint32_t teidin)
bool gtpu_tunnel_manager::remove_rnti(uint16_t rnti) bool gtpu_tunnel_manager::remove_rnti(uint16_t rnti)
{ {
if (not ue_teidin_db.contains(rnti)) { auto it = ue_teidin_db.find(rnti);
if (it == ue_teidin_db.end()) {
logger.warning("Removing rnti. rnti=0x%x not found.", rnti); logger.warning("Removing rnti. rnti=0x%x not found.", rnti);
return false; return false;
} }

Loading…
Cancel
Save