From 299d2ee35d431b2dbf335ad3d379dfc2d9ca4ba4 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Mon, 17 May 2021 12:06:53 +0100 Subject: [PATCH] Added interface to make the PDCP notify the RRC of integrity check failures. --- lib/include/srsran/interfaces/enb_rrc_interfaces.h | 1 + lib/include/srsran/interfaces/gnb_interfaces.h | 1 + lib/include/srsran/interfaces/ue_rrc_interfaces.h | 1 + lib/src/upper/pdcp_entity_lte.cc | 7 +++++-- lib/test/upper/pdcp_base_test.h | 1 + srsenb/hdr/stack/rrc/rrc.h | 1 + srsenb/hdr/stack/rrc/rrc_nr.h | 4 +++- srsenb/hdr/stack/upper/pdcp.h | 1 + srsenb/hdr/stack/upper/pdcp_nr.h | 1 + srsenb/src/stack/rrc/rrc.cc | 5 +++++ srsenb/src/stack/rrc/rrc_nr.cc | 2 ++ srsenb/src/stack/upper/pdcp.cc | 5 +++++ srsue/hdr/stack/rrc/rrc.h | 1 + srsue/hdr/stack/rrc/rrc_nr.h | 7 ++++--- srsue/src/stack/rrc/rrc.cc | 5 +++++ srsue/src/stack/rrc/rrc_nr.cc | 1 + srsue/test/ttcn3/hdr/ttcn3_syssim.h | 1 + srsue/test/ttcn3/src/ttcn3_syssim.cc | 5 +++++ srsue/test/upper/nas_test.cc | 1 + 19 files changed, 45 insertions(+), 6 deletions(-) diff --git a/lib/include/srsran/interfaces/enb_rrc_interfaces.h b/lib/include/srsran/interfaces/enb_rrc_interfaces.h index 961bd1a50..092c36316 100644 --- a/lib/include/srsran/interfaces/enb_rrc_interfaces.h +++ b/lib/include/srsran/interfaces/enb_rrc_interfaces.h @@ -117,6 +117,7 @@ class rrc_interface_pdcp { public: virtual void write_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t pdu) = 0; + virtual void notify_pdcp_integrity_error(uint16_t rnti, uint32_t lcid) = 0; }; } // namespace srsenb diff --git a/lib/include/srsran/interfaces/gnb_interfaces.h b/lib/include/srsran/interfaces/gnb_interfaces.h index 50a3a5f0d..91eae09c4 100644 --- a/lib/include/srsran/interfaces/gnb_interfaces.h +++ b/lib/include/srsran/interfaces/gnb_interfaces.h @@ -159,6 +159,7 @@ class rrc_interface_pdcp_nr { public: virtual void write_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t pdu) = 0; + virtual void notify_pdcp_integrity_error(uint16_t rnti, uint32_t lcid) = 0; }; class phy_interface_stack_nr diff --git a/lib/include/srsran/interfaces/ue_rrc_interfaces.h b/lib/include/srsran/interfaces/ue_rrc_interfaces.h index 7b40ab483..f26d98ae4 100644 --- a/lib/include/srsran/interfaces/ue_rrc_interfaces.h +++ b/lib/include/srsran/interfaces/ue_rrc_interfaces.h @@ -84,6 +84,7 @@ public: virtual void write_pdu_bcch_dlsch(srsran::unique_byte_buffer_t pdu) = 0; virtual void write_pdu_pcch(srsran::unique_byte_buffer_t pdu) = 0; virtual void write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t pdu) = 0; + virtual void notify_pdcp_integrity_error(uint32_t lcid) = 0; virtual const char* get_rb_name(uint32_t lcid) = 0; }; diff --git a/lib/src/upper/pdcp_entity_lte.cc b/lib/src/upper/pdcp_entity_lte.cc index 38273101c..03c671622 100644 --- a/lib/src/upper/pdcp_entity_lte.cc +++ b/lib/src/upper/pdcp_entity_lte.cc @@ -301,8 +301,10 @@ void pdcp_entity_lte::handle_srb_pdu(srsran::unique_byte_buffer_t pdu) // Perfrom integrity checks if (integrity_direction == DIRECTION_RX || integrity_direction == DIRECTION_TXRX) { - if (not integrity_verify(pdu->msg, pdu->N_bytes, count, mac)) { + bool pdu_valid = integrity_verify(pdu->msg, pdu->N_bytes, count, mac); + if (not pdu_valid) { logger.error(pdu->msg, pdu->N_bytes, "%s Dropping PDU", rrc->get_rb_name(lcid)); + rrc->notify_pdcp_integrity_error(lcid); return; // Discard } } @@ -763,7 +765,8 @@ void pdcp_entity_lte::notify_failure(const pdcp_sn_vector_t& pdcp_sns) ***************************************************************************/ bool pdcp_entity_lte::check_valid_config() { - if (cfg.sn_len != PDCP_SN_LEN_5 && cfg.sn_len != PDCP_SN_LEN_7 && cfg.sn_len != PDCP_SN_LEN_12 && cfg.sn_len != PDCP_SN_LEN_18) { + if (cfg.sn_len != PDCP_SN_LEN_5 && cfg.sn_len != PDCP_SN_LEN_7 && cfg.sn_len != PDCP_SN_LEN_12 && + cfg.sn_len != PDCP_SN_LEN_18) { logger.error("Trying to configure bearer with invalid SN LEN=%d", cfg.sn_len); return false; } diff --git a/lib/test/upper/pdcp_base_test.h b/lib/test/upper/pdcp_base_test.h index 3daf26dd9..19c1a86bb 100644 --- a/lib/test/upper/pdcp_base_test.h +++ b/lib/test/upper/pdcp_base_test.h @@ -75,6 +75,7 @@ public: void write_pdu_bcch_dlsch(srsran::unique_byte_buffer_t pdu) {} void write_pdu_pcch(srsran::unique_byte_buffer_t pdu) {} void write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t pdu) {} + void notify_pdcp_integrity_error(uint32_t lcid) {} const char* get_rb_name(uint32_t lcid) { return "None"; } diff --git a/srsenb/hdr/stack/rrc/rrc.h b/srsenb/hdr/stack/rrc/rrc.h index 5b559482b..56994573b 100644 --- a/srsenb/hdr/stack/rrc/rrc.h +++ b/srsenb/hdr/stack/rrc/rrc.h @@ -117,6 +117,7 @@ public: // rrc_interface_pdcp void write_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t pdu) override; + void notify_pdcp_integrity_error(uint16_t rnti, uint32_t lcid) override; uint32_t get_nof_users(); diff --git a/srsenb/hdr/stack/rrc/rrc_nr.h b/srsenb/hdr/stack/rrc/rrc_nr.h index 70eebdecd..b36ff70c0 100644 --- a/srsenb/hdr/stack/rrc/rrc_nr.h +++ b/srsenb/hdr/stack/rrc/rrc_nr.h @@ -90,8 +90,10 @@ public: void max_retx_attempted(uint16_t rnti) {} void protocol_failure(uint16_t rnti) {} const char* get_rb_name(uint32_t lcid) { return "invalid"; } + // PDCP interface void write_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t pdu) final; + void notify_pdcp_integrity_error(uint16_t rnti, uint32_t lcid) final; class ue { @@ -155,4 +157,4 @@ private: } // namespace srsenb -#endif // SRSENB_RRC_NR_H \ No newline at end of file +#endif // SRSENB_RRC_NR_H diff --git a/srsenb/hdr/stack/upper/pdcp.h b/srsenb/hdr/stack/upper/pdcp.h index 2a896bb3a..4bc74f75d 100644 --- a/srsenb/hdr/stack/upper/pdcp.h +++ b/srsenb/hdr/stack/upper/pdcp.h @@ -99,6 +99,7 @@ private: void write_pdu_bcch_dlsch(srsran::unique_byte_buffer_t pdu); void write_pdu_pcch(srsran::unique_byte_buffer_t pdu); void write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t pdu) {} + void notify_pdcp_integrity_error(uint32_t lcid); const char* get_rb_name(uint32_t lcid); }; diff --git a/srsenb/hdr/stack/upper/pdcp_nr.h b/srsenb/hdr/stack/upper/pdcp_nr.h index 32e12c1fe..3ea7b676d 100644 --- a/srsenb/hdr/stack/upper/pdcp_nr.h +++ b/srsenb/hdr/stack/upper/pdcp_nr.h @@ -87,6 +87,7 @@ private: void write_pdu_bcch_dlsch(srsran::unique_byte_buffer_t pdu) final; void write_pdu_pcch(srsran::unique_byte_buffer_t pdu) final; void write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t pdu) final {} + void notify_pdcp_integrity_error(uint32_t lcid) final {} const char* get_rb_name(uint32_t lcid) final; }; diff --git a/srsenb/src/stack/rrc/rrc.cc b/srsenb/src/stack/rrc/rrc.cc index 3d6992eb1..738e964e3 100644 --- a/srsenb/src/stack/rrc/rrc.cc +++ b/srsenb/src/stack/rrc/rrc.cc @@ -290,6 +290,11 @@ void rrc::write_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t p } } +void rrc::notify_pdcp_integrity_error(uint16_t rnti, uint32_t lcid) +{ + logger.warning("Received Integrity Protection failured indication, rnti=0x%u, lcid=%u", rnti, lcid); +} + /******************************************************************************* S1AP interface *******************************************************************************/ diff --git a/srsenb/src/stack/rrc/rrc_nr.cc b/srsenb/src/stack/rrc/rrc_nr.cc index e8b107603..143edd1a4 100644 --- a/srsenb/src/stack/rrc/rrc_nr.cc +++ b/srsenb/src/stack/rrc/rrc_nr.cc @@ -344,6 +344,8 @@ void rrc_nr::write_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_ handle_pdu(rnti, lcid, std::move(pdu)); } +void rrc_nr::notify_pdcp_integrity_error(uint16_t rnti, uint32_t lcid) {} + /******************************************************************************* UE class diff --git a/srsenb/src/stack/upper/pdcp.cc b/srsenb/src/stack/upper/pdcp.cc index 697679c81..7bf37ba12 100644 --- a/srsenb/src/stack/upper/pdcp.cc +++ b/srsenb/src/stack/upper/pdcp.cc @@ -220,6 +220,11 @@ void pdcp::user_interface_rrc::write_pdu(uint32_t lcid, srsran::unique_byte_buff rrc->write_pdu(rnti, lcid, std::move(pdu)); } +void pdcp::user_interface_rrc::notify_pdcp_integrity_error(uint32_t lcid) +{ + rrc->notify_pdcp_integrity_error(rnti, lcid); +} + void pdcp::user_interface_rrc::write_pdu_bcch_bch(srsran::unique_byte_buffer_t pdu) { ERROR("Error: Received BCCH from ue=%d", rnti); diff --git a/srsue/hdr/stack/rrc/rrc.h b/srsue/hdr/stack/rrc/rrc.h index 3125eaf2f..abe9910c3 100644 --- a/srsue/hdr/stack/rrc/rrc.h +++ b/srsue/hdr/stack/rrc/rrc.h @@ -147,6 +147,7 @@ public: void write_pdu_bcch_dlsch(srsran::unique_byte_buffer_t pdu); void write_pdu_pcch(srsran::unique_byte_buffer_t pdu); void write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t pdu); + void notify_pdcp_integrity_error(uint32_t lcid); bool srbs_flushed(); //< Check if data on SRBs still needs to be sent diff --git a/srsue/hdr/stack/rrc/rrc_nr.h b/srsue/hdr/stack/rrc/rrc_nr.h index 80aee18b8..6cd4db138 100644 --- a/srsue/hdr/stack/rrc/rrc_nr.h +++ b/srsue/hdr/stack/rrc/rrc_nr.h @@ -16,12 +16,12 @@ #include "srsran/asn1/rrc_nr.h" #include "srsran/asn1/rrc_nr_utils.h" #include "srsran/common/block_queue.h" -#include "srsran/common/common_nr.h" #include "srsran/common/buffer_pool.h" +#include "srsran/common/common_nr.h" #include "srsran/common/stack_procedure.h" #include "srsran/common/task_scheduler.h" -#include "srsran/interfaces/ue_rrc_interfaces.h" #include "srsran/interfaces/ue_nr_interfaces.h" +#include "srsran/interfaces/ue_rrc_interfaces.h" #include "srsue/hdr/stack/upper/gw.h" namespace srsue { @@ -115,6 +115,7 @@ public: void write_pdu_bcch_dlsch(srsran::unique_byte_buffer_t pdu) final; void write_pdu_pcch(srsran::unique_byte_buffer_t pdu) final; void write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t pdu) final; + void notify_pdcp_integrity_error(uint32_t lcid) final; // RRC (LTE) interface void get_eutra_nr_capabilities(srsran::byte_buffer_t* eutra_nr_caps); @@ -246,4 +247,4 @@ private: } // namespace srsue -#endif // SRSUE_RRC_NR_H \ No newline at end of file +#endif // SRSUE_RRC_NR_H diff --git a/srsue/src/stack/rrc/rrc.cc b/srsue/src/stack/rrc/rrc.cc index eca1a141f..e919ba66f 100644 --- a/srsue/src/stack/rrc/rrc.cc +++ b/srsue/src/stack/rrc/rrc.cc @@ -1620,6 +1620,11 @@ void rrc::write_pdu(uint32_t lcid, unique_byte_buffer_t pdu) process_pdu(lcid, std::move(pdu)); } +void rrc::notify_pdcp_integrity_error(uint32_t lcid) +{ + logger.warning("Received Integrity Protection failured indication, rnti=0x%u, lcid=%u", lcid); +} + void rrc::process_pdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu) { logger.debug("RX PDU, LCID: %d", lcid); diff --git a/srsue/src/stack/rrc/rrc_nr.cc b/srsue/src/stack/rrc/rrc_nr.cc index 7d0236aa2..ad9ddebba 100644 --- a/srsue/src/stack/rrc/rrc_nr.cc +++ b/srsue/src/stack/rrc/rrc_nr.cc @@ -206,6 +206,7 @@ void rrc_nr::write_pdu_bcch_bch(srsran::unique_byte_buffer_t pdu) {} void rrc_nr::write_pdu_bcch_dlsch(srsran::unique_byte_buffer_t pdu) {} void rrc_nr::write_pdu_pcch(srsran::unique_byte_buffer_t pdu) {} void rrc_nr::write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t pdu) {} +void rrc_nr::notify_pdcp_integrity_error(uint32_t lcid) {} void rrc_nr::get_eutra_nr_capabilities(srsran::byte_buffer_t* eutra_nr_caps_pdu) { diff --git a/srsue/test/ttcn3/hdr/ttcn3_syssim.h b/srsue/test/ttcn3/hdr/ttcn3_syssim.h index ffcfec54f..7de69a831 100644 --- a/srsue/test/ttcn3/hdr/ttcn3_syssim.h +++ b/srsue/test/ttcn3/hdr/ttcn3_syssim.h @@ -150,6 +150,7 @@ public: // RRC interface for PDCP, PDCP calls RRC to push RRC SDU void write_pdu(uint32_t lcid, unique_byte_buffer_t pdu); + void notify_pdcp_integrity_error(uint32_t lcid); // Not supported right now void write_pdu_bcch_bch(unique_byte_buffer_t pdu); diff --git a/srsue/test/ttcn3/src/ttcn3_syssim.cc b/srsue/test/ttcn3/src/ttcn3_syssim.cc index 6ee227cba..5c9b81d50 100644 --- a/srsue/test/ttcn3/src/ttcn3_syssim.cc +++ b/srsue/test/ttcn3/src/ttcn3_syssim.cc @@ -1139,6 +1139,11 @@ void ttcn3_syssim::protocol_failure() logger.error("%s not implemented.", __FUNCTION__); } +void ttcn3_syssim::notify_pdcp_integrity_error(uint32_t lcid) +{ + logger.error("%s not implemented.", __FUNCTION__); +} + const char* ttcn3_syssim::get_rb_name(uint32_t lcid) { if (lcid < rb_id_vec.size()) { diff --git a/srsue/test/upper/nas_test.cc b/srsue/test/upper/nas_test.cc index 845690bc1..0769167af 100644 --- a/srsue/test/upper/nas_test.cc +++ b/srsue/test/upper/nas_test.cc @@ -74,6 +74,7 @@ public: const char* get_rb_name(uint32_t lcid) { return "lcid"; } void write_sdu(uint32_t lcid, srsran::unique_byte_buffer_t sdu) {} bool is_lcid_enabled(uint32_t lcid) { return false; } + void notify_pdcp_integrity_error(uint32_t lcid) {} }; class rrc_dummy : public rrc_interface_nas