gtpu: improve check for PDU session Id in NR SA

master
herlesupreeth 2 years ago committed by Justin Tallon
parent 751136f46a
commit b927936d52

@ -95,6 +95,14 @@ inline const char* get_drb_name(lte_drb drb_id)
return names[(uint32_t)(drb_id < lte_drb::invalid ? drb_id : lte_drb::invalid) - 1];
}
inline const char* get_rb_name(uint32_t lcid)
{
if (is_lte_srb(lcid)) {
return get_srb_name(static_cast<lte_srb>(lcid));
}
return get_drb_name(static_cast<lte_drb>(lcid - MAX_LTE_SRB_ID));
}
} // namespace srsran
#endif // SRSRAN_COMMON_LTE_H

@ -94,6 +94,15 @@ inline const char* get_drb_name(nr_drb drb_id)
"DRB25", "DRB26", "DRB27", "DRB28", "DRB29", "invalid DRB id"};
return names[(uint32_t)(drb_id < nr_drb::invalid ? drb_id : nr_drb::invalid) - 1];
}
inline const char* get_nr_rb_name(uint32_t lcid)
{
if (is_nr_srb(lcid)) {
return get_srb_name(static_cast<nr_srb>(lcid));
}
return get_drb_name(static_cast<nr_drb>(lcid - MAX_NR_SRB_ID));
}
} // namespace srsran
#endif // SRSRAN_COMMON_NR_H

@ -11,8 +11,8 @@
*/
#include <map>
#include <unordered_map>
#include <string.h>
#include <unordered_map>
#include "srsenb/hdr/common/common_enb.h"
#include "srsran/adt/bounded_vector.h"
@ -49,7 +49,7 @@ class gtpu_tunnel_manager
public:
// A UE should have <= 3 DRBs active, and each DRB should have two tunnels active at the same time at most
const static size_t MAX_TUNNELS_PER_UE = 10;
const static size_t MAX_TUNNELS_PER_UE = 32;
enum class tunnel_state { pdcp_active, buffering, forward_to, forwarded_from, inactive };
@ -66,8 +66,8 @@ public:
tunnel* fwd_tunnel = nullptr; ///< forward Rx SDUs to this TEID
srsran::move_callback<void()> on_removal;
tunnel() = default;
tunnel(tunnel&&) noexcept = default;
tunnel() = default;
tunnel(tunnel&&) noexcept = default;
tunnel& operator=(tunnel&&) noexcept = default;
~tunnel()
{
@ -92,7 +92,7 @@ public:
};
using ue_bearer_tunnel_list = srsran::bounded_vector<bearer_teid_pair, MAX_TUNNELS_PER_UE>;
explicit gtpu_tunnel_manager(srsran::task_sched_handle task_sched_, srslog::basic_logger& logger);
explicit gtpu_tunnel_manager(srsran::task_sched_handle task_sched_, srslog::basic_logger& logger, bool is_nr_);
void init(const gtpu_args_t& gtpu_args, pdcp_interface_gtpu* pdcp_);
bool has_teid(uint32_t teid) const { return tunnels.contains(teid); }
@ -118,13 +118,16 @@ private:
using tunnel_list_t = srsran::static_id_obj_pool<uint32_t, tunnel, SRSENB_MAX_UES * MAX_TUNNELS_PER_UE>;
using tunnel_ctxt_it = typename tunnel_list_t::iterator;
// Flag to indicate whether GTPU is used in NR or LTE context.
bool is_nr;
srsran::task_sched_handle task_sched;
const gtpu_args_t* gtpu_args = nullptr;
pdcp_interface_gtpu* pdcp = nullptr;
srslog::basic_logger& logger;
std::unordered_map<uint16_t, ue_bearer_tunnel_list> ue_teidin_db;
tunnel_list_t tunnels;
tunnel_list_t tunnels;
};
using gtpu_tunnel_state = gtpu_tunnel_manager::tunnel_state;
@ -135,6 +138,7 @@ class gtpu final : public gtpu_interface_rrc, public gtpu_interface_pdcp
public:
explicit gtpu(srsran::task_sched_handle task_sched_,
srslog::basic_logger& logger,
bool is_nr_,
srsran::socket_manager_itf* rx_socket_handler_);
~gtpu();
@ -168,6 +172,9 @@ private:
srsran::socket_manager_itf* rx_socket_handler = nullptr;
srsran::task_queue_handle gtpu_queue;
// Flag to indicate whether GTPU entity is used in NR or LTE context.
bool is_nr;
gtpu_args_t args;
std::string gtp_bind_addr;
std::string mme_addr;
@ -181,10 +188,10 @@ private:
public:
explicit m1u_handler(gtpu* gtpu_) : parent(gtpu_), logger(parent->logger) {}
~m1u_handler();
m1u_handler(const m1u_handler&) = delete;
m1u_handler(m1u_handler&&) = delete;
m1u_handler(const m1u_handler&) = delete;
m1u_handler(m1u_handler&&) = delete;
m1u_handler& operator=(const m1u_handler&) = delete;
m1u_handler& operator=(m1u_handler&&) = delete;
m1u_handler& operator=(m1u_handler&&) = delete;
bool init(std::string m1u_multiaddr_, std::string m1u_if_addr_);
void handle_rx_packet(srsran::unique_byte_buffer_t pdu, const sockaddr_in& addr);

@ -36,7 +36,7 @@ enb_stack_lte::enb_stack_lte(srslog::sink& log_sink) :
pdcp(&task_sched, pdcp_logger),
mac(&task_sched, mac_logger),
rlc(rlc_logger),
gtpu(&task_sched, gtpu_logger, &get_rx_io_manager()),
gtpu(&task_sched, gtpu_logger, false, &get_rx_io_manager()),
s1ap(&task_sched, s1ap_logger, &get_rx_io_manager()),
rrc(&task_sched, bearers),
mac_pcap(),

@ -12,6 +12,7 @@
#include "srsran/upper/gtpu.h"
#include "srsenb/hdr/stack/upper/gtpu.h"
#include "srsran/common/common_nr.h"
#include "srsran/common/network_utils.h"
#include "srsran/common/standard_streams.h"
#include "srsran/common/string_helpers.h"
@ -32,9 +33,12 @@ namespace srsenb {
#define TEID_IN_FMT "TEID In=0x%x"
#define TEID_OUT_FMT "TEID Out=0x%x"
gtpu_tunnel_manager::gtpu_tunnel_manager(srsran::task_sched_handle task_sched_, srslog::basic_logger& logger) :
logger(logger), task_sched(task_sched_), tunnels(1)
{}
gtpu_tunnel_manager::gtpu_tunnel_manager(srsran::task_sched_handle task_sched_,
srslog::basic_logger& logger,
bool is_nr_) :
logger(logger), is_nr(is_nr_), task_sched(task_sched_), tunnels(1)
{
}
void gtpu_tunnel_manager::init(const gtpu_args_t& args, pdcp_interface_gtpu* pdcp_)
{
@ -57,7 +61,7 @@ gtpu_tunnel_manager::ue_bearer_tunnel_list* gtpu_tunnel_manager::find_rnti_tunne
srsran::span<gtpu_tunnel_manager::bearer_teid_pair>
gtpu_tunnel_manager::find_rnti_bearer_tunnels(uint16_t rnti, uint32_t eps_bearer_id)
{
if (not is_eps_bearer_id(eps_bearer_id)) {
if ((not is_nr and not is_eps_bearer_id(eps_bearer_id)) or (is_nr and not is_nr_lcid(eps_bearer_id))) {
logger.warning("Searching for bearer with invalid eps-BearerID=%d", eps_bearer_id);
return {};
}
@ -74,7 +78,7 @@ gtpu_tunnel_manager::find_rnti_bearer_tunnels(uint16_t rnti, uint32_t eps_bearer
const gtpu_tunnel*
gtpu_tunnel_manager::add_tunnel(uint16_t rnti, uint32_t eps_bearer_id, uint32_t teidout, uint32_t spgw_addr)
{
if (not is_eps_bearer_id(eps_bearer_id)) {
if ((not is_nr and not is_eps_bearer_id(eps_bearer_id)) or (is_nr and not is_nr_lcid(eps_bearer_id))) {
logger.warning("Adding TEID with invalid eps-BearerID=%d", eps_bearer_id);
return nullptr;
}
@ -351,11 +355,14 @@ void gtpu_tunnel_manager::setup_forwarding(uint32_t rx_teid, uint32_t tx_teid)
gtpu::gtpu(srsran::task_sched_handle task_sched_,
srslog::basic_logger& logger,
bool is_nr_,
srsran::socket_manager_itf* rx_socket_handler_) :
m1u(this),
task_sched(task_sched_),
logger(logger),
tunnels(task_sched_, logger),
is_nr(is_nr_),
tunnels(task_sched_, logger, is_nr),
rx_socket_handler(rx_socket_handler_)
{
gtpu_queue = task_sched.make_task_queue();

@ -158,7 +158,7 @@ void test_gtpu_tunnel_manager()
srsran::task_scheduler task_sched;
gtpu_args_t gtpu_args = {};
gtpu_tunnel_manager tunnels(&task_sched, srslog::fetch_basic_logger("GTPU"));
gtpu_tunnel_manager tunnels(&task_sched, srslog::fetch_basic_logger("GTPU"), false);
tunnels.init(gtpu_args, nullptr);
TESTASSERT(tunnels.find_tunnel(0) == nullptr);
TESTASSERT(tunnels.find_rnti_bearer_tunnels(0x46, drb1_eps_bearer_id).empty());
@ -235,9 +235,10 @@ int test_gtpu_direct_tunneling(tunnel_test_event event)
logger2.set_hex_dump_max_size(2048);
srsran::task_scheduler task_sched;
dummy_socket_manager senb_rx_sockets, tenb_rx_sockets;
srsenb::gtpu senb_gtpu(&task_sched, logger1, &senb_rx_sockets), tenb_gtpu(&task_sched, logger2, &tenb_rx_sockets);
pdcp_tester senb_pdcp, tenb_pdcp;
gtpu_args_t gtpu_args;
srsenb::gtpu senb_gtpu(&task_sched, logger1, false, &senb_rx_sockets),
tenb_gtpu(&task_sched, logger2, false, &tenb_rx_sockets);
pdcp_tester senb_pdcp, tenb_pdcp;
gtpu_args_t gtpu_args;
gtpu_args.gtp_bind_addr = senb_addr_str;
gtpu_args.mme_addr = sgw_addr_str;
gtpu_args.indirect_tunnel_timeout_msec = std::uniform_int_distribution<uint32_t>{500, 2000}(g);
@ -263,7 +264,7 @@ int test_gtpu_direct_tunneling(tunnel_test_event event)
props.flush_before_teidin = tenb_teid_in;
uint32_t addr_in3;
uint32_t dl_tenb_teid_in = tenb_gtpu.add_bearer(rnti2, drb1_bearer_id, senb_addr, 0, addr_in3, &props).value();
props = {};
props = {};
props.forward_from_teidin_present = true;
props.forward_from_teidin = senb_teid_in;
uint32_t addr_in4;

@ -83,7 +83,7 @@ int gnb_stack_nr::init(const gnb_stack_args_t& args_,
if (x2_ == nullptr) {
// SA mode
ngap.reset(new srsenb::ngap(&task_sched, ngap_logger, &srsran::get_rx_io_manager()));
gtpu.reset(new srsenb::gtpu(&task_sched, gtpu_logger, &srsran::get_rx_io_manager()));
gtpu.reset(new srsenb::gtpu(&task_sched, gtpu_logger, true, &srsran::get_rx_io_manager()));
gtpu_adapter.reset(new gtpu_pdcp_adapter(gtpu_logger, nullptr, &pdcp, gtpu.get(), *bearer_manager));
}

@ -137,7 +137,7 @@ void test_rrc_sa_ngap_integration(ngap_args_t ngap_args)
srsran::socket_manager rx_sockets;
srsenb::ngap ngap_obj(&task_sched, ngap_logger, &rx_sockets);
srsenb::gtpu gtpu_obj(&task_sched, gtpu_logger, &rx_sockets);
srsenb::gtpu gtpu_obj(&task_sched, gtpu_logger, true, &rx_sockets);
gtpu_args_t gtpu_args;
gtpu_args.embms_enable = false;

Loading…
Cancel
Save