lists.osmocom.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
September
August
July
June
May
April
March
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
List overview
Download
gerrit-log
September 2025
----- 2025 -----
September 2025
August 2025
July 2025
June 2025
May 2025
April 2025
March 2025
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
gerrit-log@lists.osmocom.org
1 participants
1000 discussions
Start a n
N
ew thread
[S] Change in osmo-ttcn3-hacks[master]: sgsn: TC_stat_bsc_sctp_disconnected: validate using StatsD
by pespin
Attention is currently required from: fixeria. pespin has posted comments on this change by pespin. (
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/40992?usp=email
) Change subject: sgsn: TC_stat_bsc_sctp_disconnected: validate using StatsD ...................................................................... Patch Set 1: Code-Review+2 -- To view, visit
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/40992?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: I1ff8c51a73556357c5a5e97bc2a0edec30f1cf03 Gerrit-Change-Number: 40992 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: lynxis lazus <lynxis(a)fe80.eu> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Comment-Date: Wed, 03 Sep 2025 14:17:13 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes
2 weeks, 4 days
1
0
0
0
[M] Change in osmo-sgsn[master]: stats: Introduce stats sgsn.iu_peers.{total,active}
by lynxis lazus
lynxis lazus has submitted this change. (
https://gerrit.osmocom.org/c/osmo-sgsn/+/40990?usp=email
) Change subject: stats: Introduce stats sgsn.iu_peers.{total,active} ...................................................................... stats: Introduce stats sgsn.iu_peers.{total,active} Change-Id: I51b5227d92027f1251dc4debbbf59737e7c1a9ba --- M include/osmocom/sgsn/sgsn.h M src/sgsn/iu_rnc.c M src/sgsn/iu_rnc_fsm.c M src/sgsn/sgsn.c 4 files changed, 53 insertions(+), 0 deletions(-) Approvals: Jenkins Builder: Verified osmith: Looks good to me, but someone else must approve lynxis lazus: Looks good to me, approved diff --git a/include/osmocom/sgsn/sgsn.h b/include/osmocom/sgsn/sgsn.h index 8fc97b0..8524dd7 100644 --- a/include/osmocom/sgsn/sgsn.h +++ b/include/osmocom/sgsn/sgsn.h @@ -5,6 +5,7 @@ #include <osmocom/core/msgb.h> #include <osmocom/core/select.h> +#include <osmocom/core/stat_item.h> #include <osmocom/crypt/gprs_cipher.h> #include <osmocom/gprs/gprs_ns2.h> #include <osmocom/gprs/gprs_bssgp.h> @@ -159,6 +160,7 @@ struct sgsn_ra_global *routing_area; struct rate_ctr_group *rate_ctrs; + struct osmo_stat_item_group *statg; struct llist_head apn_list; /* list of struct sgsn_apn_ctx */ struct llist_head ggsn_list; /* list of struct sgsn_ggsn_ctx */ @@ -184,6 +186,21 @@ extern struct sgsn_instance *sgsn; extern void *tall_sgsn_ctx; +enum { + SGSN_STAT_IU_PEERS_TOTAL, + SGSN_STAT_IU_PEERS_ACTIVE, +}; +static inline void sgsn_stat_inc(unsigned int idx, int32_t value) +{ + osmo_stat_item_inc(osmo_stat_item_group_get_item(sgsn->statg, idx), value); +} + +static inline void sgsn_stat_dec(unsigned int idx, int32_t value) +{ + osmo_stat_item_dec(osmo_stat_item_group_get_item(sgsn->statg, idx), value); +} + + /* * ctrl interface related work (sgsn_ctrl.c) */ diff --git a/src/sgsn/iu_rnc.c b/src/sgsn/iu_rnc.c index abe6f61..38cddb5 100644 --- a/src/sgsn/iu_rnc.c +++ b/src/sgsn/iu_rnc.c @@ -76,6 +76,7 @@ osmo_rnc_id_name(rnc_id), addr_str); llist_add(&rnc->entry, &sgsn->rnc_list); + sgsn_stat_inc(SGSN_STAT_IU_PEERS_TOTAL, 1); LOGP(DRANAP, LOGL_NOTICE, "New RNC %s at %s\n", osmo_rnc_id_name(&rnc->rnc_id), osmo_sccp_addr_dump(rnc_sccp_addr)); diff --git a/src/sgsn/iu_rnc_fsm.c b/src/sgsn/iu_rnc_fsm.c index 4085586..6f610b4 100644 --- a/src/sgsn/iu_rnc_fsm.c +++ b/src/sgsn/iu_rnc_fsm.c @@ -216,6 +216,12 @@ } } +static void iu_rnc_st_ready_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state) +{ + if (prev_state != IU_RNC_ST_READY) + sgsn_stat_inc(SGSN_STAT_IU_PEERS_ACTIVE, 1); +} + static void iu_rnc_st_ready(struct osmo_fsm_inst *fi, uint32_t event, void *data) { struct ranap_iu_rnc *rnc = fi->priv; @@ -261,6 +267,12 @@ } } +static void iu_rnc_st_ready_onleave(struct osmo_fsm_inst *fi, uint32_t next_state) +{ + if (next_state != IU_RNC_ST_READY) + sgsn_stat_dec(SGSN_STAT_IU_PEERS_ACTIVE, 1); +} + static int iu_rnc_fsm_timer_cb(struct osmo_fsm_inst *fi) { struct ranap_iu_rnc *rnc = fi->priv; @@ -273,6 +285,10 @@ struct ranap_iu_rnc *rnc = fi->priv; iu_rnc_discard_all_ue_ctx(rnc); + + if (rnc->fi->state == IU_RNC_ST_READY) + sgsn_stat_dec(SGSN_STAT_IU_PEERS_ACTIVE, 1); + sgsn_stat_dec(SGSN_STAT_IU_PEERS_TOTAL, 1); } static const struct osmo_fsm_state iu_rnc_fsm_states[] = { @@ -314,6 +330,8 @@ [IU_RNC_ST_READY] = { .name = "READY", .action = iu_rnc_st_ready, + .onenter = iu_rnc_st_ready_onenter, + .onleave = iu_rnc_st_ready_onleave, .in_event_mask = 0 | S(IU_RNC_EV_RX_RESET) | S(IU_RNC_EV_MSG_UP_CO_INITIAL) diff --git a/src/sgsn/sgsn.c b/src/sgsn/sgsn.c index 1b02f76..fe52e6c 100644 --- a/src/sgsn/sgsn.c +++ b/src/sgsn/sgsn.c @@ -103,6 +103,20 @@ sgsn_ctr_description, }; + +static const struct osmo_stat_item_desc sgsn_stat_item_description[] = { + [SGSN_STAT_IU_PEERS_TOTAL] = { "iu_peers:total", "Total Iu peers (RNC, HNBGW) seen since startup", OSMO_STAT_ITEM_NO_UNIT, 4, 0}, + [SGSN_STAT_IU_PEERS_ACTIVE] = { "iu_peers:active", "Currently active Iu peers (RANAP ready)", OSMO_STAT_ITEM_NO_UNIT, 4, 0}, +}; + +static const struct osmo_stat_item_group_desc sgsn_statg_desc = { + "sgsn", + "serving GPRS support node statistics", + OSMO_STATS_CLASS_GLOBAL, + ARRAY_SIZE(sgsn_stat_item_description), + sgsn_stat_item_description, +}; + static void sgsn_llme_cleanup_free(struct gprs_llc_llme *llme) { struct sgsn_mm_ctx *mmctx = NULL; @@ -161,6 +175,7 @@ #endif /* #if BUILD_IU */ osmo_timer_del(&sgi->llme_timer); rate_ctr_group_free(sgi->rate_ctrs); + osmo_stat_item_group_free(sgi->statg); return 0; } @@ -185,6 +200,8 @@ inst->rate_ctrs = rate_ctr_group_alloc(inst, &sgsn_ctrg_desc, 0); OSMO_ASSERT(inst->rate_ctrs); + inst->statg = osmo_stat_item_group_alloc(inst, &sgsn_statg_desc, 0); + OSMO_ASSERT(inst->statg); INIT_LLIST_HEAD(&inst->apn_list); INIT_LLIST_HEAD(&inst->ggsn_list); -- To view, visit
https://gerrit.osmocom.org/c/osmo-sgsn/+/40990?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged Gerrit-Project: osmo-sgsn Gerrit-Branch: master Gerrit-Change-Id: I51b5227d92027f1251dc4debbbf59737e7c1a9ba Gerrit-Change-Number: 40990 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: lynxis lazus <lynxis(a)fe80.eu> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
2 weeks, 4 days
1
0
0
0
[L] Change in osmo-sgsn[master]: ranap: Take into account RNC availability during paging
by lynxis lazus
lynxis lazus has submitted this change. (
https://gerrit.osmocom.org/c/osmo-sgsn/+/41001?usp=email
) Change subject: ranap: Take into account RNC availability during paging ...................................................................... ranap: Take into account RNC availability during paging Avoid transmitting a RANAP paging message to an RNC if we already know it's not currently available over SCCP. Take into account that information when deciding/printing whether the paging could be sent or not. Take the chance to clean up the iu paging function helpers inherited from osmo-iuh iu_client.c to better fit the data domain in osmo-sgsn (iu_rnc). Change-Id: I24e5446bcf4c958028577230b231960acea9e5b9 --- M include/osmocom/sgsn/gprs_ranap.h M include/osmocom/sgsn/iu_rnc.h M include/osmocom/sgsn/iu_rnc_fsm.h M src/sgsn/gprs_ranap.c M src/sgsn/iu_client.c M src/sgsn/iu_rnc.c M src/sgsn/iu_rnc_fsm.c 7 files changed, 144 insertions(+), 115 deletions(-) Approvals: lynxis lazus: Looks good to me, approved Jenkins Builder: Verified osmith: Looks good to me, but someone else must approve diff --git a/include/osmocom/sgsn/gprs_ranap.h b/include/osmocom/sgsn/gprs_ranap.h index 62914ba..b959b57 100644 --- a/include/osmocom/sgsn/gprs_ranap.h +++ b/include/osmocom/sgsn/gprs_ranap.h @@ -30,9 +30,6 @@ int sgsn_ranap_iu_tx_sec_mode_cmd(struct ranap_ue_conn_ctx *uectx, struct osmo_auth_vector *vec, int send_ck, int new_key); int sgsn_ranap_iu_tx_common_id(struct ranap_ue_conn_ctx *ue_ctx, const char *imsi); -int sgsn_ranap_iu_tx_paging_cmd(struct osmo_sccp_addr *called_addr, - const char *imsi, const uint32_t *tmsi, - bool is_ps, uint32_t paging_cause); int sgsn_ranap_iu_tx_release(struct ranap_ue_conn_ctx *ctx, const struct RANAP_Cause *cause); /* Transmit a Iu Release Command and submit event RANAP_IU_EVENT_IU_RELEASE upon diff --git a/include/osmocom/sgsn/iu_rnc.h b/include/osmocom/sgsn/iu_rnc.h index b0e5be3..0382b74 100644 --- a/include/osmocom/sgsn/iu_rnc.h +++ b/include/osmocom/sgsn/iu_rnc.h @@ -1,6 +1,7 @@ #pragma once #include <stdbool.h> +#include <stdint.h> #include <osmocom/core/defs.h> #include <osmocom/core/linuxlist.h> @@ -43,6 +44,12 @@ void iu_rnc_discard_all_ue_ctx(struct ranap_iu_rnc *rnc); +int iu_rnc_tx_paging_cmd(struct ranap_iu_rnc *rnc, + const char *imsi, + const uint32_t *tmsi, + bool is_ps, + uint32_t paging_cause); + #define LOG_RNC_CAT(IU_RNC, subsys, loglevel, fmt, args ...) \ LOGPFSMSL((IU_RNC)->fi, subsys, loglevel, fmt, ## args) diff --git a/include/osmocom/sgsn/iu_rnc_fsm.h b/include/osmocom/sgsn/iu_rnc_fsm.h index d9be576..f69d82e 100644 --- a/include/osmocom/sgsn/iu_rnc_fsm.h +++ b/include/osmocom/sgsn/iu_rnc_fsm.h @@ -29,6 +29,7 @@ IU_RNC_EV_MSG_UP_CO, /* struct iu_rnc_ev_msg_up_co_ctx* */ IU_RNC_EV_RX_RESET, /* no param */ IU_RNC_EV_RX_RESET_ACK, /* no param */ + IU_RNC_EV_MSG_DOWN_CL, /* struct msgb* */ IU_RNC_EV_AVAILABLE, IU_RNC_EV_UNAVAILABLE }; diff --git a/src/sgsn/gprs_ranap.c b/src/sgsn/gprs_ranap.c index df9cc9e..1cdb72b 100644 --- a/src/sgsn/gprs_ranap.c +++ b/src/sgsn/gprs_ranap.c @@ -287,22 +287,6 @@ return sgsn_scu_iups_tx_data_req(uectx->rnc->scu_iups, uectx->conn_id, msg); } -/* Send a paging command down a given SCCP User. tmsi and paging_cause are - * optional and may be passed NULL and 0, respectively, to disable their use. - * See enum RANAP_PagingCause. - * - * If TMSI is given, the IMSI is not sent over the air interface. Nevertheless, - * the IMSI is still required for resolution in the HNB-GW and/or(?) RNC. */ -int sgsn_ranap_iu_tx_paging_cmd(struct osmo_sccp_addr *called_addr, - const char *imsi, const uint32_t *tmsi, - bool is_ps, uint32_t paging_cause) -{ - struct msgb *msg; - msg = ranap_new_msg_paging_cmd(imsi, tmsi, is_ps ? 1 : 0, paging_cause); - msg->l2h = msg->data; - return osmo_sccp_tx_unitdata_msg(sgsn->sccp.scu_iups->scu, &sgsn->sccp.scu_iups->local_sccp_addr, called_addr, msg); -} - int sgsn_ranap_iu_tx(struct msgb *msg_nas, uint8_t sapi) { struct ranap_ue_conn_ctx *uectx = msg_nas->dst; diff --git a/src/sgsn/iu_client.c b/src/sgsn/iu_client.c index cb5d096..164ff71 100644 --- a/src/sgsn/iu_client.c +++ b/src/sgsn/iu_client.c @@ -43,12 +43,6 @@ #include <osmocom/sgsn/sccp.h> #include <osmocom/sgsn/sgsn.h> -#define LOGPIU(level, fmt, args...) \ - LOGP(DRANAP, level, fmt, ## args) - -#define LOGPIUC(level, fmt, args...) \ - LOGPC(DRANAP, level, fmt, ## args) - const struct value_string iu_client_event_type_names[] = { OSMO_VALUE_STRING(RANAP_IU_EVENT_RAB_ASSIGN), OSMO_VALUE_STRING(RANAP_IU_EVENT_SECURITY_MODE_COMPLETE), @@ -66,7 +60,7 @@ if (ue_ctx && !ue_ctx->notification) return 0; - LOGPIU(LOGL_DEBUG, "Submit Iu event to upper layer: %s\n", iu_client_event_type_str(type)); + LOGP(DRANAP, LOGL_DEBUG, "Submit Iu event to upper layer: %s\n", iu_client_event_type_str(type)); return sgsn_ranap_iu_event(ue_ctx, type, data); } @@ -126,78 +120,74 @@ ***********************************************************************/ /* legacy, do a first match with ignoring PLMN */ -static bool iu_rnc_lac_rac_find_legacy(struct ranap_iu_rnc **rnc, struct iu_lac_rac_entry **lre, - uint16_t lac, uint8_t rac) -{ - struct ranap_iu_rnc *r; - struct iu_lac_rac_entry *e; - - if (rnc) - *rnc = NULL; - if (lre) - *lre = NULL; - - llist_for_each_entry(r, &sgsn->rnc_list, entry) { - llist_for_each_entry(e, &r->lac_rac_list, entry) { - if (e->rai.lac.lac == lac && e->rai.rac == rac) { - if (rnc) - *rnc = r; - if (lre) - *lre = e; - return true; - } - } - } - return false; -} - -static int iu_page(const char *imsi, const uint32_t *tmsi_or_ptmsi, - uint16_t lac, uint8_t rac, bool is_ps) +static struct ranap_iu_rnc *iu_rnc_lac_rac_find_legacy(uint16_t lac, uint8_t rac) { struct ranap_iu_rnc *rnc; - const char *log_msg; - int log_level; - int paged = 0; + struct iu_lac_rac_entry *e; - iu_rnc_lac_rac_find_legacy(&rnc, NULL, lac, rac); - if (rnc) { - if (sgsn_ranap_iu_tx_paging_cmd(&rnc->sccp_addr, imsi, tmsi_or_ptmsi, is_ps, 0) == 0) { - log_msg = "Paging"; - log_level = LOGL_DEBUG; - paged = 1; - } else { - log_msg = "Paging failed"; - log_level = LOGL_ERROR; + llist_for_each_entry(rnc, &sgsn->rnc_list, entry) { + llist_for_each_entry(e, &rnc->lac_rac_list, entry) { + if (e->rai.lac.lac == lac && e->rai.rac == rac) + return rnc; } - } else { - log_msg = "Found no RNC to Page"; - log_level = LOGL_ERROR; } - - if (is_ps) - LOGPIU(log_level, "IuPS: %s on LAC %d RAC %d", log_msg, lac, rac); - else - LOGPIU(log_level, "IuCS: %s on LAC %d", log_msg, lac); - if (rnc) - LOGPIUC(log_level, " at SCCP-addr %s", osmo_sccp_addr_dump(&rnc->sccp_addr)); - if (tmsi_or_ptmsi) - LOGPIUC(log_level, ", for %s %08x\n", is_ps ? "PTMSI" : "TMSI", *tmsi_or_ptmsi); - else - LOGPIUC(log_level, ", for IMSI %s\n", imsi); - - return paged; + return NULL; } /*! Old paging() doesn't use PLMN and transmit paging command only to the first RNC */ int ranap_iu_page_cs(const char *imsi, const uint32_t *tmsi, uint16_t lac) { - return iu_page(imsi, tmsi, lac, 0, false); + struct ranap_iu_rnc *rnc; + char log_msg[32] = {}; + int rc; + + if (tmsi) + snprintf(log_msg, sizeof(log_msg), "TMSI %08x\n", *tmsi); + else + snprintf(log_msg, sizeof(log_msg), "IMSI %s\n", imsi); + + rnc = iu_rnc_lac_rac_find_legacy(lac, 0); + if (!rnc) { + LOGP(DRANAP, LOGL_INFO, "Found no RNC to Page CS on LAC %u for %s", + lac, log_msg); + return 0; + } + + rc = iu_rnc_tx_paging_cmd(rnc, imsi, tmsi, false, 0); + if (rc != 0) { + LOG_RNC(rnc, LOGL_ERROR, "Failed to tx Paging CS for LAC %u for %s", + lac, log_msg); + return 0; + } + return 1; } /*! Old paging() doesn't use PLMN and transmit paging command only to the first RNC */ int ranap_iu_page_ps(const char *imsi, const uint32_t *ptmsi, uint16_t lac, uint8_t rac) { - return iu_page(imsi, ptmsi, lac, rac, true); + struct ranap_iu_rnc *rnc; + char log_msg[32] = {}; + int rc; + + if (ptmsi) + snprintf(log_msg, sizeof(log_msg), "P-TMSI %08x\n", *ptmsi); + else + snprintf(log_msg, sizeof(log_msg), "IMSI %s\n", imsi); + + rnc = iu_rnc_lac_rac_find_legacy(lac, rac); + if (!rnc) { + LOGP(DRANAP, LOGL_INFO, "Found no RNC to Page PS on LAC %u RAC %u for %s", + lac, rac, log_msg); + return 0; + } + + rc = iu_rnc_tx_paging_cmd(rnc, imsi, ptmsi, true, 0); + if (rc != 0) { + LOG_RNC(rnc, LOGL_ERROR, "Failed to tx Paging PS for LAC %u RAC %u for %s", + lac, rac, log_msg); + return 0; + } + return 1; } /*! Transmit a single page request towards all RNCs serving the specific LAI (no page retransmission). @@ -212,8 +202,13 @@ struct ranap_iu_rnc *rnc; struct iu_lac_rac_entry *entry; char log_msg[32] = {}; - int paged = 0; - int rc = 0; + unsigned int paged = 0; + int rc; + + if (tmsi) + snprintf(log_msg, sizeof(log_msg), "TMSI %08x\n", *tmsi); + else + snprintf(log_msg, sizeof(log_msg), "IMSI %s\n", imsi); /* find all RNCs which are serving this LA */ llist_for_each_entry(rnc, &sgsn->rnc_list, entry) { @@ -221,27 +216,23 @@ if (osmo_lai_cmp(&entry->rai.lac, lai)) continue; - rc = sgsn_ranap_iu_tx_paging_cmd(&rnc->sccp_addr, imsi, tmsi, false, 0); - if (rc > 0) { - LOGPIU(LOGL_ERROR, "IuCS: Failed to tx Paging RNC %s for LAC %s for IMSI %s / TMSI %08x", - osmo_rnc_id_name(&rnc->rnc_id), - osmo_lai_name(lai), imsi, tmsi ? *tmsi : GSM_RESERVED_TMSI); + rc = iu_rnc_tx_paging_cmd(rnc, imsi, tmsi, false, 0); + if (rc != 0) { + LOG_RNC(rnc, LOGL_ERROR, "Failed to tx Paging CS for LAI %s for %s", + osmo_lai_name(lai), log_msg); + } else { + paged++; } - paged++; break; } } - if (tmsi) - snprintf(log_msg, sizeof(log_msg), "for TMSI %08x\n", *tmsi); - else - snprintf(log_msg, sizeof(log_msg) - 1, "for IMSI %s\n", imsi); - if (paged) - LOGPIU(LOGL_DEBUG, "IuPS: Paged %d RNCs on LAI %s for %s", paged, osmo_lai_name(lai), log_msg); + LOGP(DRANAP, LOGL_DEBUG, "Paged CS %u RNCs on LAI %s for %s", + paged, osmo_lai_name(lai), log_msg); else - LOGPIU(LOGL_INFO, "IuPS: Found no RNC to Page on LAI %s for %s", osmo_lai_name(lai), log_msg); - + LOGP(DRANAP, LOGL_INFO, "Found no RNC to Page CS on LAI %s for %s", + osmo_lai_name(lai), log_msg); return paged; } @@ -249,7 +240,7 @@ /*! Transmit a single page request towards all RNCs serving the specific RAI (no page retransmission). * * \param imsi the imsi as human readable string - * \param ptmsi NULL or pointer to the tmsi + * \param ptmsi NULL or pointer to the ptmsi * \param rai full Location Area Identifier * \return amount of paged RNCs. 0 when no RNC found. */ @@ -258,8 +249,13 @@ struct ranap_iu_rnc *rnc; struct iu_lac_rac_entry *entry; char log_msg[32] = {}; - int paged = 0; - int rc = 0; + unsigned int paged = 0; + int rc; + + if (ptmsi) + snprintf(log_msg, sizeof(log_msg), "P-TMSI %08x\n", *ptmsi); + else + snprintf(log_msg, sizeof(log_msg), "IMSI %s\n", imsi); /* find all RNCs which are serving this RAC */ llist_for_each_entry(rnc, &sgsn->rnc_list, entry) { @@ -267,26 +263,23 @@ if (osmo_rai_cmp(&entry->rai, rai)) continue; - rc = sgsn_ranap_iu_tx_paging_cmd(&rnc->sccp_addr, imsi, ptmsi, true, 0); - if (rc > 0) { - LOGPIU(LOGL_ERROR, "IuPS: Failed to tx Paging RNC %s for RAC %s for IMSI %s / P-TMSI %08x", - osmo_rnc_id_name(&rnc->rnc_id), - osmo_rai_name2(rai), imsi, ptmsi ? *ptmsi : GSM_RESERVED_TMSI); + rc = iu_rnc_tx_paging_cmd(rnc, imsi, ptmsi, true, 0); + if (rc != 0) { + LOG_RNC(rnc, LOGL_ERROR, "Failed to tx Paging PS for RAI %s for %s", + osmo_rai_name2(rai), log_msg); + } else { + paged++; } - paged++; break; } } - if (ptmsi) - snprintf(log_msg, sizeof(log_msg) - 1, "for PTMSI %08x\n", *ptmsi); - else - snprintf(log_msg, sizeof(log_msg) - 1, "for IMSI %s\n", imsi); - if (paged) - LOGPIU(LOGL_DEBUG, "IuPS: Paged %d RNCs on RAI %s for %s", paged, osmo_rai_name2(rai), log_msg); + LOGP(DRANAP, LOGL_DEBUG, "Paged PS %u RNCs on RAI %s for %s", + paged, osmo_rai_name2(rai), log_msg); else - LOGPIU(LOGL_INFO, "IuPS: Found no RNC to Page on RAI %s for %s", osmo_rai_name2(rai), log_msg); + LOGP(DRANAP, LOGL_INFO, "Found no RNC to Page PS on RAI %s for %s", + osmo_rai_name2(rai), log_msg); return paged; } diff --git a/src/sgsn/iu_rnc.c b/src/sgsn/iu_rnc.c index 38cddb5..1a15df1 100644 --- a/src/sgsn/iu_rnc.c +++ b/src/sgsn/iu_rnc.c @@ -213,3 +213,43 @@ ue_conn_ctx_link_invalidated_free(ue_ctx); } } + +/* Send a paging command down a given SCCP User. tmsi_or_ptmsi and paging_cause are + * optional and may be passed NULL and 0, respectively, to disable their use. + * See enum RANAP_PagingCause. + * + * If tmsi_or_ptmsi is given, the imsi is not sent over the air interface. + * Nevertheless, the IMSI is still required for resolution in the HNB-GW + * and/or(?) RNC. + * + * returns negative if paging couldn't be sent (eg. because RNC is currently + * unreachable in lower layers). + **/ +int iu_rnc_tx_paging_cmd(struct ranap_iu_rnc *rnc, + const char *imsi, + const uint32_t *tmsi_or_ptmsi, + bool is_ps, + uint32_t paging_cause) +{ + struct msgb *ranap_msg; + int rc; + + /* rnc is not ready for paging (link not ready). */ + if (rnc->fi->state != IU_RNC_ST_READY) + return -ENOLINK; + + LOG_RNC(rnc, LOGL_DEBUG, "Paging %s for %s=%08x IMSI=%s\n", + is_ps ? "PS" : "CS", + is_ps ? "P-TMSI" : "TMSI", + tmsi_or_ptmsi ? *tmsi_or_ptmsi : GSM_RESERVED_TMSI, + imsi); + + ranap_msg = ranap_new_msg_paging_cmd(imsi, tmsi_or_ptmsi, is_ps ? 1 : 0, paging_cause); + if (!ranap_msg) + return -EINVAL; + + rc = osmo_fsm_inst_dispatch(rnc->fi, IU_RNC_EV_MSG_DOWN_CL, ranap_msg); + if (rc != 0) + msgb_free(ranap_msg); + return rc; +} diff --git a/src/sgsn/iu_rnc_fsm.c b/src/sgsn/iu_rnc_fsm.c index 6f610b4..6b0ad41 100644 --- a/src/sgsn/iu_rnc_fsm.c +++ b/src/sgsn/iu_rnc_fsm.c @@ -57,6 +57,7 @@ OSMO_VALUE_STRING(IU_RNC_EV_MSG_UP_CO), OSMO_VALUE_STRING(IU_RNC_EV_RX_RESET), OSMO_VALUE_STRING(IU_RNC_EV_RX_RESET_ACK), + OSMO_VALUE_STRING(IU_RNC_EV_MSG_DOWN_CL), OSMO_VALUE_STRING(IU_RNC_EV_AVAILABLE), OSMO_VALUE_STRING(IU_RNC_EV_UNAVAILABLE), {} @@ -252,6 +253,11 @@ iu_rnc_rx_reset(rnc); return; + case IU_RNC_EV_MSG_DOWN_CL: + OSMO_ASSERT(data); + sgsn_ranap_iu_tx_cl(rnc->scu_iups, &rnc->sccp_addr, (struct msgb *)data); + return; + case IU_RNC_EV_AVAILABLE: /* Do nothing, we were already up. */ return; @@ -336,6 +342,7 @@ | S(IU_RNC_EV_RX_RESET) | S(IU_RNC_EV_MSG_UP_CO_INITIAL) | S(IU_RNC_EV_MSG_UP_CO) + | S(IU_RNC_EV_MSG_DOWN_CL) | S(IU_RNC_EV_AVAILABLE) | S(IU_RNC_EV_UNAVAILABLE) , -- To view, visit
https://gerrit.osmocom.org/c/osmo-sgsn/+/41001?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged Gerrit-Project: osmo-sgsn Gerrit-Branch: master Gerrit-Change-Id: I24e5446bcf4c958028577230b231960acea9e5b9 Gerrit-Change-Number: 41001 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: lynxis lazus <lynxis(a)fe80.eu> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
2 weeks, 4 days
1
0
0
0
[M] Change in osmo-sgsn[master]: ranap: Clean up RANAP rx path param passing
by lynxis lazus
lynxis lazus has submitted this change. (
https://gerrit.osmocom.org/c/osmo-sgsn/+/40960?usp=email
) ( 2 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: ranap: Clean up RANAP rx path param passing ...................................................................... ranap: Clean up RANAP rx path param passing Use the osmo-iuh ranap_cn_rx_*_decode2() APIs directly. This allows getting rid of extra "ctx" temporary structs and another level of cb indirection. Take the chance to update most pointers consitfying them. Depends: osmo-iuh.git Change-Id I667dc2ef377c1ceb5b11315458f00b282c143c81 Change-Id: Ib3c00b5105b7ba4bb1a2dad1a14bea233a03c358 --- M TODO-RELEASE M include/osmocom/sgsn/gprs_ranap.h M src/sgsn/gprs_ranap.c 3 files changed, 102 insertions(+), 61 deletions(-) Approvals: Jenkins Builder: Verified fixeria: Looks good to me, but someone else must approve lynxis lazus: Looks good to me, approved diff --git a/TODO-RELEASE b/TODO-RELEASE index 662cdb5..1dfbdb0 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -11,3 +11,4 @@ libgtp >1.12.0 gtp_set_cb_update_context_ind(), gtp_update_context_resp() libosmocore >1.10.0 enum gsm48_gprs_ie_mm: GSM48_IE_GMM_UE_NET_CAP, GSM48_IE_GMM_VD_PREF_UE_USAGE libosmo-gsup-client >1.8.0 osmo_gsup_client_is_connected(), osmo_gsup_client_get_rem_addr(), osmo_gsup_client_get_rem_port() +osmo-iuh >1.7.0 ranap multiple params are constified, see osmo-iuh Change-Id I667dc2ef377c1ceb5b11315458f00b282c143c81 diff --git a/include/osmocom/sgsn/gprs_ranap.h b/include/osmocom/sgsn/gprs_ranap.h index 8a6c189..80b57e6 100644 --- a/include/osmocom/sgsn/gprs_ranap.h +++ b/include/osmocom/sgsn/gprs_ranap.h @@ -39,11 +39,14 @@ void sgsn_ranap_iu_release_free(struct sgsn_mm_ctx *ctx, const struct RANAP_Cause *cause); -int sgsn_ranap_iu_rx_cl_msg(struct sgsn_sccp_user_iups *scu_iups, struct osmo_scu_unitdata_param *ud_prim, - uint8_t *data, size_t len); -int sgsn_ranap_iu_rx_co_initial_msg(struct sgsn_sccp_user_iups *scu_iups, const struct osmo_sccp_addr *rem_sccp_addr, - uint32_t conn_id, uint8_t *data, size_t len); -int sgsn_ranap_iu_rx_co_msg(struct ranap_ue_conn_ctx *ue_ctx, uint8_t *data, size_t len); +int sgsn_ranap_iu_rx_cl_msg(struct sgsn_sccp_user_iups *scu_iups, + const struct osmo_scu_unitdata_param *ud_prim, + const uint8_t *data, size_t len); +int sgsn_ranap_iu_rx_co_initial_msg(struct sgsn_sccp_user_iups *scu_iups, + const struct osmo_sccp_addr *rem_sccp_addr, + uint32_t conn_id, + const uint8_t *data, size_t len); +int sgsn_ranap_iu_rx_co_msg(struct ranap_ue_conn_ctx *ue_ctx, const uint8_t *data, size_t len); #else /* ifndef BUILD_IU */ inline static void sgsn_ranap_iu_free(void *ctx) {}; diff --git a/src/sgsn/gprs_ranap.c b/src/sgsn/gprs_ranap.c index 376fcac..f71db50 100644 --- a/src/sgsn/gprs_ranap.c +++ b/src/sgsn/gprs_ranap.c @@ -60,7 +60,7 @@ uint16_t rnc_id; }; -static int iu_grnc_id_parse(struct osmo_rnc_id *dst, struct RANAP_GlobalRNC_ID *src) +static int iu_grnc_id_parse(struct osmo_rnc_id *dst, const struct RANAP_GlobalRNC_ID *src) { /* The size is coming from arbitrary sender, check it gracefully */ if (src->pLMNidentity.size != 3) { @@ -86,17 +86,6 @@ } #endif -struct ranap_iu_event_sccp_new_ue_context { - struct sgsn_sccp_user_iups *scu_iups; - struct osmo_sccp_addr rem_sccp_addr; - uint32_t conn_id; -}; - -struct ranap_iu_event_cl_msg_ind { - struct sgsn_sccp_user_iups *scu_iups; - struct osmo_scu_unitdata_param *ud_prim; -}; - /* Send RAB activation requests for all PDP contexts */ void activate_pdp_rabs(struct sgsn_mm_ctx *ctx) { @@ -430,9 +419,11 @@ osmo_timer_schedule(&ctx->release_timeout, timeout, 0); } -static int ranap_handle_co_initial_ue(void *ctx, RANAP_InitialUE_MessageIEs_t *ies) +static int ranap_handle_co_initial_ue(struct sgsn_sccp_user_iups *scu_iups, + const struct osmo_sccp_addr *rem_sccp_addr, + uint32_t conn_id, + const RANAP_InitialUE_MessageIEs_t *ies) { - struct ranap_iu_event_sccp_new_ue_context *new_ctx = ctx; struct gprs_ra_id ra_id = {}; struct osmo_routing_area_id ra_id2 = {}; struct osmo_rnc_id rnc_id = {}; @@ -470,9 +461,9 @@ gprs_rai_to_osmo(&ra_id2, &ra_id); /* Make sure we know the RNC Id and LAC+RAC coming in on this connection. */ - rnc = iu_rnc_register(&rnc_id, &ra_id2, &new_ctx->rem_sccp_addr); + rnc = iu_rnc_register(&rnc_id, &ra_id2, rem_sccp_addr); - ue = ue_conn_ctx_alloc(rnc, new_ctx->scu_iups, new_ctx->conn_id); + ue = ue_conn_ctx_alloc(rnc, scu_iups, conn_id); OSMO_ASSERT(ue); ue->ra_id = ra_id; @@ -485,7 +476,10 @@ return 0; } -static void cn_ranap_handle_co_initial(void *ctx, ranap_message *message) +static void cn_ranap_handle_co_initial(struct sgsn_sccp_user_iups *scu_iups, + const struct osmo_sccp_addr *rem_sccp_addr, + uint32_t conn_id, + const ranap_message *message) { int rc; @@ -498,7 +492,7 @@ message->direction, message->procedureCode); rc = -1; } else - rc = ranap_handle_co_initial_ue(ctx, &message->msg.initialUE_MessageIEs); + rc = ranap_handle_co_initial_ue(scu_iups, rem_sccp_addr, conn_id, &message->msg.initialUE_MessageIEs); if (rc) { LOGP(DRANAP, LOGL_ERROR, "Error in %s (%d)\n", __func__, rc); @@ -506,17 +500,29 @@ } } -int sgsn_ranap_iu_rx_co_initial_msg(struct sgsn_sccp_user_iups *scu_iups, const struct osmo_sccp_addr *rem_sccp_addr, uint32_t conn_id, uint8_t *data, size_t len) +int sgsn_ranap_iu_rx_co_initial_msg(struct sgsn_sccp_user_iups *scu_iups, + const struct osmo_sccp_addr *rem_sccp_addr, + uint32_t conn_id, + const uint8_t *data, size_t len) { - struct ranap_iu_event_sccp_new_ue_context new_ctx = { - .scu_iups = scu_iups, - .conn_id = conn_id, - .rem_sccp_addr = *rem_sccp_addr, - }; - return ranap_cn_rx_co(cn_ranap_handle_co_initial, &new_ctx, data, len); + ranap_message message; + int rc; + + rc = ranap_cn_rx_co_decode2(&message, data, len); + if (rc != 0) { + LOGP(DRANAP, LOGL_ERROR, "Not calling cn_ranap_handle_co_initial() due to rc=%d\n", rc); + goto free_ret; + } + + cn_ranap_handle_co_initial(scu_iups, rem_sccp_addr, conn_id, &message); + +free_ret: + /* Free the asn1 structs in message */ + ranap_cn_rx_co_free(&message); + return rc; } -static int ranap_handle_co_dt(void *ctx, RANAP_DirectTransferIEs_t *ies) +static int ranap_handle_co_dt(struct ranap_ue_conn_ctx *ue_ctx, const RANAP_DirectTransferIEs_t *ies) { struct gprs_ra_id _ra_id, *ra_id = NULL; uint16_t _sai, *sai = NULL; @@ -541,7 +547,7 @@ memcpy(msgb_gmmh(msg), ies->nas_pdu.buf, ies->nas_pdu.size); /* Feed into the MM/CC/SMS-CP layer */ - msg->dst = ctx; + msg->dst = ue_ctx; gsm0408_gprs_rcvmsg_iu(msg, ra_id, sai); msgb_free(msg); @@ -549,7 +555,7 @@ return 0; } -static int ranap_handle_co_err_ind(void *ctx, RANAP_ErrorIndicationIEs_t *ies) +static int ranap_handle_co_err_ind(struct ranap_ue_conn_ctx *ue_ctx, const RANAP_ErrorIndicationIEs_t *ies) { if (ies->presenceMask & ERRORINDICATIONIES_RANAP_CAUSE_PRESENT) LOGP(DRANAP, LOGL_ERROR, "Rx Error Indication (%s)\n", @@ -560,19 +566,19 @@ return 0; } -static int ranap_handle_co_iu_rel_req(struct ranap_ue_conn_ctx *ctx, RANAP_Iu_ReleaseRequestIEs_t *ies) +static int ranap_handle_co_iu_rel_req(struct ranap_ue_conn_ctx *ue_ctx, const RANAP_Iu_ReleaseRequestIEs_t *ies) { LOGP(DRANAP, LOGL_INFO, "Received Iu Release Request, Sending Release Command\n"); - ranap_iu_tx_release(ctx, &ies->cause); + ranap_iu_tx_release(ue_ctx, &ies->cause); return 0; } -static int ranap_handle_co_rab_ass_resp(struct ranap_ue_conn_ctx *ctx, RANAP_RAB_AssignmentResponseIEs_t *ies) +static int ranap_handle_co_rab_ass_resp(struct ranap_ue_conn_ctx *ue_ctx, const RANAP_RAB_AssignmentResponseIEs_t *ies) { int rc = -1; LOGP(DRANAP, LOGL_INFO, - "Rx RAB Assignment Response for UE conn_id %u\n", ctx->conn_id); + "Rx RAB Assignment Response for UE conn_id %u\n", ue_ctx->conn_id); if (ies->presenceMask & RAB_ASSIGNMENTRESPONSEIES_RANAP_RAB_SETUPORMODIFIEDLIST_PRESENT) { /* TODO: Iterate over list of SetupOrModifiedList IEs and handle each one */ RANAP_IE_t *ranap_ie = ies->raB_SetupOrModifiedList.raB_SetupOrModifiedList_ies.list.array[0]; @@ -584,7 +590,7 @@ return rc; } - rc = global_iu_event(ctx, RANAP_IU_EVENT_RAB_ASSIGN, &setup_ies); + rc = global_iu_event(ue_ctx, RANAP_IU_EVENT_RAB_ASSIGN, &setup_ies); ranap_free_rab_setupormodifieditemies(&setup_ies); } @@ -594,7 +600,7 @@ } /* Entry point for connection-oriented RANAP message */ -static void cn_ranap_handle_co(void *ctx, ranap_message *message) +static void cn_ranap_handle_co(struct ranap_ue_conn_ctx *ue_ctx, const ranap_message *message) { int rc; @@ -608,14 +614,14 @@ rc = -1; break; case RANAP_ProcedureCode_id_DirectTransfer: - rc = ranap_handle_co_dt(ctx, &message->msg.directTransferIEs); + rc = ranap_handle_co_dt(ue_ctx, &message->msg.directTransferIEs); break; case RANAP_ProcedureCode_id_ErrorIndication: - rc = ranap_handle_co_err_ind(ctx, &message->msg.errorIndicationIEs); + rc = ranap_handle_co_err_ind(ue_ctx, &message->msg.errorIndicationIEs); break; case RANAP_ProcedureCode_id_Iu_ReleaseRequest: /* Iu Release Request */ - rc = ranap_handle_co_iu_rel_req(ctx, &message->msg.iu_ReleaseRequestIEs); + rc = ranap_handle_co_iu_rel_req(ue_ctx, &message->msg.iu_ReleaseRequestIEs); break; default: LOGP(DRANAP, LOGL_ERROR, "Received Initiating Message: unknown Procedure Code %d\n", @@ -628,11 +634,11 @@ switch (message->procedureCode) { case RANAP_ProcedureCode_id_SecurityModeControl: /* Security Mode Complete */ - rc = global_iu_event(ctx, RANAP_IU_EVENT_SECURITY_MODE_COMPLETE, NULL); + rc = global_iu_event(ue_ctx, RANAP_IU_EVENT_SECURITY_MODE_COMPLETE, NULL); break; case RANAP_ProcedureCode_id_Iu_Release: /* Iu Release Complete */ - rc = global_iu_event(ctx, RANAP_IU_EVENT_IU_RELEASE, NULL); + rc = global_iu_event(ue_ctx, RANAP_IU_EVENT_IU_RELEASE, NULL); if (rc) { LOGP(DRANAP, LOGL_ERROR, "Iu Release event: Iu Event callback returned %d\n", rc); @@ -649,7 +655,7 @@ switch (message->procedureCode) { case RANAP_ProcedureCode_id_RAB_Assignment: /* RAB Assignment Response */ - rc = ranap_handle_co_rab_ass_resp(ctx, &message->msg.raB_AssignmentResponseIEs); + rc = ranap_handle_co_rab_ass_resp(ue_ctx, &message->msg.raB_AssignmentResponseIEs); break; default: LOGP(DRANAP, LOGL_ERROR, "Received Outcome: unknown Procedure Code %d\n", @@ -672,14 +678,30 @@ } } -int sgsn_ranap_iu_rx_co_msg(struct ranap_ue_conn_ctx *ue_ctx, uint8_t *data, size_t len) +int sgsn_ranap_iu_rx_co_msg(struct ranap_ue_conn_ctx *ue_ctx, const uint8_t *data, size_t len) { - return ranap_cn_rx_co(cn_ranap_handle_co, ue_ctx, data, len); + ranap_message message; + int rc; + + rc = ranap_cn_rx_co_decode2(&message, data, len); + if (rc != 0) { + LOGP(DRANAP, LOGL_ERROR, "Not calling cn_ranap_handle_co() due to rc=%d\n", rc); + goto free_ret; + } + + cn_ranap_handle_co(ue_ctx, &message); + +free_ret: + /* Free the asn1 structs in message */ + ranap_cn_rx_co_free(&message); + return rc; } -static int ranap_handle_cl_reset_req(struct ranap_iu_event_cl_msg_ind *cl_msg_ind, RANAP_ResetIEs_t *ies) +static int ranap_handle_cl_reset_req(struct sgsn_sccp_user_iups *scu_iups, + const struct osmo_scu_unitdata_param *ud_prim, + const RANAP_ResetIEs_t *ies) { - RANAP_GlobalRNC_ID_t *grnc_id = NULL; + const RANAP_GlobalRNC_ID_t *grnc_id = NULL; struct msgb *resp; /* FIXME: verify ies.cN_DomainIndicator */ @@ -692,10 +714,12 @@ if (!resp) return -ENOMEM; resp->l2h = resp->data; - return osmo_sccp_tx_unitdata_msg(cl_msg_ind->scu_iups->scu, &cl_msg_ind->scu_iups->local_sccp_addr, &cl_msg_ind->ud_prim->calling_addr, resp); + return osmo_sccp_tx_unitdata_msg(scu_iups->scu, &scu_iups->local_sccp_addr, &ud_prim->calling_addr, resp); } -static int ranap_handle_cl_err_ind(struct ranap_iu_event_cl_msg_ind *cl_msg_ind, RANAP_ErrorIndicationIEs_t *ies) +static int ranap_handle_cl_err_ind(struct sgsn_sccp_user_iups *scu_iups, + const struct osmo_scu_unitdata_param *ud_prim, + const RANAP_ErrorIndicationIEs_t *ies) { if (ies->presenceMask & ERRORINDICATIONIES_RANAP_CAUSE_PRESENT) LOGP(DRANAP, LOGL_ERROR, "Rx Error Indication (%s)\n", @@ -707,9 +731,10 @@ } /* Entry point for connection-less RANAP message */ -static void cn_ranap_handle_cl(void *ctx, ranap_message *message) +static void cn_ranap_handle_cl(struct sgsn_sccp_user_iups *scu_iups, + const struct osmo_scu_unitdata_param *ud_prim, + const ranap_message *message) { - struct ranap_iu_event_cl_msg_ind *cl_msg_ind = ctx; int rc; switch (message->direction) { @@ -717,10 +742,10 @@ switch (message->procedureCode) { case RANAP_ProcedureCode_id_Reset: /* received reset.req, send reset.resp */ - rc = ranap_handle_cl_reset_req(cl_msg_ind, &message->msg.resetIEs); + rc = ranap_handle_cl_reset_req(scu_iups, ud_prim, &message->msg.resetIEs); break; case RANAP_ProcedureCode_id_ErrorIndication: - rc = ranap_handle_cl_err_ind(cl_msg_ind, &message->msg.errorIndicationIEs); + rc = ranap_handle_cl_err_ind(scu_iups, ud_prim, &message->msg.errorIndicationIEs); break; default: rc = -1; @@ -741,11 +766,23 @@ } } -int sgsn_ranap_iu_rx_cl_msg(struct sgsn_sccp_user_iups *scu_iups, struct osmo_scu_unitdata_param *ud_prim, uint8_t *data, size_t len) +int sgsn_ranap_iu_rx_cl_msg(struct sgsn_sccp_user_iups *scu_iups, + const struct osmo_scu_unitdata_param *ud_prim, + const uint8_t *data, size_t len) { - struct ranap_iu_event_cl_msg_ind cl_msg_ind = { - .scu_iups = scu_iups, - .ud_prim = ud_prim, - }; - return ranap_cn_rx_cl(cn_ranap_handle_cl, &cl_msg_ind, data, len); + ranap_message message; + int rc; + + rc = ranap_cn_rx_cl_decode2(&message, data, len); + if (rc != 0) { + LOGP(DRANAP, LOGL_ERROR, "Not calling cn_ranap_handle_cl() due to rc=%d\n", rc); + goto free_ret; + } + + cn_ranap_handle_cl(scu_iups, ud_prim, &message); + +free_ret: + /* Free the asn1 structs in message */ + ranap_cn_rx_cl_free(&message); + return rc; } -- To view, visit
https://gerrit.osmocom.org/c/osmo-sgsn/+/40960?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged Gerrit-Project: osmo-sgsn Gerrit-Branch: master Gerrit-Change-Id: Ib3c00b5105b7ba4bb1a2dad1a14bea233a03c358 Gerrit-Change-Number: 40960 Gerrit-PatchSet: 3 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: lynxis lazus <lynxis(a)fe80.eu>
2 weeks, 4 days
1
0
0
0
[M] Change in osmo-sgsn[master]: Split Iu RANAP RAB PS act/deact over different layers
by lynxis lazus
lynxis lazus has submitted this change. (
https://gerrit.osmocom.org/c/osmo-sgsn/+/40961?usp=email
) ( 5 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: Split Iu RANAP RAB PS act/deact over different layers ...................................................................... Split Iu RANAP RAB PS act/deact over different layers Properly separate logic acting on objects vs logic building and generating RANAP msg on the wire. Change-Id: I98788468b7e50619cfd99b3aef2311bb601fb6be --- M include/osmocom/sgsn/gprs_ranap.h M include/osmocom/sgsn/mmctx.h M include/osmocom/sgsn/pdpctx.h M src/sgsn/gprs_gmm.c M src/sgsn/gprs_ranap.c M src/sgsn/mmctx.c M src/sgsn/pdpctx.c M src/sgsn/sgsn_libgtp.c 8 files changed, 76 insertions(+), 41 deletions(-) Approvals: lynxis lazus: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmocom/sgsn/gprs_ranap.h b/include/osmocom/sgsn/gprs_ranap.h index 80b57e6..e2450bd 100644 --- a/include/osmocom/sgsn/gprs_ranap.h +++ b/include/osmocom/sgsn/gprs_ranap.h @@ -1,5 +1,7 @@ #pragma once +#include "config.h" + #include <osmocom/core/msgb.h> #ifdef BUILD_IU @@ -11,12 +13,11 @@ struct sgsn_mm_ctx; struct sgsn_pdp_ctx; -void activate_pdp_rabs(struct sgsn_mm_ctx *ctx); int sgsn_ranap_iu_event(struct ranap_ue_conn_ctx *ctx, enum ranap_iu_event_type type, void *data); -int iu_rab_act_ps(uint8_t rab_id, struct sgsn_pdp_ctx *pdp); int ranap_iu_tx(struct msgb *msg, uint8_t sapi); -int ranap_iu_rab_deact(struct ranap_ue_conn_ctx *ue_ctx, uint8_t rab_id); +int sgsn_ranap_iu_tx_rab_ps_ass_req(struct ranap_ue_conn_ctx *ue_ctx, + uint8_t rab_id, uint32_t gtp_ip, uint32_t gtp_tei); int ranap_iu_tx_sec_mode_cmd(struct ranap_ue_conn_ctx *uectx, struct osmo_auth_vector *vec, int send_ck, int new_key); int ranap_iu_tx_common_id(struct ranap_ue_conn_ctx *ue_ctx, const char *imsi); diff --git a/include/osmocom/sgsn/mmctx.h b/include/osmocom/sgsn/mmctx.h index 760e2c4..8ee82e0 100644 --- a/include/osmocom/sgsn/mmctx.h +++ b/include/osmocom/sgsn/mmctx.h @@ -1,5 +1,7 @@ #pragma once +#include "config.h" + #include <stdint.h> #include <netinet/in.h> #include <inttypes.h> @@ -289,3 +291,7 @@ /* Called on subscriber data updates */ void sgsn_update_subscriber_data(struct sgsn_mm_ctx *mmctx); + +#ifdef BUILD_IU +void sgsn_mm_ctx_iu_activate_rabs(struct sgsn_mm_ctx *ctx); +#endif /* ifdef BUILD_IU */ diff --git a/include/osmocom/sgsn/pdpctx.h b/include/osmocom/sgsn/pdpctx.h index 39d744a..a4bbd97 100644 --- a/include/osmocom/sgsn/pdpctx.h +++ b/include/osmocom/sgsn/pdpctx.h @@ -1,5 +1,7 @@ #pragma once +#include "config.h" + #include <stdint.h> #include <netinet/in.h> #include <inttypes.h> @@ -94,5 +96,10 @@ void sgsn_pdp_ctx_terminate(struct sgsn_pdp_ctx *pdp); void sgsn_pdp_ctx_free(struct sgsn_pdp_ctx *pdp); +#ifdef BUILD_IU +int sgsn_pdp_ctx_iu_rab_activate(struct sgsn_pdp_ctx *pdp, uint8_t rab_id); +int sgsn_pdp_ctx_iu_rab_deactivate(struct sgsn_pdp_ctx *pdp, uint8_t rab_id); +#endif /* ifdef BUILD_IU */ + char *gprs_pdpaddr2str(uint8_t *pdpa, uint8_t len, bool return_ipv6); diff --git a/src/sgsn/gprs_gmm.c b/src/sgsn/gprs_gmm.c index d2627a3..a409660 100644 --- a/src/sgsn/gprs_gmm.c +++ b/src/sgsn/gprs_gmm.c @@ -1014,7 +1014,7 @@ rc = gsm48_tx_gmm_service_ack(ctx); if (ctx->iu.service.type != GPRS_SERVICE_T_SIGNALLING) - activate_pdp_rabs(ctx); + sgsn_mm_ctx_iu_activate_rabs(ctx); return rc; #endif diff --git a/src/sgsn/gprs_ranap.c b/src/sgsn/gprs_ranap.c index f71db50..70f369d 100644 --- a/src/sgsn/gprs_ranap.c +++ b/src/sgsn/gprs_ranap.c @@ -86,17 +86,6 @@ } #endif -/* Send RAB activation requests for all PDP contexts */ -void activate_pdp_rabs(struct sgsn_mm_ctx *ctx) -{ - struct sgsn_pdp_ctx *pdp; - if (ctx->ran_type != MM_CTX_T_UTRAN_Iu) - return; - llist_for_each_entry(pdp, &ctx->pdp_list, list) { - iu_rab_act_ps(pdp->nsapi, pdp); - } -} - /* Callback for RAB assignment response */ static int sgsn_ranap_rab_ass_resp(struct sgsn_mm_ctx *ctx, RANAP_RAB_SetupOrModifiedItemIEs_t *setup_ies) { @@ -299,34 +288,18 @@ ctx->iu.ue_ctx = NULL; } -int iu_rab_act_ps(uint8_t rab_id, struct sgsn_pdp_ctx *pdp) +int sgsn_ranap_iu_tx_rab_ps_ass_req(struct ranap_ue_conn_ctx *ue_ctx, + uint8_t rab_id, uint32_t gtp_ip, uint32_t gtp_tei) { struct msgb *msg; - struct sgsn_mm_ctx *mm = pdp->mm; - struct ranap_ue_conn_ctx *uectx; - uint32_t ggsn_ip; - bool use_x213_nsap; + bool use_x213_nsap = (ue_ctx->rab_assign_addr_enc == RANAP_NSAP_ADDR_ENC_X213); - uectx = mm->iu.ue_ctx; - use_x213_nsap = (uectx->rab_assign_addr_enc == RANAP_NSAP_ADDR_ENC_X213); + LOGP(DRANAP, LOGL_DEBUG, + "Assigning RAB: rab_id=%u, ggsn_ip=%x, teid_gn=%x, use_x213_nsap=%d\n", + rab_id, gtp_ip, gtp_tei, use_x213_nsap); - /* Get the IP address for ggsn user plane */ - memcpy(&ggsn_ip, pdp->lib->gsnru.v, pdp->lib->gsnru.l); - ggsn_ip = htonl(ggsn_ip); - - LOGP(DRANAP, LOGL_DEBUG, "Assigning RAB: rab_id=%d, ggsn_ip=%x," - " teid_gn=%x, use_x213_nsap=%d\n", - rab_id, ggsn_ip, pdp->lib->teid_gn, use_x213_nsap); - - msg = ranap_new_msg_rab_assign_data(rab_id, ggsn_ip, - pdp->lib->teid_gn, use_x213_nsap); - return sgsn_scu_iups_tx_data_req(uectx->scu_iups, uectx->conn_id, msg); -} - -int ranap_iu_rab_deact(struct ranap_ue_conn_ctx *ue_ctx, uint8_t rab_id) -{ - /* FIXME */ - return -1; + msg = ranap_new_msg_rab_assign_data(rab_id, gtp_ip, gtp_tei, use_x213_nsap); + return sgsn_scu_iups_tx_data_req(ue_ctx->scu_iups, ue_ctx->conn_id, msg); } int ranap_iu_tx_sec_mode_cmd(struct ranap_ue_conn_ctx *uectx, struct osmo_auth_vector *vec, diff --git a/src/sgsn/mmctx.c b/src/sgsn/mmctx.c index 40f902b..3d3047f 100644 --- a/src/sgsn/mmctx.c +++ b/src/sgsn/mmctx.c @@ -608,3 +608,15 @@ return true; return false; } + +#if BUILD_IU +/* Send RAB activation requests for all PDP contexts */ +void sgsn_mm_ctx_iu_activate_rabs(struct sgsn_mm_ctx *ctx) +{ + struct sgsn_pdp_ctx *pdp; + OSMO_ASSERT(ctx->ran_type == MM_CTX_T_UTRAN_Iu); + + llist_for_each_entry(pdp, &ctx->pdp_list, list) + sgsn_pdp_ctx_iu_rab_activate(pdp, pdp->nsapi); +} +#endif diff --git a/src/sgsn/pdpctx.c b/src/sgsn/pdpctx.c index e779420..7806ada 100644 --- a/src/sgsn/pdpctx.c +++ b/src/sgsn/pdpctx.c @@ -19,6 +19,8 @@ * */ +#include "config.h" + #include <stdint.h> #include <osmocom/core/linuxlist.h> @@ -36,6 +38,7 @@ #include <osmocom/sgsn/gprs_llc_xid.h> #include <osmocom/sgsn/gprs_sndcp.h> #include <osmocom/sgsn/gprs_llc.h> +#include <osmocom/sgsn/gprs_ranap.h> #include <osmocom/sgsn/gprs_sm.h> #include <osmocom/sgsn/gtp.h> @@ -156,3 +159,36 @@ talloc_free(pdp); } + +#ifdef BUILD_IU +int sgsn_pdp_ctx_iu_rab_activate(struct sgsn_pdp_ctx *pdp, uint8_t rab_id) +{ + struct sgsn_mm_ctx *mm = pdp->mm; + struct ranap_ue_conn_ctx *ue_ctx; + uint32_t ggsn_ip; + + OSMO_ASSERT(mm->ran_type == MM_CTX_T_UTRAN_Iu); + ue_ctx = mm->iu.ue_ctx; + + /* Get the IP address for ggsn user plane */ + memcpy(&ggsn_ip, pdp->lib->gsnru.v, pdp->lib->gsnru.l); + ggsn_ip = htonl(ggsn_ip); + + LOGPDPCTXP(LOGL_INFO, pdp, "Activate RAB: rab_id=%u, ggsn_ip=%x, teid_gn=%x\n", + rab_id, ggsn_ip, pdp->lib->teid_gn); + + return sgsn_ranap_iu_tx_rab_ps_ass_req(ue_ctx, rab_id, ggsn_ip, pdp->lib->teid_gn); +} + +int sgsn_pdp_ctx_iu_rab_deactivate(struct sgsn_pdp_ctx *pdp, uint8_t rab_id) +{ + struct sgsn_mm_ctx *mm = pdp->mm; + + OSMO_ASSERT(mm->ran_type == MM_CTX_T_UTRAN_Iu); + + LOGPDPCTXP(LOGL_NOTICE, pdp, "Release RAB: rab_id=%u not supported!\n", rab_id); + //struct ranap_ue_conn_ctx *ue_ctx = mm->iu.ue_ctx; + // TODO: add new function similar to sgsn_ranap_iu_tx_rab_ps_ass_req() but requesting relese of RAB. + return -ENOTSUP; +} +#endif /* ifdef BUILD_IU */ diff --git a/src/sgsn/sgsn_libgtp.c b/src/sgsn/sgsn_libgtp.c index edfe250..e637967 100644 --- a/src/sgsn/sgsn_libgtp.c +++ b/src/sgsn/sgsn_libgtp.c @@ -439,7 +439,7 @@ } else if (pctx->mm->ran_type == MM_CTX_T_UTRAN_Iu) { #ifdef BUILD_IU /* Activate a radio bearer */ - iu_rab_act_ps(pdp->nsapi, pctx); + sgsn_pdp_ctx_iu_rab_activate(pctx, pdp->nsapi); return 0; #else return -ENOTSUP; @@ -564,7 +564,7 @@ } else { #ifdef BUILD_IU /* Deactivate radio bearer */ - ranap_iu_rab_deact(pctx->mm->iu.ue_ctx, 1); + sgsn_pdp_ctx_iu_rab_deactivate(pctx, 1); #else return -ENOTSUP; #endif -- To view, visit
https://gerrit.osmocom.org/c/osmo-sgsn/+/40961?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged Gerrit-Project: osmo-sgsn Gerrit-Branch: master Gerrit-Change-Id: I98788468b7e50619cfd99b3aef2311bb601fb6be Gerrit-Change-Number: 40961 Gerrit-PatchSet: 6 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: lynxis lazus <lynxis(a)fe80.eu>
2 weeks, 4 days
1
0
0
0
[M] Change in osmo-sgsn[master]: Split Iu RANAP conn release over different layers
by lynxis lazus
lynxis lazus has submitted this change. (
https://gerrit.osmocom.org/c/osmo-sgsn/+/40962?usp=email
) ( 2 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: Split Iu RANAP conn release over different layers ...................................................................... Split Iu RANAP conn release over different layers Move and rename functions acting on mmctx to mmctx.{c,h}. From there, call functions acting on ranap ue_ctx. Change-Id: I4acdbc857df36b7409c8210d364758192dfdb0bb --- M include/osmocom/sgsn/gprs_ranap.h M include/osmocom/sgsn/iu_client.h M include/osmocom/sgsn/mmctx.h M src/sgsn/gprs_gmm.c M src/sgsn/gprs_mm_state_iu_fsm.c M src/sgsn/gprs_ranap.c M src/sgsn/iu_client.c M src/sgsn/mmctx.c M src/sgsn/sccp.c 9 files changed, 54 insertions(+), 59 deletions(-) Approvals: lynxis lazus: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmocom/sgsn/gprs_ranap.h b/include/osmocom/sgsn/gprs_ranap.h index e2450bd..92b453d 100644 --- a/include/osmocom/sgsn/gprs_ranap.h +++ b/include/osmocom/sgsn/gprs_ranap.h @@ -28,18 +28,11 @@ int ranap_iu_tx_release(struct ranap_ue_conn_ctx *ctx, const struct RANAP_Cause *cause); /* Transmit a Iu Release Command and submit event RANAP_IU_EVENT_IU_RELEASE upon * Release Complete or timeout. Caller is responsible to free the context and - * closing the SCCP connection (ranap_iu_free_ue) upon recieval of the event. */ -void ranap_iu_tx_release_free(struct ranap_ue_conn_ctx *ctx, + * closing the SCCP connection (sgsn_ranap_iu_free_ue) upon recieval of the event. */ +void sgsn_ranap_iu_tx_release_free(struct ranap_ue_conn_ctx *ctx, const struct RANAP_Cause *cause, int timeout); -/* free the Iu UE context */ -void sgsn_ranap_iu_free(struct sgsn_mm_ctx *ctx); - -/* send a Iu Release Command and free afterwards the UE context */ -void sgsn_ranap_iu_release_free(struct sgsn_mm_ctx *ctx, - const struct RANAP_Cause *cause); - int sgsn_ranap_iu_rx_cl_msg(struct sgsn_sccp_user_iups *scu_iups, const struct osmo_scu_unitdata_param *ud_prim, const uint8_t *data, size_t len); @@ -49,10 +42,7 @@ const uint8_t *data, size_t len); int sgsn_ranap_iu_rx_co_msg(struct ranap_ue_conn_ctx *ue_ctx, const uint8_t *data, size_t len); -#else /* ifndef BUILD_IU */ -inline static void sgsn_ranap_iu_free(void *ctx) {}; -inline static void sgsn_ranap_iu_release_free(void *ctx, void *cause) {}; -#endif /* BUILD_IU*/ +#endif /* ifdef BUILD_IU */ struct ranap_ue_conn_ctx; /* On RANAP, Returns pointer to he associated ranap_ue_conn_ctx in msg, filled diff --git a/include/osmocom/sgsn/iu_client.h b/include/osmocom/sgsn/iu_client.h index 0dedba4..4e44f03 100644 --- a/include/osmocom/sgsn/iu_client.h +++ b/include/osmocom/sgsn/iu_client.h @@ -91,4 +91,4 @@ /* freeing the UE will release all resources * This will close the SCCP connection connected to the UE */ -void ranap_iu_free_ue(struct ranap_ue_conn_ctx *ue_ctx); +void sgsn_ranap_iu_free_ue(struct ranap_ue_conn_ctx *ue_ctx); diff --git a/include/osmocom/sgsn/mmctx.h b/include/osmocom/sgsn/mmctx.h index 8ee82e0..f1dca9b 100644 --- a/include/osmocom/sgsn/mmctx.h +++ b/include/osmocom/sgsn/mmctx.h @@ -293,5 +293,9 @@ void sgsn_update_subscriber_data(struct sgsn_mm_ctx *mmctx); #ifdef BUILD_IU +struct RANAP_Cause; void sgsn_mm_ctx_iu_activate_rabs(struct sgsn_mm_ctx *ctx); +void sgsn_mm_ctx_iu_ranap_release_free(struct sgsn_mm_ctx *ctx, + const struct RANAP_Cause *cause); +void sgsn_mm_ctx_iu_ranap_free(struct sgsn_mm_ctx *ctx); #endif /* ifdef BUILD_IU */ diff --git a/src/sgsn/gprs_gmm.c b/src/sgsn/gprs_gmm.c index a409660..f4d3d8b 100644 --- a/src/sgsn/gprs_gmm.c +++ b/src/sgsn/gprs_gmm.c @@ -1839,7 +1839,7 @@ #ifdef BUILD_IU else if (MSG_IU_UE_CTX(msg)) { unsigned long X1001 = osmo_tdef_get(sgsn->cfg.T_defs, -1001, OSMO_TDEF_S, -1); - ranap_iu_tx_release_free(MSG_IU_UE_CTX(msg), NULL, (int) X1001); + sgsn_ranap_iu_tx_release_free(MSG_IU_UE_CTX(msg), NULL, (int) X1001); } #endif diff --git a/src/sgsn/gprs_mm_state_iu_fsm.c b/src/sgsn/gprs_mm_state_iu_fsm.c index c426678..8c4cc46 100644 --- a/src/sgsn/gprs_mm_state_iu_fsm.c +++ b/src/sgsn/gprs_mm_state_iu_fsm.c @@ -95,12 +95,12 @@ switch(event) { case E_PMM_PS_CONN_RELEASE: - sgsn_ranap_iu_free(ctx); + sgsn_mm_ctx_iu_ranap_free(ctx); mm_state_iu_fsm_state_chg(fi, ST_PMM_IDLE); mmctx_change_gtpu_endpoints_to_sgsn(ctx, NULL); break; case E_PMM_PS_DETACH: - sgsn_ranap_iu_release_free(ctx, NULL); + sgsn_mm_ctx_iu_ranap_release_free(ctx, NULL); mm_state_iu_fsm_state_chg(fi, ST_PMM_DETACHED); break; case E_PMM_RA_UPDATE: @@ -108,7 +108,7 @@ case E_PMM_RX_GGSN_GTPU_DT_EI: /* GTPU Direct Tunnel (RNC<->GGSN): GGSN Received Error Indication when transmitting DL data*/ pctx = (struct sgsn_pdp_ctx *)data; - sgsn_ranap_iu_free(ctx); + sgsn_mm_ctx_iu_ranap_free(ctx); mm_state_iu_fsm_state_chg(fi, ST_PMM_IDLE); mmctx_change_gtpu_endpoints_to_sgsn(ctx, pctx); break; diff --git a/src/sgsn/gprs_ranap.c b/src/sgsn/gprs_ranap.c index 70f369d..e328414 100644 --- a/src/sgsn/gprs_ranap.c +++ b/src/sgsn/gprs_ranap.c @@ -100,7 +100,7 @@ pdp = sgsn_pdp_ctx_by_nsapi(ctx, rab_id); if (!pdp) { LOGP(DRANAP, LOGL_ERROR, "RAB Assignment Response for unknown RAB/NSAPI=%u\n", rab_id); - sgsn_ranap_iu_release_free(ctx, NULL); + sgsn_mm_ctx_iu_ranap_release_free(ctx, NULL); return -1; } @@ -184,7 +184,7 @@ if (!mm) { LOGIUP(ctx, LOGL_NOTICE, "Cannot find mm ctx for IU event %s\n", iu_client_event_type_str(type)); - ranap_iu_free_ue(ctx); + sgsn_ranap_iu_free_ue(ctx); return rc; } @@ -199,7 +199,7 @@ LOGMMCTXP(LOGL_INFO, mm, "IU release (cause=%s)\n", iu_client_event_type_str(type)); rc = osmo_fsm_inst_dispatch(mm->iu.mm_state_fsm, E_PMM_PS_CONN_RELEASE, NULL); if (rc < 0) - sgsn_ranap_iu_free(mm); + sgsn_mm_ctx_iu_ranap_free(mm); /* TODO: move this into FSM */ if (mm->ran_type == MM_CTX_T_UTRAN_Iu && mm->gmm_att_req.fsm->state != ST_INIT) @@ -257,37 +257,6 @@ } } -void sgsn_ranap_iu_free(struct sgsn_mm_ctx *ctx) -{ - if (!ctx) - return; - - if (!ctx->iu.ue_ctx) - return; - - ranap_iu_free_ue(ctx->iu.ue_ctx); - ctx->iu.ue_ctx = NULL; -} - -void sgsn_ranap_iu_release_free(struct sgsn_mm_ctx *ctx, - const struct RANAP_Cause *cause) -{ - unsigned long X1001; - - if (!ctx) - return; - - if (!ctx->iu.ue_ctx) - return; - - X1001 = osmo_tdef_get(sgsn->cfg.T_defs, -1001, OSMO_TDEF_S, -1); - - ranap_iu_tx_release_free(ctx->iu.ue_ctx, - cause, - (int) X1001); - ctx->iu.ue_ctx = NULL; -} - int sgsn_ranap_iu_tx_rab_ps_ass_req(struct ranap_ue_conn_ctx *ue_ctx, uint8_t rab_id, uint32_t gtp_ip, uint32_t gtp_tei) { @@ -378,9 +347,9 @@ return sgsn_scu_iups_tx_data_req(uectx->scu_iups, uectx->conn_id, msg); } -void ranap_iu_tx_release_free(struct ranap_ue_conn_ctx *ctx, - const struct RANAP_Cause *cause, - int timeout) +void sgsn_ranap_iu_tx_release_free(struct ranap_ue_conn_ctx *ctx, + const struct RANAP_Cause *cause, + int timeout) { ctx->notification = false; ctx->free_on_release = true; diff --git a/src/sgsn/iu_client.c b/src/sgsn/iu_client.c index 1f36129..950a264 100644 --- a/src/sgsn/iu_client.c +++ b/src/sgsn/iu_client.c @@ -95,7 +95,7 @@ return ctx; } -void ranap_iu_free_ue(struct ranap_ue_conn_ctx *ue_ctx) +void sgsn_ranap_iu_free_ue(struct ranap_ue_conn_ctx *ue_ctx) { if (!ue_ctx) return; diff --git a/src/sgsn/mmctx.c b/src/sgsn/mmctx.c index 3d3047f..0de0fc3 100644 --- a/src/sgsn/mmctx.c +++ b/src/sgsn/mmctx.c @@ -19,6 +19,8 @@ * */ +#include "config.h" + #include <stdint.h> #include <osmocom/core/linuxlist.h> @@ -51,6 +53,7 @@ #include <osmocom/sgsn/gprs_mm_state_iu_fsm.h> #include <osmocom/sgsn/gprs_gmm_fsm.h> #include <osmocom/sgsn/gprs_llc.h> +#include <osmocom/sgsn/gprs_ranap.h> #include <osmocom/sgsn/gprs_sndcp.h> #include <osmocom/sgsn/gtp_ggsn.h> #include <osmocom/sgsn/gtp.h> @@ -58,8 +61,6 @@ #include <time.h> -#include "../../config.h" - const struct value_string sgsn_ran_type_names[] = { { MM_CTX_T_GERAN_Gb, "GPRS/EDGE via Gb" }, { MM_CTX_T_UTRAN_Iu, "UMTS via Iu" }, @@ -619,4 +620,35 @@ llist_for_each_entry(pdp, &ctx->pdp_list, list) sgsn_pdp_ctx_iu_rab_activate(pdp, pdp->nsapi); } + +/* send a Iu Release Command and free afterwards the UE context */ +void sgsn_mm_ctx_iu_ranap_release_free(struct sgsn_mm_ctx *mmctx, + const struct RANAP_Cause *cause) +{ + unsigned long X1001; + + if (!mmctx) + return; + + if (!mmctx->iu.ue_ctx) + return; + + X1001 = osmo_tdef_get(sgsn->cfg.T_defs, -1001, OSMO_TDEF_S, -1); + + sgsn_ranap_iu_tx_release_free(mmctx->iu.ue_ctx, cause, (int) X1001); + mmctx->iu.ue_ctx = NULL; +} + +/* free the Iu UE context */ +void sgsn_mm_ctx_iu_ranap_free(struct sgsn_mm_ctx *mmctx) +{ + if (!mmctx) + return; + + if (!mmctx->iu.ue_ctx) + return; + + sgsn_ranap_iu_free_ue(mmctx->iu.ue_ctx); + mmctx->iu.ue_ctx = NULL; +} #endif diff --git a/src/sgsn/sccp.c b/src/sgsn/sccp.c index 291222f..24b06e7 100644 --- a/src/sgsn/sccp.c +++ b/src/sgsn/sccp.c @@ -155,7 +155,7 @@ if (!ue) return; if (ue->free_on_release) - ranap_iu_free_ue(ue); + sgsn_ranap_iu_free_ue(ue); } static void handle_notice_ind(struct sgsn_sccp_user_iups *scu_iups, const struct osmo_scu_notice_param *ni) -- To view, visit
https://gerrit.osmocom.org/c/osmo-sgsn/+/40962?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged Gerrit-Project: osmo-sgsn Gerrit-Branch: master Gerrit-Change-Id: I4acdbc857df36b7409c8210d364758192dfdb0bb Gerrit-Change-Number: 40962 Gerrit-PatchSet: 4 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: lynxis lazus <lynxis(a)fe80.eu>
2 weeks, 4 days
1
0
0
0
[XS] Change in osmo-sgsn[master]: iu_rnc: Use API osmo_sccp_addr_ri_cmp() to compare addresses
by lynxis lazus
lynxis lazus has submitted this change. (
https://gerrit.osmocom.org/c/osmo-sgsn/+/40971?usp=email
) ( 1 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: iu_rnc: Use API osmo_sccp_addr_ri_cmp() to compare addresses ...................................................................... iu_rnc: Use API osmo_sccp_addr_ri_cmp() to compare addresses Change-Id: I04fb37f28b52da9eecb1f8ea40c38ee3eced1c29 --- M src/sgsn/iu_rnc.c 1 file changed, 1 insertion(+), 8 deletions(-) Approvals: lynxis lazus: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/sgsn/iu_rnc.c b/src/sgsn/iu_rnc.c index 970f628..b1af9ba 100644 --- a/src/sgsn/iu_rnc.c +++ b/src/sgsn/iu_rnc.c @@ -98,13 +98,6 @@ return NULL; } -static bool same_sccp_addr(const struct osmo_sccp_addr *a, const struct osmo_sccp_addr *b) -{ - char buf[256]; - osmo_strlcpy(buf, osmo_sccp_addr_dump(a), sizeof(buf)); - return !strcmp(buf, osmo_sccp_addr_dump(b)); -} - static void global_iu_event_new_area(const struct osmo_rnc_id *rnc_id, const struct osmo_routing_area_id *rai) { struct ranap_iu_event_new_area new_area = (struct ranap_iu_event_new_area) { @@ -135,7 +128,7 @@ rnc = iu_rnc_id_find(rnc_id); if (rnc) { - if (!same_sccp_addr(&rnc->sccp_addr, addr)) { + if (!osmo_sccp_addr_ri_cmp(&rnc->sccp_addr, addr)) { LOGP(DRANAP, LOGL_NOTICE, "RNC %s changed its SCCP addr to %s (LAC/RAC %s)\n", osmo_rnc_id_name(rnc_id), osmo_sccp_addr_dump(addr), osmo_rai_name2(rai)); rnc->sccp_addr = *addr; -- To view, visit
https://gerrit.osmocom.org/c/osmo-sgsn/+/40971?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged Gerrit-Project: osmo-sgsn Gerrit-Branch: master Gerrit-Change-Id: I04fb37f28b52da9eecb1f8ea40c38ee3eced1c29 Gerrit-Change-Number: 40971 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: lynxis lazus <lynxis(a)fe80.eu>
2 weeks, 4 days
1
0
0
0
[S] Change in osmo-sgsn[master]: Apply uniform prefix to remaining APIs in gprs_ranap.h
by lynxis lazus
lynxis lazus has submitted this change. (
https://gerrit.osmocom.org/c/osmo-sgsn/+/40963?usp=email
) ( 2 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: Apply uniform prefix to remaining APIs in gprs_ranap.h ...................................................................... Apply uniform prefix to remaining APIs in gprs_ranap.h Change-Id: I4f253f35013085bdebf80e94ab0d2f771e40dba6 --- M include/osmocom/sgsn/gprs_ranap.h M src/sgsn/gprs_gmm.c M src/sgsn/gprs_gmm_attach.c M src/sgsn/gprs_ranap.c M src/sgsn/iu_client.c 5 files changed, 21 insertions(+), 21 deletions(-) Approvals: Jenkins Builder: Verified lynxis lazus: Looks good to me, approved diff --git a/include/osmocom/sgsn/gprs_ranap.h b/include/osmocom/sgsn/gprs_ranap.h index 92b453d..491ef6c 100644 --- a/include/osmocom/sgsn/gprs_ranap.h +++ b/include/osmocom/sgsn/gprs_ranap.h @@ -15,17 +15,17 @@ int sgsn_ranap_iu_event(struct ranap_ue_conn_ctx *ctx, enum ranap_iu_event_type type, void *data); -int ranap_iu_tx(struct msgb *msg, uint8_t sapi); +int sgsn_ranap_iu_tx(struct msgb *msg, uint8_t sapi); int sgsn_ranap_iu_tx_rab_ps_ass_req(struct ranap_ue_conn_ctx *ue_ctx, uint8_t rab_id, uint32_t gtp_ip, uint32_t gtp_tei); -int ranap_iu_tx_sec_mode_cmd(struct ranap_ue_conn_ctx *uectx, struct osmo_auth_vector *vec, +int sgsn_ranap_iu_tx_sec_mode_cmd(struct ranap_ue_conn_ctx *uectx, struct osmo_auth_vector *vec, int send_ck, int new_key); -int ranap_iu_tx_common_id(struct ranap_ue_conn_ctx *ue_ctx, const char *imsi); -int ranap_iu_tx_paging_cmd(struct osmo_sccp_addr *called_addr, +int sgsn_ranap_iu_tx_common_id(struct ranap_ue_conn_ctx *ue_ctx, const char *imsi); +int sgsn_ranap_iu_tx_paging_cmd(struct osmo_sccp_addr *called_addr, const char *imsi, const uint32_t *tmsi, bool is_ps, uint32_t paging_cause); -int ranap_iu_tx_release(struct ranap_ue_conn_ctx *ctx, const struct RANAP_Cause *cause); +int sgsn_ranap_iu_tx_release(struct ranap_ue_conn_ctx *ctx, const struct RANAP_Cause *cause); /* Transmit a Iu Release Command and submit event RANAP_IU_EVENT_IU_RELEASE upon * Release Complete or timeout. Caller is responsible to free the context and * closing the SCCP connection (sgsn_ranap_iu_free_ue) upon recieval of the event. */ diff --git a/src/sgsn/gprs_gmm.c b/src/sgsn/gprs_gmm.c index f4d3d8b..3d4b940 100644 --- a/src/sgsn/gprs_gmm.c +++ b/src/sgsn/gprs_gmm.c @@ -123,13 +123,13 @@ rate_ctr_inc(rate_ctr_group_get_ctr(mm->ctrg, GMM_CTR_PKTS_SIG_OUT)); #ifdef BUILD_IU if (mm->ran_type == MM_CTX_T_UTRAN_Iu) - return ranap_iu_tx(msg, GPRS_SAPI_GMM); + return sgsn_ranap_iu_tx(msg, GPRS_SAPI_GMM); #endif } #ifdef BUILD_IU if (MSG_IU_UE_CTX(msg)) - return ranap_iu_tx(msg, GPRS_SAPI_GMM); + return sgsn_ranap_iu_tx(msg, GPRS_SAPI_GMM); #endif /* caller needs to provide TLLI, BVCI and NSEI */ @@ -979,7 +979,7 @@ send_ck ? "sending" : "not sending", sgsn->cfg.uea_encryption_mask); /* FIXME: we should send the set of allowed UEA, as in ranap_new_msg_sec_mod_cmd2(). However, this * is not possible in the iu_client API. See OS#5487. */ - rc = ranap_iu_tx_sec_mode_cmd(ctx->iu.ue_ctx, &ctx->auth_triplet.vec, send_ck, ctx->iu.new_key); + rc = sgsn_ranap_iu_tx_sec_mode_cmd(ctx->iu.ue_ctx, &ctx->auth_triplet.vec, send_ck, ctx->iu.new_key); ctx->iu.new_key = 0; return rc; } @@ -1452,7 +1452,7 @@ #ifdef BUILD_IU if (mmctx->iu.ue_ctx) { - ranap_iu_tx_release(mmctx->iu.ue_ctx, NULL); + sgsn_ranap_iu_tx_release(mmctx->iu.ue_ctx, NULL); } #endif diff --git a/src/sgsn/gprs_gmm_attach.c b/src/sgsn/gprs_gmm_attach.c index 839ad83..3dc581d 100644 --- a/src/sgsn/gprs_gmm_attach.c +++ b/src/sgsn/gprs_gmm_attach.c @@ -277,7 +277,7 @@ /* FIXME: we should send the set of allowed UEA, as in ranap_new_msg_sec_mod_cmd2(). However, this * is not possible in the iu_client API. See OS#5487. */ - ranap_iu_tx_sec_mode_cmd(ctx->iu.ue_ctx, &ctx->auth_triplet.vec, send_ck, ctx->iu.new_key); + sgsn_ranap_iu_tx_sec_mode_cmd(ctx->iu.ue_ctx, &ctx->auth_triplet.vec, send_ck, ctx->iu.new_key); ctx->iu.new_key = 0; #endif } diff --git a/src/sgsn/gprs_ranap.c b/src/sgsn/gprs_ranap.c index e328414..15f5433 100644 --- a/src/sgsn/gprs_ranap.c +++ b/src/sgsn/gprs_ranap.c @@ -214,7 +214,7 @@ */ /* Continue authentication here */ mm->iu.ue_ctx->integrity_active = 1; - ranap_iu_tx_common_id(mm->iu.ue_ctx, mm->imsi); + sgsn_ranap_iu_tx_common_id(mm->iu.ue_ctx, mm->imsi); /* FIXME: remove gmm_authorize */ if (mm->pending_req != GSM48_MT_GMM_ATTACH_REQ) @@ -271,7 +271,7 @@ return sgsn_scu_iups_tx_data_req(ue_ctx->scu_iups, ue_ctx->conn_id, msg); } -int ranap_iu_tx_sec_mode_cmd(struct ranap_ue_conn_ctx *uectx, struct osmo_auth_vector *vec, +int sgsn_ranap_iu_tx_sec_mode_cmd(struct ranap_ue_conn_ctx *uectx, struct osmo_auth_vector *vec, int send_ck, int new_key) { struct msgb *msg; @@ -282,7 +282,7 @@ return sgsn_scu_iups_tx_data_req(uectx->scu_iups, uectx->conn_id, msg); } -int ranap_iu_tx_common_id(struct ranap_ue_conn_ctx *uectx, const char *imsi) +int sgsn_ranap_iu_tx_common_id(struct ranap_ue_conn_ctx *uectx, const char *imsi) { struct msgb *msg; @@ -299,7 +299,7 @@ * * If TMSI is given, the IMSI is not sent over the air interface. Nevertheless, * the IMSI is still required for resolution in the HNB-GW and/or(?) RNC. */ -int ranap_iu_tx_paging_cmd(struct osmo_sccp_addr *called_addr, +int sgsn_ranap_iu_tx_paging_cmd(struct osmo_sccp_addr *called_addr, const char *imsi, const uint32_t *tmsi, bool is_ps, uint32_t paging_cause) { @@ -309,7 +309,7 @@ return osmo_sccp_tx_unitdata_msg(sgsn->sccp.scu_iups->scu, &sgsn->sccp.scu_iups->local_sccp_addr, called_addr, msg); } -int ranap_iu_tx(struct msgb *msg_nas, uint8_t sapi) +int sgsn_ranap_iu_tx(struct msgb *msg_nas, uint8_t sapi) { struct ranap_ue_conn_ctx *uectx = msg_nas->dst; struct msgb *msg; @@ -332,7 +332,7 @@ /* Send Iu Release for the given UE connection. * If cause is NULL, Normal Release cause is sent, otherwise * the provided cause. */ -int ranap_iu_tx_release(struct ranap_ue_conn_ctx *uectx, const struct RANAP_Cause *cause) +int sgsn_ranap_iu_tx_release(struct ranap_ue_conn_ctx *uectx, const struct RANAP_Cause *cause) { struct msgb *msg; static const struct RANAP_Cause default_cause = { @@ -353,7 +353,7 @@ { ctx->notification = false; ctx->free_on_release = true; - int ret = ranap_iu_tx_release(ctx, cause); + int ret = sgsn_ranap_iu_tx_release(ctx, cause); /* On Tx failure, trigger timeout immediately, as the response will never arrive */ if (ret) timeout = 0; @@ -511,7 +511,7 @@ static int ranap_handle_co_iu_rel_req(struct ranap_ue_conn_ctx *ue_ctx, const RANAP_Iu_ReleaseRequestIEs_t *ies) { LOGP(DRANAP, LOGL_INFO, "Received Iu Release Request, Sending Release Command\n"); - ranap_iu_tx_release(ue_ctx, &ies->cause); + sgsn_ranap_iu_tx_release(ue_ctx, &ies->cause); return 0; } diff --git a/src/sgsn/iu_client.c b/src/sgsn/iu_client.c index 950a264..d392152 100644 --- a/src/sgsn/iu_client.c +++ b/src/sgsn/iu_client.c @@ -146,7 +146,7 @@ iu_rnc_lac_rac_find_legacy(&rnc, NULL, lac, rac); if (rnc) { - if (ranap_iu_tx_paging_cmd(&rnc->sccp_addr, imsi, tmsi_or_ptmsi, is_ps, 0) == 0) { + if (sgsn_ranap_iu_tx_paging_cmd(&rnc->sccp_addr, imsi, tmsi_or_ptmsi, is_ps, 0) == 0) { log_msg = "Paging"; log_level = LOGL_DEBUG; paged = 1; @@ -206,7 +206,7 @@ if (osmo_lai_cmp(&entry->rai.lac, lai)) continue; - rc = ranap_iu_tx_paging_cmd(&rnc->sccp_addr, imsi, tmsi, false, 0); + rc = sgsn_ranap_iu_tx_paging_cmd(&rnc->sccp_addr, imsi, tmsi, false, 0); if (rc > 0) { LOGPIU(LOGL_ERROR, "IuCS: Failed to tx Paging RNC %s for LAC %s for IMSI %s / TMSI %08x", osmo_rnc_id_name(&rnc->rnc_id), @@ -252,7 +252,7 @@ if (osmo_rai_cmp(&entry->rai, rai)) continue; - rc = ranap_iu_tx_paging_cmd(&rnc->sccp_addr, imsi, ptmsi, true, 0); + rc = sgsn_ranap_iu_tx_paging_cmd(&rnc->sccp_addr, imsi, ptmsi, true, 0); if (rc > 0) { LOGPIU(LOGL_ERROR, "IuPS: Failed to tx Paging RNC %s for RAC %s for IMSI %s / P-TMSI %08x", osmo_rnc_id_name(&rnc->rnc_id), -- To view, visit
https://gerrit.osmocom.org/c/osmo-sgsn/+/40963?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged Gerrit-Project: osmo-sgsn Gerrit-Branch: master Gerrit-Change-Id: I4f253f35013085bdebf80e94ab0d2f771e40dba6 Gerrit-Change-Number: 40963 Gerrit-PatchSet: 4 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: lynxis lazus <lynxis(a)fe80.eu>
2 weeks, 4 days
1
0
0
0
[S] Change in osmo-sgsn[master]: ranap: Reject InitialUE without RAC IE
by lynxis lazus
lynxis lazus has submitted this change. (
https://gerrit.osmocom.org/c/osmo-sgsn/+/40972?usp=email
) ( 1 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: ranap: Reject InitialUE without RAC IE ...................................................................... ranap: Reject InitialUE without RAC IE According to 3GPP TS 25.413 clauses 8.22.2 and 9.1.33, RAC IE is mandatory in PS domain. Change-Id: I7d6b996ddf1c5a7cde1bf06b500d3ed19c6090c6 --- M src/sgsn/gprs_ranap.c 1 file changed, 10 insertions(+), 9 deletions(-) Approvals: lynxis lazus: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/sgsn/gprs_ranap.c b/src/sgsn/gprs_ranap.c index 15f5433..0ddb959 100644 --- a/src/sgsn/gprs_ranap.c +++ b/src/sgsn/gprs_ranap.c @@ -379,15 +379,16 @@ return -1; } - if (ies->presenceMask & INITIALUE_MESSAGEIES_RANAP_RAC_PRESENT) { - ra_id.rac = asn1str_to_u8(&ies->rac); - if (ra_id.rac == OSMO_RESERVED_RAC) { - LOGP(DRANAP, LOGL_ERROR, - "Rejecting RNC with invalid/internally used RAC 0x%02x\n", ra_id.rac); - return -1; - } - } else { - ra_id.rac = OSMO_RESERVED_RAC; + if (!(ies->presenceMask & INITIALUE_MESSAGEIES_RANAP_RAC_PRESENT)) { + LOGP(DRANAP, LOGL_ERROR, "Rejecting InitialUE msg without RAC IE\n"); + return -1; + } + + ra_id.rac = asn1str_to_u8(&ies->rac); + if (ra_id.rac == OSMO_RESERVED_RAC) { + LOGP(DRANAP, LOGL_ERROR, + "Rejecting RNC with invalid/internally used RAC 0x%02x\n", ra_id.rac); + return -1; } if (iu_grnc_id_parse(&rnc_id, &ies->globalRNC_ID) != 0) { -- To view, visit
https://gerrit.osmocom.org/c/osmo-sgsn/+/40972?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged Gerrit-Project: osmo-sgsn Gerrit-Branch: master Gerrit-Change-Id: I7d6b996ddf1c5a7cde1bf06b500d3ed19c6090c6 Gerrit-Change-Number: 40972 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: lynxis lazus <lynxis(a)fe80.eu>
2 weeks, 4 days
1
0
0
0
[M] Change in osmo-sgsn[master]: iu_rnc: Split iu_rnc_register API into 2 steps
by lynxis lazus
lynxis lazus has submitted this change. (
https://gerrit.osmocom.org/c/osmo-sgsn/+/40973?usp=email
) ( 2 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: iu_rnc: Split iu_rnc_register API into 2 steps ...................................................................... iu_rnc: Split iu_rnc_register API into 2 steps Split lookup+allocation from RAI updating. This will be needed once we start creating iu_rnc objects upon SCCP rx RANAP RESET messages, which hold Global RNC-ID but no RAI information. Change-Id: I3761cc539c63a7ed680b04bb8136a43d397c10aa --- M include/osmocom/sgsn/iu_rnc.h M src/sgsn/gprs_ranap.c M src/sgsn/iu_rnc.c 3 files changed, 40 insertions(+), 35 deletions(-) Approvals: Jenkins Builder: Verified lynxis lazus: Looks good to me, approved diff --git a/include/osmocom/sgsn/iu_rnc.h b/include/osmocom/sgsn/iu_rnc.h index 895e922..344337d 100644 --- a/include/osmocom/sgsn/iu_rnc.h +++ b/include/osmocom/sgsn/iu_rnc.h @@ -30,6 +30,6 @@ struct llist_head lac_rac_list; }; -struct ranap_iu_rnc *iu_rnc_register(struct osmo_rnc_id *rnc_id, - const struct osmo_routing_area_id *rai, - const struct osmo_sccp_addr *addr); +struct ranap_iu_rnc *iu_rnc_find_or_create(const struct osmo_rnc_id *rnc_id, + const struct osmo_sccp_addr *addr); +void iu_rnc_update_rai_seen(struct ranap_iu_rnc *rnc, const struct osmo_routing_area_id *rai); diff --git a/src/sgsn/gprs_ranap.c b/src/sgsn/gprs_ranap.c index 0ddb959..38d3c34 100644 --- a/src/sgsn/gprs_ranap.c +++ b/src/sgsn/gprs_ranap.c @@ -404,7 +404,9 @@ gprs_rai_to_osmo(&ra_id2, &ra_id); /* Make sure we know the RNC Id and LAC+RAC coming in on this connection. */ - rnc = iu_rnc_register(&rnc_id, &ra_id2, rem_sccp_addr); + rnc = iu_rnc_find_or_create(&rnc_id, rem_sccp_addr); + OSMO_ASSERT(rnc); + iu_rnc_update_rai_seen(rnc, &ra_id2); ue = ue_conn_ctx_alloc(rnc, scu_iups, conn_id); OSMO_ASSERT(ue); diff --git a/src/sgsn/iu_rnc.c b/src/sgsn/iu_rnc.c index b1af9ba..8bb5bc1 100644 --- a/src/sgsn/iu_rnc.c +++ b/src/sgsn/iu_rnc.c @@ -60,6 +60,35 @@ return rnc; } +static struct ranap_iu_rnc *iu_rnc_find_by_id(const struct osmo_rnc_id *rnc_id) +{ + struct ranap_iu_rnc *rnc; + llist_for_each_entry(rnc, &sgsn->rnc_list, entry) { + if (!osmo_rnc_id_cmp(&rnc->rnc_id, rnc_id)) + return rnc; + } + return NULL; +} + +struct ranap_iu_rnc *iu_rnc_find_or_create(const struct osmo_rnc_id *rnc_id, + const struct osmo_sccp_addr *addr) +{ + struct ranap_iu_rnc *rnc; + + /* Make sure we know this rnc_id and that this SCCP address is in our records */ + rnc = iu_rnc_find_by_id(rnc_id); + if (rnc) { + if (!osmo_sccp_addr_ri_cmp(&rnc->sccp_addr, addr)) { + LOGP(DRANAP, LOGL_NOTICE, "RNC %s changed its SCCP addr to %s\n", + osmo_rnc_id_name(&rnc->rnc_id), osmo_sccp_addr_dump(addr)); + rnc->sccp_addr = *addr; + } + } else { + rnc = iu_rnc_alloc(rnc_id, addr); + } + return rnc; +} + /* Find a match for the given LAC (and RAC). For CS, pass rac as 0. * If rnc and lre pointers are not NULL, *rnc / *lre are set to NULL if no match is found, or to the * match if a match is found. Return true if a match is found. */ @@ -88,16 +117,6 @@ return false; } -static struct ranap_iu_rnc *iu_rnc_id_find(struct osmo_rnc_id *rnc_id) -{ - struct ranap_iu_rnc *rnc; - llist_for_each_entry(rnc, &sgsn->rnc_list, entry) { - if (!osmo_rnc_id_cmp(&rnc->rnc_id, rnc_id)) - return rnc; - } - return NULL; -} - static void global_iu_event_new_area(const struct osmo_rnc_id *rnc_id, const struct osmo_routing_area_id *rai) { struct ranap_iu_event_new_area new_area = (struct ranap_iu_event_new_area) { @@ -116,26 +135,12 @@ global_iu_event(NULL, RANAP_IU_EVENT_NEW_AREA, &new_area); } -struct ranap_iu_rnc *iu_rnc_register(struct osmo_rnc_id *rnc_id, - const struct osmo_routing_area_id *rai, - const struct osmo_sccp_addr *addr) + +void iu_rnc_update_rai_seen(struct ranap_iu_rnc *rnc, const struct osmo_routing_area_id *rai) { - struct ranap_iu_rnc *rnc; struct ranap_iu_rnc *old_rnc; struct iu_lac_rac_entry *lre; - /* Make sure we know this rnc_id and that this SCCP address is in our records */ - rnc = iu_rnc_id_find(rnc_id); - - if (rnc) { - if (!osmo_sccp_addr_ri_cmp(&rnc->sccp_addr, addr)) { - LOGP(DRANAP, LOGL_NOTICE, "RNC %s changed its SCCP addr to %s (LAC/RAC %s)\n", - osmo_rnc_id_name(rnc_id), osmo_sccp_addr_dump(addr), osmo_rai_name2(rai)); - rnc->sccp_addr = *addr; - } - } else - rnc = iu_rnc_alloc(rnc_id, addr); - /* Detect whether the LAC,RAC is already recorded in another RNC */ iu_rnc_lac_rac_find(&old_rnc, &lre, rai); @@ -149,17 +154,15 @@ llist_del(&lre->entry); llist_add(&lre->entry, &rnc->lac_rac_list); - global_iu_event_new_area(rnc_id, rai); + global_iu_event_new_area(&rnc->rnc_id, rai); } else if (!old_rnc) { /* LAC, RAC not recorded yet */ LOGP(DRANAP, LOGL_NOTICE, "RNC %s: new LAC/RAC %s\n", - osmo_rnc_id_name(rnc_id), osmo_rai_name2(rai)); + osmo_rnc_id_name(&rnc->rnc_id), osmo_rai_name2(rai)); lre = talloc_zero(rnc, struct iu_lac_rac_entry); lre->rai = *rai; llist_add(&lre->entry, &rnc->lac_rac_list); - global_iu_event_new_area(rnc_id, rai); + global_iu_event_new_area(&rnc->rnc_id, rai); } /* else, LAC,RAC already recorded with the current RNC. */ - - return rnc; } -- To view, visit
https://gerrit.osmocom.org/c/osmo-sgsn/+/40973?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged Gerrit-Project: osmo-sgsn Gerrit-Branch: master Gerrit-Change-Id: I3761cc539c63a7ed680b04bb8136a43d397c10aa Gerrit-Change-Number: 40973 Gerrit-PatchSet: 3 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: lynxis lazus <lynxis(a)fe80.eu>
2 weeks, 4 days
1
0
0
0
← Newer
1
...
81
82
83
84
85
86
87
...
100
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
Results per page:
10
25
50
100
200