From dde8157bf1a5b1e86a4b57a7dc9464c775ac3d93 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Thu, 18 Mar 2021 15:25:06 +0000 Subject: [PATCH] Make sure that S1 Setup request is restarted regardless of which error made the procedure fail. --- lib/src/common/network_utils.cc | 9 +-------- srsenb/src/stack/upper/s1ap.cc | 17 +++++++++++------ 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/lib/src/common/network_utils.cc b/lib/src/common/network_utils.cc index e3f903de5..3356af1f9 100644 --- a/lib/src/common/network_utils.cc +++ b/lib/src/common/network_utils.cc @@ -474,14 +474,7 @@ public: bool ret = true; pdu->N_bytes = static_cast(n_recv); - if (flags & MSG_NOTIFICATION) { - // Received notification - union sctp_notification* notification = (union sctp_notification*)pdu->msg; - if (notification->sn_header.sn_type == SCTP_SHUTDOWN_EVENT) { - // Socket Shutdown - ret = false; - } - } + // SCTP notifications handled in callback. func(std::move(pdu), from, sri, flags); return ret; } diff --git a/srsenb/src/stack/upper/s1ap.cc b/srsenb/src/stack/upper/s1ap.cc index 695e565c0..9b5f296af 100644 --- a/srsenb/src/stack/upper/s1ap.cc +++ b/srsenb/src/stack/upper/s1ap.cc @@ -174,11 +174,7 @@ srslte::proc_outcome_t s1ap::s1_setup_proc_t::start_mme_connection() } if (not s1ap_ptr->connect_mme()) { - procInfo("Failed to initiate SCTP socket. Attempting reconnection in %d seconds", - s1ap_ptr->mme_connect_timer.duration() / 1000); - srslte::console("Failed to initiate SCTP socket. Attempting reconnection in %d seconds\n", - s1ap_ptr->mme_connect_timer.duration() / 1000); - s1ap_ptr->mme_connect_timer.run(); + procInfo("Could not connect to MME"); return srslte::proc_outcome_t::error; } @@ -203,7 +199,7 @@ srslte::proc_outcome_t s1ap::s1_setup_proc_t::react(const srsenb::s1ap::s1_setup procInfo("S1Setup procedure completed successfully"); return srslte::proc_outcome_t::success; } - procError("S1Setup failed. Exiting..."); + procError("S1Setup failed."); srslte::console("S1setup failed\n"); return srslte::proc_outcome_t::error; } @@ -211,8 +207,15 @@ srslte::proc_outcome_t s1ap::s1_setup_proc_t::react(const srsenb::s1ap::s1_setup void s1ap::s1_setup_proc_t::then(const srslte::proc_state_t& result) const { if (result.is_error()) { + procInfo("Failed to initiate S1 connection. Attempting reconnection in %d seconds", + s1ap_ptr->mme_connect_timer.duration() / 1000); + srslte::console("Failed to initiate S1 connection. Attempting reconnection in %d seconds\n", + s1ap_ptr->mme_connect_timer.duration() / 1000); + s1ap_ptr->mme_connect_timer.run(); + s1ap_ptr->stack->remove_mme_socket(s1ap_ptr->s1ap_socket.get_socket()); s1ap_ptr->s1ap_socket.reset(); procInfo("S1AP socket closed."); + // Try again with in 10 seconds } } @@ -429,11 +432,13 @@ bool s1ap::connect_mme() &s1ap_socket, srslte::net_utils::socket_type::seqpacket, args.s1c_bind_addr.c_str())) { return false; } + logger.info("SCTP socket opened. fd=%d", s1ap_socket.fd()); // Connect to the MME address if (not s1ap_socket.connect_to(args.mme_addr.c_str(), MME_PORT, &mme_addr)) { return false; } + logger.info("SCTP socket connected with MME. fd=%d", s1ap_socket.fd()); // Assign a handler to rx MME packets (going to run in a different thread) stack->add_mme_socket(s1ap_socket.fd());