From 78d60bc1386034da94b57b4185ea9b2740df9373 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Mon, 30 Aug 2021 14:51:56 +0200 Subject: [PATCH] nas: remove all uses of atomic from 4G and 5G classes the NAS classes aren't thread safe and thread-safety shouldn't be pretended by using atomics. Remove them and add explicit notice. --- srsue/hdr/stack/upper/nas.h | 7 +++++++ srsue/hdr/stack/upper/nas_5g.h | 6 ++++++ srsue/hdr/stack/upper/nas_5gmm_state.h | 6 +++--- srsue/hdr/stack/upper/nas_emm_state.h | 9 ++++----- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/srsue/hdr/stack/upper/nas.h b/srsue/hdr/stack/upper/nas.h index bfb4d2a6a..d919a6050 100644 --- a/srsue/hdr/stack/upper/nas.h +++ b/srsue/hdr/stack/upper/nas.h @@ -35,6 +35,13 @@ class usim_interface_nas; class gw_interface_nas; class rrc_interface_nas; +/** + * @brief This class implements the NAS layer of a EUTRA UE. + * + * The class is *NOT* thread-safe. + * + */ + class nas : public nas_interface_rrc, public srsran::timer_callback, public nas_base { public: diff --git a/srsue/hdr/stack/upper/nas_5g.h b/srsue/hdr/stack/upper/nas_5g.h index fc13ede48..0695aaf17 100644 --- a/srsue/hdr/stack/upper/nas_5g.h +++ b/srsue/hdr/stack/upper/nas_5g.h @@ -33,6 +33,12 @@ using srsran::byte_buffer_t; namespace srsue { +/** + * @brief This class implements the NAS layer of a 5G UE. + * + * The class is *NOT* thread-safe. + * + */ class nas_5g : public nas_base, public nas_5g_interface_rrc_nr, public nas_5g_interface_procedures { public: diff --git a/srsue/hdr/stack/upper/nas_5gmm_state.h b/srsue/hdr/stack/upper/nas_5gmm_state.h index 28c5efdbd..b28280b61 100644 --- a/srsue/hdr/stack/upper/nas_5gmm_state.h +++ b/srsue/hdr/stack/upper/nas_5gmm_state.h @@ -74,9 +74,9 @@ public: const std::string get_full_state_text(); private: - std::atomic state{state_t::null}; - std::atomic deregistered_substate{deregistered_substate_t::null}; - std::atomic registered_substate{registered_substate_t::null}; + state_t state = state_t::null; + deregistered_substate_t deregistered_substate = deregistered_substate_t::null; + registered_substate_t registered_substate = registered_substate_t::null; srslog::basic_logger& logger = srslog::fetch_basic_logger("NAS-5G"); }; diff --git a/srsue/hdr/stack/upper/nas_emm_state.h b/srsue/hdr/stack/upper/nas_emm_state.h index e541d10d2..ebb44ee19 100644 --- a/srsue/hdr/stack/upper/nas_emm_state.h +++ b/srsue/hdr/stack/upper/nas_emm_state.h @@ -14,7 +14,6 @@ #define SRSUE_NAS_EMM_STATE_H #include "srsran/srslog/srslog.h" -#include #include namespace srsue { @@ -77,10 +76,10 @@ public: const std::string get_full_state_text(); private: - std::atomic state{state_t::null}; // The GW might require to know the NAS state from another thread - std::atomic deregistered_substate{deregistered_substate_t::null}; - std::atomic registered_substate{registered_substate_t::null}; - srslog::basic_logger& logger = srslog::fetch_basic_logger("NAS"); + state_t state = state_t::null; + deregistered_substate_t deregistered_substate = deregistered_substate_t::null; + registered_substate_t registered_substate = registered_substate_t::null; + srslog::basic_logger& logger = srslog::fetch_basic_logger("NAS"); }; const char* emm_state_text(emm_state_t::state_t type);