s1ap - simplified erab modify procedure

master
Francisco 4 years ago committed by Francisco Paisana
parent 76978f0d14
commit f401683960

@ -30,13 +30,20 @@ public:
virtual bool setup_ue_ctxt(uint16_t rnti, const asn1::s1ap::init_context_setup_request_s& msg) = 0;
virtual bool modify_ue_ctxt(uint16_t rnti, const asn1::s1ap::ue_context_mod_request_s& msg) = 0;
virtual bool setup_ue_erabs(uint16_t rnti, const asn1::s1ap::erab_setup_request_s& msg) = 0;
virtual void
modify_erabs(uint16_t rnti,
srsran::const_span<const asn1::s1ap::erab_to_be_modified_item_bearer_mod_req_s*> erabs_to_modify) = 0;
virtual bool has_erab(uint16_t rnti, uint32_t erab_id) const = 0;
virtual bool release_erabs(uint32_t rnti) = 0;
/**
* TS 36.413, 8.2.2 - Modify E-RAB
* @return if error, cause argument is updated with cause
*/
virtual int modify_erab(uint16_t rnti,
uint16_t erab_id,
const asn1::s1ap::erab_level_qos_params_s& qos_params,
const asn1::unbounded_octstring<true>* nas_pdu,
asn1::s1ap::cause_c& cause) = 0;
/**
* Release E-RAB id
* TS 36.413, 8.2.3 - Release E-RAB id
* @return error if E-RAB id or rnti were not found
*/
virtual int release_erab(uint16_t rnti, uint16_t erab_id) = 0;

@ -29,5 +29,12 @@ uint32_t get_obj_id<protocol_ie_single_container_s<erab_to_be_setup_item_ctxt_su
return obj.value.erab_to_be_setup_item_ctxt_su_req().erab_id;
}
template <>
uint32_t get_obj_id<protocol_ie_single_container_s<erab_to_be_modified_item_bearer_mod_req_ies_o> >(
const protocol_ie_single_container_s<erab_to_be_modified_item_bearer_mod_req_ies_o>& obj)
{
return obj.value.erab_to_be_modified_item_bearer_mod_req().erab_id;
}
} // namespace s1ap
} // namespace asn1

@ -83,13 +83,11 @@ public:
bool modify_ue_ctxt(uint16_t rnti, const asn1::s1ap::ue_context_mod_request_s& msg) override;
bool setup_ue_erabs(uint16_t rnti, const asn1::s1ap::erab_setup_request_s& msg) override;
bool has_erab(uint16_t rnti, uint32_t erab_id) const override;
void modify_erabs(
uint16_t rnti,
srsran::const_span<const asn1::s1ap::erab_to_be_modified_item_bearer_mod_req_s*> erabs_to_modify) override;
bool modify_ue_erab(uint16_t rnti,
uint8_t erab_id,
int modify_erab(uint16_t rnti,
uint16_t erab_id,
const asn1::s1ap::erab_level_qos_params_s& qos_params,
const asn1::unbounded_octstring<true>* nas_pdu);
const asn1::unbounded_octstring<true>* nas_pdu,
asn1::s1ap::cause_c& cause) override;
bool release_erabs(uint32_t rnti) override;
int release_erab(uint16_t rnti, uint16_t erab_id) override;
void add_paging_id(uint32_t ueid, const asn1::s1ap::ue_paging_id_c& UEPagingID) override;

@ -87,9 +87,10 @@ public:
asn1::s1ap::cause_c& cause);
int release_erab(uint8_t erab_id);
void release_erabs();
bool modify_erab(uint8_t erab_id,
int modify_erab(uint8_t erab_id,
const asn1::s1ap::erab_level_qos_params_s& qos,
const asn1::unbounded_octstring<true>* nas_pdu);
const asn1::unbounded_octstring<true>* nas_pdu,
asn1::s1ap::cause_c& cause);
// Methods to apply bearer updates
int add_gtpu_bearer(uint32_t erab_id);

@ -114,9 +114,10 @@ public:
bool setup_erabs(const asn1::s1ap::erab_to_be_setup_list_bearer_su_req_l& e);
bool release_erabs();
int release_erab(uint32_t erab_id);
bool modify_erab(uint16_t erab_id,
int modify_erab(uint16_t erab_id,
const asn1::s1ap::erab_level_qos_params_s& qos_params,
const asn1::unbounded_octstring<true>* nas_pdu);
const asn1::unbounded_octstring<true>* nas_pdu,
asn1::s1ap::cause_c& cause);
void notify_s1ap_ue_ctxt_setup_complete();
void notify_s1ap_ue_erab_setup_response(const asn1::s1ap::erab_to_be_setup_list_bearer_su_req_l& e);

@ -163,8 +163,8 @@ private:
bool handle_uectxtreleasecommand(const asn1::s1ap::ue_context_release_cmd_s& msg);
bool handle_s1setupfailure(const asn1::s1ap::s1_setup_fail_s& msg);
bool handle_erabsetuprequest(const asn1::s1ap::erab_setup_request_s& msg);
bool handle_erabreleasecommand(const asn1::s1ap::erab_release_cmd_s& msg);
bool handle_erabmodifyrequest(const asn1::s1ap::erab_modify_request_s& msg);
bool handle_erabreleasecommand(const asn1::s1ap::erab_release_cmd_s& msg);
bool handle_uecontextmodifyrequest(const asn1::s1ap::ue_context_mod_request_s& msg);
// handover
@ -249,9 +249,8 @@ private:
bool send_erab_setup_response(const asn1::s1ap::erab_setup_resp_s& res_);
bool send_erab_release_response(srsran::const_span<uint16_t> erabs_released,
srsran::const_span<asn1::s1ap::erab_item_s> erabs_failed);
bool send_erab_modify_response(
srsran::const_span<const asn1::s1ap::erab_to_be_modified_item_bearer_mod_req_s*> erabs_modified,
srsran::const_span<std::pair<uint16_t, asn1::s1ap::cause_c> > erabs_failed_to_modify);
bool send_erab_modify_response(srsran::const_span<uint16_t> erabs_modified,
srsran::const_span<asn1::s1ap::erab_item_s> erabs_failed_to_modify);
bool send_erab_release_indication(const std::vector<uint16_t>& erabs_successfully_released);
bool send_ue_cap_info_indication(srsran::unique_byte_buffer_t ue_radio_cap);

@ -392,39 +392,21 @@ bool rrc::has_erab(uint16_t rnti, uint32_t erab_id) const
return user_it->second->has_erab(erab_id);
}
void rrc::modify_erabs(uint16_t rnti,
srsran::const_span<const asn1::s1ap::erab_to_be_modified_item_bearer_mod_req_s*> erabs_to_modify)
{
logger.info("Modifying E-RABs for 0x%x", rnti);
auto user_it = users.find(rnti);
if (user_it == users.end()) {
logger.warning("Unrecognised rnti: 0x%x", rnti);
return;
}
for (const auto* erab_ptr : erabs_to_modify) {
// Attempt to modify E-RAB
bool ret = modify_ue_erab(rnti, erab_ptr->erab_id, erab_ptr->erab_level_qos_params, &erab_ptr->nas_pdu);
srsran_expect(ret, "modify_erabs should not called for valid E-RAB Ids");
}
}
bool rrc::modify_ue_erab(uint16_t rnti,
uint8_t erab_id,
int rrc::modify_erab(uint16_t rnti,
uint16_t erab_id,
const asn1::s1ap::erab_level_qos_params_s& qos_params,
const asn1::unbounded_octstring<true>* nas_pdu)
const asn1::unbounded_octstring<true>* nas_pdu,
asn1::s1ap::cause_c& cause)
{
logger.info("Modifying E-RAB for 0x%x. E-RAB Id %d", rnti, erab_id);
auto user_it = users.find(rnti);
if (user_it == users.end()) {
logger.warning("Unrecognised rnti: 0x%x", rnti);
return false;
cause.set_radio_network().value = asn1::s1ap::cause_radio_network_opts::unknown_erab_id;
return SRSRAN_ERROR;
}
bool ret = user_it->second->modify_erab(erab_id, qos_params, nas_pdu);
return ret;
return user_it->second->modify_erab(erab_id, qos_params, nas_pdu, cause);
}
/*******************************************************************************

@ -317,21 +317,22 @@ void bearer_cfg_handler::release_erabs()
}
}
bool bearer_cfg_handler::modify_erab(uint8_t erab_id,
int bearer_cfg_handler::modify_erab(uint8_t erab_id,
const asn1::s1ap::erab_level_qos_params_s& qos,
const asn1::unbounded_octstring<true>* nas_pdu)
const asn1::unbounded_octstring<true>* nas_pdu,
asn1::s1ap::cause_c& cause)
{
logger->info("Modifying E-RAB %d", erab_id);
std::map<uint8_t, erab_t>::iterator erab_it = erabs.find(erab_id);
if (erab_it == erabs.end()) {
logger->error("Could not find E-RAB to modify");
return false;
cause.set_radio_network().value = asn1::s1ap::cause_radio_network_opts::unknown_erab_id;
return SRSRAN_ERROR;
}
auto address = erab_it->second.address;
uint32_t teid_out = erab_it->second.teid_out;
release_erab(erab_id);
asn1::s1ap::cause_c cause;
return add_erab(erab_id, qos, address, teid_out, nas_pdu, cause) == SRSRAN_SUCCESS;
return add_erab(erab_id, qos, address, teid_out, nas_pdu, cause);
}
int bearer_cfg_handler::add_gtpu_bearer(uint32_t erab_id)

@ -1055,15 +1055,12 @@ int rrc::ue::release_erab(uint32_t erab_id)
return bearer_list.release_erab(erab_id);
}
bool rrc::ue::modify_erab(uint16_t erab_id,
int rrc::ue::modify_erab(uint16_t erab_id,
const asn1::s1ap::erab_level_qos_params_s& qos_params,
const asn1::unbounded_octstring<true>* nas_pdu)
const asn1::unbounded_octstring<true>* nas_pdu,
asn1::s1ap::cause_c& cause)
{
bool ret = bearer_list.modify_erab(erab_id, qos_params, nas_pdu);
if (ret) {
send_connection_reconf(nullptr, false);
}
return ret;
return bearer_list.modify_erab(erab_id, qos_params, nas_pdu, cause);
}
void rrc::ue::notify_s1ap_ue_erab_setup_response(const asn1::s1ap::erab_to_be_setup_list_bearer_su_req_l& e)

@ -74,6 +74,20 @@ void add_repeated_erab_ids(const List&
}
}
}
// Sort and remove duplications
std::sort(failed_cfg_erabs.begin(), failed_cfg_erabs.end(), &lower_obj_id<erab_item_s>);
failed_cfg_erabs.erase(std::unique(failed_cfg_erabs.begin(), failed_cfg_erabs.end(), &equal_obj_id<erab_item_s>),
failed_cfg_erabs.end());
}
bool contains_erab_id(srsran::bounded_vector<erab_item_s, ASN1_S1AP_MAXNOOF_ERABS>& failed_cfg_erabs, uint16_t erab_id)
{
erab_item_s dummy;
dummy.erab_id = erab_id;
return std::find_if(failed_cfg_erabs.begin(), failed_cfg_erabs.end(), [erab_id](const erab_item_s& e) {
return e.erab_id == erab_id;
}) != failed_cfg_erabs.end();
}
/*********************************************************
@ -760,73 +774,48 @@ bool s1ap::handle_erabsetuprequest(const erab_setup_request_s& msg)
bool s1ap::handle_erabmodifyrequest(const erab_modify_request_s& msg)
{
if (msg.ext) {
logger.warning("Not handling S1AP message extension");
}
WarnUnsupportFeature(msg.ext, "S1AP message extension");
ue* u =
handle_s1apmsg_ue_id(msg.protocol_ies.enb_ue_s1ap_id.value.value, msg.protocol_ies.mme_ue_s1ap_id.value.value);
if (u == nullptr) {
return false;
}
using erab_t = erab_to_be_modified_item_bearer_mod_req_s;
using failed_erab_t = std::pair<uint16_t, cause_c>;
srsran::bounded_vector<const erab_t*, MAX_ERAB_ID + 1> erab_mod_list;
srsran::bounded_vector<failed_erab_t, MAX_ERAB_ID + 1> erabs_failed_to_modify;
const auto& msg_erabs = msg.protocol_ies.erab_to_be_modified_list_bearer_mod_req.value;
if (msg_erabs.size() > erab_mod_list.capacity()) {
logger.warning("Not handling more than %d E-RABs per modify request message.", erab_mod_list.capacity());
}
for (size_t i = 0; i < SRSRAN_MIN(msg_erabs.size(), erab_mod_list.capacity()); ++i) {
const erab_t& e = msg_erabs[i].value.erab_to_be_modified_item_bearer_mod_req();
failed_cfg_erabs.clear();
updated_erabs.clear();
add_repeated_erab_ids(msg.protocol_ies.erab_to_be_modified_list_bearer_mod_req.value, failed_cfg_erabs);
// Check if E-RAB exists. If not, add to "erabs_failed_to_modify" with "unknown_erab_id" cause
if (not rrc->has_erab(u->ctxt.rnti, e.erab_id)) {
cause_c cause;
cause.set_radio_network().value = cause_radio_network_opts::unknown_erab_id;
erabs_failed_to_modify.emplace_back(e.erab_id, cause);
for (const auto& item : msg.protocol_ies.erab_to_be_modified_list_bearer_mod_req.value) {
const auto& erab = item.value.erab_to_be_modified_item_bearer_mod_req();
if (contains_erab_id(failed_cfg_erabs, erab.erab_id)) {
// E-RAB is duplicate
continue;
}
// Check Repeated E-RABs in the modification list. If repeated, add to the list of "erabs_failed_to_modify"
// with cause "multiple_erab_id_instances"
for (const auto& msg_erab2 : msg_erabs) {
const erab_t& e2 = msg_erab2.value.erab_to_be_modified_item_bearer_mod_req();
if (&e2 != &e and e2.erab_id == e.erab_id) {
cause_c cause;
cause.set_radio_network().value = cause_radio_network_opts::multiple_erab_id_instances;
erabs_failed_to_modify.emplace_back(e.erab_id, cause);
break;
}
if (rrc->modify_erab(u->ctxt.rnti, erab.erab_id, erab.erab_level_qos_params, &erab.nas_pdu, cause) ==
SRSRAN_SUCCESS) {
updated_erabs.push_back(erab.erab_id);
} else {
failed_cfg_erabs.push_back(erab_item_s());
failed_cfg_erabs.back().erab_id = erab.erab_id;
failed_cfg_erabs.back().cause = cause;
}
if (not erabs_failed_to_modify.empty() and erabs_failed_to_modify.back().first == e.erab_id) {
continue;
}
// Add to the list to modify
erab_mod_list.push_back(&e);
// Notify UE of updates
if (not updated_erabs.empty()) {
rrc->notify_ue_erab_updates(u->ctxt.rnti, nullptr);
}
// Modify E-RABs from RRC
rrc->modify_erabs(u->ctxt.rnti, erab_mod_list);
// Sort by E-RAB id, and remove duplicates
auto lower_erab = [](const erab_t* lhs, const erab_t* rhs) { return lhs->erab_id < rhs->erab_id; };
std::sort(erab_mod_list.begin(), erab_mod_list.end(), lower_erab);
auto lower_erab2 = [](const failed_erab_t& lhs, const failed_erab_t& rhs) { return lhs.first < rhs.first; };
auto equal_erab2 = [](const failed_erab_t& lhs, const failed_erab_t& rhs) { return lhs.first == rhs.first; };
std::sort(erabs_failed_to_modify.begin(), erabs_failed_to_modify.end(), lower_erab2);
erabs_failed_to_modify.erase(std::unique(erabs_failed_to_modify.begin(), erabs_failed_to_modify.end(), equal_erab2),
erabs_failed_to_modify.end());
// Send E-RAB modify response back to the MME
if (not u->send_erab_modify_response(erab_mod_list, erabs_failed_to_modify)) {
logger.info("Failed to send ERABReleaseResponse");
// send E-RAB modify response back to the mme
std::sort(updated_erabs.begin(), updated_erabs.end());
std::sort(failed_cfg_erabs.begin(), failed_cfg_erabs.end(), &lower_obj_id<erab_item_s>);
if (not u->send_erab_modify_response(updated_erabs, failed_cfg_erabs)) {
logger.info("failed to send erabreleaseresponse");
return false;
}
return true;
}
@ -873,15 +862,15 @@ bool s1ap::handle_erabreleasecommand(const erab_release_cmd_s& msg)
}
}
// Sort E-RABs to be sent
std::sort(failed_cfg_erabs.begin(), failed_cfg_erabs.end(), &lower_obj_id<erab_item_s>);
std::sort(updated_erabs.begin(), updated_erabs.end());
// Notify RRC of E-RAB update. (RRC reconf message is going to be sent.
if (not updated_erabs.empty()) {
rrc->notify_ue_erab_updates(u->ctxt.rnti, nullptr);
}
// Sort E-RABs to be sent
std::sort(failed_cfg_erabs.begin(), failed_cfg_erabs.end(), &lower_obj_id<erab_item_s>);
std::sort(updated_erabs.begin(), updated_erabs.end());
// Send E-RAB release response back to the MME
if (not u->send_erab_release_response(updated_erabs, failed_cfg_erabs)) {
logger.info("Failed to send ERABReleaseResponse");
@ -1516,14 +1505,9 @@ bool s1ap::ue::send_erab_release_response(srsran::const_span<uint16_t>
return s1ap_ptr->sctp_send_s1ap_pdu(tx_pdu, ctxt.rnti, "E-RABReleaseResponse");
}
bool s1ap::ue::send_erab_modify_response(
srsran::const_span<const erab_to_be_modified_item_bearer_mod_req_s*> erabs_modified,
srsran::const_span<std::pair<uint16_t, cause_c> > erabs_failed_to_modify)
bool s1ap::ue::send_erab_modify_response(srsran::const_span<uint16_t> erabs_modified,
srsran::const_span<erab_item_s> erabs_failed_to_modify)
{
if (not s1ap_ptr->mme_connected) {
return false;
}
asn1::s1ap::s1ap_pdu_c tx_pdu;
tx_pdu.set_successful_outcome().load_info_obj(ASN1_S1AP_ID_ERAB_MODIFY);
@ -1538,7 +1522,7 @@ bool s1ap::ue::send_erab_modify_response(
for (uint32_t i = 0; i < container.erab_modify_list_bearer_mod_res.value.size(); i++) {
container.erab_modify_list_bearer_mod_res.value[i].load_info_obj(ASN1_S1AP_ID_ERAB_MODIFY_ITEM_BEARER_MOD_RES);
container.erab_modify_list_bearer_mod_res.value[i].value.erab_modify_item_bearer_mod_res().erab_id =
erabs_modified[i]->erab_id;
erabs_modified[i];
}
}
@ -1548,8 +1532,7 @@ bool s1ap::ue::send_erab_modify_response(
container.erab_failed_to_modify_list.value.resize(erabs_failed_to_modify.size());
for (uint32_t i = 0; i < container.erab_failed_to_modify_list.value.size(); i++) {
container.erab_failed_to_modify_list.value[i].load_info_obj(ASN1_S1AP_ID_ERAB_ITEM);
container.erab_failed_to_modify_list.value[i].value.erab_item().erab_id = erabs_failed_to_modify[i].first;
container.erab_failed_to_modify_list.value[i].value.erab_item().cause = erabs_failed_to_modify[i].second;
container.erab_failed_to_modify_list.value[i].value.erab_item() = erabs_failed_to_modify[i];
}
}
@ -1558,9 +1541,6 @@ bool s1ap::ue::send_erab_modify_response(
bool s1ap::ue::send_erab_release_indication(const std::vector<uint16_t>& erabs_successfully_released)
{
if (not s1ap_ptr->mme_connected) {
return false;
}
if (not erabs_successfully_released.empty()) {
logger.error("Failed to initiate E-RAB RELEASE INDICATION procedure for user rnti=0x%x", ctxt.rnti);
return false;
@ -1585,10 +1565,6 @@ bool s1ap::ue::send_erab_release_indication(const std::vector<uint16_t>& erabs_s
bool s1ap::ue::send_ue_cap_info_indication(srsran::unique_byte_buffer_t ue_radio_cap)
{
if (not s1ap_ptr->mme_connected) {
return false;
}
asn1::s1ap::s1ap_pdu_c tx_pdu;
tx_pdu.set_init_msg().load_info_obj(ASN1_S1AP_ID_UE_CAP_INFO_IND);
ue_cap_info_ind_ies_container& container = tx_pdu.init_msg().value.ue_cap_info_ind().protocol_ies;
@ -1711,6 +1687,11 @@ void s1ap::user_list::erase(ue* ue_ptr)
bool s1ap::sctp_send_s1ap_pdu(const asn1::s1ap::s1ap_pdu_c& tx_pdu, uint32_t rnti, const char* procedure_name)
{
if (not mme_connected and rnti != SRSRAN_INVALID_RNTI) {
logger.error("Aborting %s for rnti=0x%x. Cause: MME is not connected.", procedure_name, rnti);
return false;
}
srsran::unique_byte_buffer_t buf = srsran::make_byte_buffer();
if (buf == nullptr) {
logger.error("Fatal Error: Couldn't allocate buffer for %s.", procedure_name);

@ -169,10 +169,14 @@ public:
bool setup_ue_ctxt(uint16_t rnti, const asn1::s1ap::init_context_setup_request_s& msg) override { return true; }
bool modify_ue_ctxt(uint16_t rnti, const asn1::s1ap::ue_context_mod_request_s& msg) override { return true; }
bool setup_ue_erabs(uint16_t rnti, const asn1::s1ap::erab_setup_request_s& msg) override { return true; }
void modify_erabs(
uint16_t rnti,
srsran::const_span<const asn1::s1ap::erab_to_be_modified_item_bearer_mod_req_s*> erabs_to_modify) override
{}
int modify_erab(uint16_t rnti,
uint16_t erab_id,
const asn1::s1ap::erab_level_qos_params_s& qos_params,
const asn1::unbounded_octstring<true>* nas_pdu,
asn1::s1ap::cause_c& cause) override
{
return SRSRAN_SUCCESS;
}
bool has_erab(uint16_t rnti, uint32_t erab_id) const override { return true; }
bool release_erabs(uint32_t rnti) override { return true; }
int release_erab(uint16_t rnti, uint16_t erab_id) override { return SRSRAN_SUCCESS; }

@ -91,14 +91,18 @@ struct dummy_socket_manager : public srsran::socket_manager_itf {
};
struct rrc_tester : public rrc_dummy {
void modify_erabs(
uint16_t rnti,
srsran::const_span<const asn1::s1ap::erab_to_be_modified_item_bearer_mod_req_s*> erabs_to_modify) override
int modify_erab(uint16_t rnti,
uint16_t erab_id,
const asn1::s1ap::erab_level_qos_params_s& qos_params,
const asn1::unbounded_octstring<true>* nas_pdu,
asn1::s1ap::cause_c& cause) override
{
last_erabs_modified.clear();
for (auto& erab : erabs_to_modify) {
last_erabs_modified.push_back(erab->erab_id);
if (std::count(next_erabs_failed_to_modify.begin(), next_erabs_failed_to_modify.end(), erab_id) > 0) {
cause.set_radio_network().value = asn1::s1ap::cause_radio_network_opts::unknown_erab_id;
return SRSRAN_ERROR;
}
last_erabs_modified.push_back(erab_id);
return SRSRAN_SUCCESS;
}
bool has_erab(uint16_t rnti, uint32_t erab_id) const override
{

Loading…
Cancel
Save