pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-sgsn/+/40984?usp=email )
Change subject: Store scu_iups in iu_rnc instead of ue_ctx ......................................................................
Store scu_iups in iu_rnc instead of ue_ctx
All the ue_ctx belong to a given peer RNC, which holds the SCCP User to talk to it.
Change-Id: I3969af765b7b0d1375b5e6ad8f3f2e9845f939ef --- M include/osmocom/sgsn/iu_client.h M include/osmocom/sgsn/iu_rnc.h M src/sgsn/gprs_ranap.c M src/sgsn/iu_client.c M src/sgsn/iu_rnc.c M src/sgsn/sccp.c 6 files changed, 21 insertions(+), 17 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-sgsn refs/changes/84/40984/1
diff --git a/include/osmocom/sgsn/iu_client.h b/include/osmocom/sgsn/iu_client.h index 4e44f03..e32084b 100644 --- a/include/osmocom/sgsn/iu_client.h +++ b/include/osmocom/sgsn/iu_client.h @@ -20,7 +20,6 @@ struct ranap_ue_conn_ctx { struct llist_head list; /* item in sgsn_sccp->ue_conn_ctx_list */ struct ranap_iu_rnc *rnc; - struct sgsn_sccp_user_iups *scu_iups; uint32_t conn_id; int integrity_active; struct gprs_ra_id ra_id; @@ -87,7 +86,7 @@ int ranap_iu_page_ps2(const char *imsi, const uint32_t *ptmsi, const struct osmo_routing_area_id *rai);
-struct ranap_ue_conn_ctx *ue_conn_ctx_alloc(struct ranap_iu_rnc *rnc, struct sgsn_sccp_user_iups *scu_iups, uint32_t conn_id); +struct ranap_ue_conn_ctx *ue_conn_ctx_alloc(struct ranap_iu_rnc *rnc, uint32_t conn_id);
/* freeing the UE will release all resources * This will close the SCCP connection connected to the UE */ diff --git a/include/osmocom/sgsn/iu_rnc.h b/include/osmocom/sgsn/iu_rnc.h index 344337d..55f716b 100644 --- a/include/osmocom/sgsn/iu_rnc.h +++ b/include/osmocom/sgsn/iu_rnc.h @@ -24,6 +24,7 @@ struct llist_head entry;
struct osmo_rnc_id rnc_id; + struct sgsn_sccp_user_iups *scu_iups; struct osmo_sccp_addr sccp_addr;
/* A list of struct iu_lac_rac_entry */ @@ -31,5 +32,6 @@ };
struct ranap_iu_rnc *iu_rnc_find_or_create(const struct osmo_rnc_id *rnc_id, + struct sgsn_sccp_user_iups *scu_iups, 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 d101a3e..d05cc7b 100644 --- a/src/sgsn/gprs_ranap.c +++ b/src/sgsn/gprs_ranap.c @@ -268,7 +268,7 @@ rab_id, gtp_ip, gtp_tei, use_x213_nsap);
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); + return sgsn_scu_iups_tx_data_req(ue_ctx->rnc->scu_iups, ue_ctx->conn_id, msg); }
int sgsn_ranap_iu_tx_sec_mode_cmd(struct ranap_ue_conn_ctx *uectx, struct osmo_auth_vector *vec, @@ -279,7 +279,7 @@ /* create RANAP message */ msg = ranap_new_msg_sec_mod_cmd(vec->ik, send_ck ? vec->ck : NULL, new_key ? RANAP_KeyStatus_new : RANAP_KeyStatus_old); - return sgsn_scu_iups_tx_data_req(uectx->scu_iups, uectx->conn_id, msg); + return sgsn_scu_iups_tx_data_req(uectx->rnc->scu_iups, uectx->conn_id, msg); }
int sgsn_ranap_iu_tx_common_id(struct ranap_ue_conn_ctx *uectx, const char *imsi) @@ -290,7 +290,7 @@ uectx->conn_id);
msg = ranap_new_msg_common_id(imsi); - return sgsn_scu_iups_tx_data_req(uectx->scu_iups, uectx->conn_id, msg); + 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 @@ -326,7 +326,7 @@ msg = ranap_new_msg_dt(sapi, msg_nas->data, msgb_length(msg_nas)); msgb_free(msg_nas);
- return sgsn_scu_iups_tx_data_req(uectx->scu_iups, uectx->conn_id, msg); + return sgsn_scu_iups_tx_data_req(uectx->rnc->scu_iups, uectx->conn_id, msg); }
/* Send CL RANAP message over SCCP: */ @@ -368,7 +368,7 @@ cause = &default_cause;
msg = ranap_new_msg_iu_rel_cmd(cause); - return sgsn_scu_iups_tx_data_req(uectx->scu_iups, uectx->conn_id, msg); + return sgsn_scu_iups_tx_data_req(uectx->rnc->scu_iups, uectx->conn_id, msg); }
void sgsn_ranap_iu_tx_release_free(struct ranap_ue_conn_ctx *ctx, @@ -428,11 +428,11 @@ 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_find_or_create(&rnc_id, rem_sccp_addr); + rnc = iu_rnc_find_or_create(&rnc_id, scu_iups, rem_sccp_addr); OSMO_ASSERT(rnc); iu_rnc_update_rai_seen(rnc, &ra_id2);
- ue = ue_conn_ctx_alloc(rnc, scu_iups, conn_id); + ue = ue_conn_ctx_alloc(rnc, conn_id); OSMO_ASSERT(ue); ue->ra_id = ra_id;
@@ -711,7 +711,7 @@ return sgsn_ranap_iu_tx_error_ind(scu_iups, &ud_prim->calling_addr, &cause); }
- rnc = iu_rnc_find_or_create(&rnc_id, &ud_prim->calling_addr); + rnc = iu_rnc_find_or_create(&rnc_id, scu_iups, &ud_prim->calling_addr); OSMO_ASSERT(rnc);
/* send reset response */ diff --git a/src/sgsn/iu_client.c b/src/sgsn/iu_client.c index d392152..21c0470 100644 --- a/src/sgsn/iu_client.c +++ b/src/sgsn/iu_client.c @@ -78,19 +78,18 @@ global_iu_event(ctx, RANAP_IU_EVENT_IU_RELEASE, NULL); }
-struct ranap_ue_conn_ctx *ue_conn_ctx_alloc(struct ranap_iu_rnc *rnc, struct sgsn_sccp_user_iups *scu_iups, uint32_t conn_id) +struct ranap_ue_conn_ctx *ue_conn_ctx_alloc(struct ranap_iu_rnc *rnc, uint32_t conn_id) { struct ranap_ue_conn_ctx *ctx = talloc_zero(sgsn, struct ranap_ue_conn_ctx);
ctx->rnc = rnc; - ctx->scu_iups = scu_iups; ctx->conn_id = conn_id; ctx->notification = true; ctx->free_on_release = false; osmo_timer_setup(&ctx->release_timeout, ue_conn_ctx_release_timeout_cb, ctx); - llist_add(&ctx->list, &scu_iups->ue_conn_ctx_list); + llist_add(&ctx->list, &rnc->scu_iups->ue_conn_ctx_list);
return ctx; } @@ -101,7 +100,7 @@ return;
osmo_timer_del(&ue_ctx->release_timeout); - osmo_sccp_tx_disconn(ue_ctx->scu_iups->scu, ue_ctx->conn_id, NULL, 0); + osmo_sccp_tx_disconn(ue_ctx->rnc->scu_iups->scu, ue_ctx->conn_id, NULL, 0); llist_del(&ue_ctx->list); talloc_free(ue_ctx); } diff --git a/src/sgsn/iu_rnc.c b/src/sgsn/iu_rnc.c index 8bb5bc1..36350ff 100644 --- a/src/sgsn/iu_rnc.c +++ b/src/sgsn/iu_rnc.c @@ -43,7 +43,9 @@ #include <osmocom/sgsn/sccp.h> #include <osmocom/sgsn/sgsn.h>
-static struct ranap_iu_rnc *iu_rnc_alloc(const struct osmo_rnc_id *rnc_id, const struct osmo_sccp_addr *addr) +static struct ranap_iu_rnc *iu_rnc_alloc(const struct osmo_rnc_id *rnc_id, + struct sgsn_sccp_user_iups *scu_iups, + const struct osmo_sccp_addr *addr) { struct ranap_iu_rnc *rnc = talloc_zero(sgsn, struct ranap_iu_rnc); OSMO_ASSERT(rnc); @@ -51,6 +53,7 @@ INIT_LLIST_HEAD(&rnc->lac_rac_list);
rnc->rnc_id = *rnc_id; + rnc->scu_iups = scu_iups; rnc->sccp_addr = *addr; llist_add(&rnc->entry, &sgsn->rnc_list);
@@ -71,6 +74,7 @@ }
struct ranap_iu_rnc *iu_rnc_find_or_create(const struct osmo_rnc_id *rnc_id, + struct sgsn_sccp_user_iups *scu_iups, const struct osmo_sccp_addr *addr) { struct ranap_iu_rnc *rnc; @@ -84,7 +88,7 @@ rnc->sccp_addr = *addr; } } else { - rnc = iu_rnc_alloc(rnc_id, addr); + rnc = iu_rnc_alloc(rnc_id, scu_iups, addr); } return rnc; } diff --git a/src/sgsn/sccp.c b/src/sgsn/sccp.c index b1291a3..1eed08a 100644 --- a/src/sgsn/sccp.c +++ b/src/sgsn/sccp.c @@ -150,7 +150,7 @@ global_iu_event(ue, RANAP_IU_EVENT_LINK_INVALIDATED, NULL);
/* A RANAP_IU_EVENT_LINK_INVALIDATED, can lead to a free */ - ue = ue_conn_ctx_find(ue->scu_iups, conn_id); + ue = ue_conn_ctx_find(ue->rnc->scu_iups, conn_id); if (!ue) return; if (ue->free_on_release)