aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo-bsc
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2020-09-18 04:02:13 +0200
committerNeels Hofmeyr <neels@hofmeyr.de>2020-10-07 11:40:12 +0000
commit4c5fd38b3b8fc9c351e2e7a929bcb6da10a28fc6 (patch)
treec7998fe22ac8e749eb2817376c13d13a89880a9b /src/osmo-bsc
parent86ce105038275f8e32a4bcdd55ed4f1aa225615a (diff)
refactor paging: add bsc_subscr to bsc_paging_params
Get a bsub once at start of paging. Change-Id: I13621cd51d934846ff6556e1f2f8839da73a5dbb
Diffstat (limited to 'src/osmo-bsc')
-rw-r--r--src/osmo-bsc/osmo_bsc_bssap.c33
-rw-r--r--src/osmo-bsc/paging.c10
2 files changed, 19 insertions, 24 deletions
diff --git a/src/osmo-bsc/osmo_bsc_bssap.c b/src/osmo-bsc/osmo_bsc_bssap.c
index ad501222f..2665a9be4 100644
--- a/src/osmo-bsc/osmo_bsc_bssap.c
+++ b/src/osmo-bsc/osmo_bsc_bssap.c
@@ -117,7 +117,6 @@ static int bssmap_handle_reset(struct bsc_msc_data *msc,
static void
page_subscriber(const struct bsc_paging_params *params, struct gsm_bts *bts, uint32_t lac)
{
- struct bsc_subscr *subscr;
int ret;
if (!bsc_grace_allow_new_connection(bsc_gsmnet, bts)) {
@@ -125,29 +124,12 @@ page_subscriber(const struct bsc_paging_params *params, struct gsm_bts *bts, uin
return;
}
- subscr = bsc_subscr_find_or_create_by_mi(bsc_gsmnet->bsc_subscribers, &params->imsi);
-
- if (subscr)
- log_set_context(LOG_CTX_BSC_SUBSCR, subscr);
-
LOG_PAGING_BTS(params, bts, DMSC, LOGL_INFO, "Paging on LAC %u\n", lac);
- if (!subscr) {
- LOGP(DMSC, LOGL_ERROR, "Paging request failed: Could not allocate subscriber for %s\n",
- osmo_mobile_identity_to_str_c(OTC_SELECT, &params->imsi));
- return;
- }
-
- subscr->tmsi = params->tmsi;
- ret = paging_request_bts(params, subscr, bts);
+ ret = paging_request_bts(params, bts);
if (ret == 0)
LOG_PAGING_BTS(params, bts, DMSC, LOGL_INFO,
"Paging request failed, or repeated paging on LAC %u\n", lac);
-
- /* the paging code has grabbed its own references */
- bsc_subscr_put(subscr);
-
- log_set_context(LOG_CTX_BSC_SUBSCR, NULL);
}
static void
@@ -363,6 +345,17 @@ int bsc_paging_start(struct bsc_paging_params *params)
{
rate_ctr_inc(&bsc_gsmnet->bsc_ctrs->ctr[BSC_CTR_PAGING_ATTEMPTED]);
+ if (!params->bsub) {
+ params->bsub = bsc_subscr_find_or_create_by_imsi(bsc_gsmnet->bsc_subscribers, params->imsi.imsi);
+ if (!params->bsub) {
+ LOG_PAGING(params, DMSC, LOGL_ERROR, "Paging request failed: Could not allocate subscriber\n");
+ return -EINVAL;
+ }
+ }
+ if (params->tmsi != GSM_RESERVED_TMSI)
+ params->bsub->tmsi = params->tmsi;
+ log_set_context(LOG_CTX_BSC_SUBSCR, params->bsub);
+
switch (params->cil.id_discr) {
case CELL_IDENT_NO_CELL:
page_all_bts(params);
@@ -400,6 +393,8 @@ int bsc_paging_start(struct bsc_paging_params *params)
break;
}
+ bsc_subscr_put(params->bsub);
+ log_set_context(LOG_CTX_BSC_SUBSCR, NULL);
return 0;
}
diff --git a/src/osmo-bsc/paging.c b/src/osmo-bsc/paging.c
index 186904253..d026a2055 100644
--- a/src/osmo-bsc/paging.c
+++ b/src/osmo-bsc/paging.c
@@ -325,7 +325,7 @@ static unsigned int calculate_timer_3113(struct gsm_bts *bts)
* \param[in] type type of radio channel we're requirign
* \param[in] msc MSC which has issue this paging
* \returns 0 on success, negative on error */
-static int _paging_request(const struct bsc_paging_params *params, struct bsc_subscr *bsub, struct gsm_bts *bts)
+static int _paging_request(const struct bsc_paging_params *params, struct gsm_bts *bts)
{
struct gsm_bts_paging_state *bts_entry = &bts->paging;
struct gsm_paging_request *req;
@@ -333,7 +333,7 @@ static int _paging_request(const struct bsc_paging_params *params, struct bsc_su
rate_ctr_inc(&bts->bts_ctrs->ctr[BTS_CTR_PAGING_ATTEMPTED]);
- if (paging_pending_request(bts_entry, bsub)) {
+ if (paging_pending_request(bts_entry, params->bsub)) {
LOG_PAGING_BTS(params, bts, DPAG, LOGL_INFO, "Paging request already pending for this subscriber\n");
rate_ctr_inc(&bts->bts_ctrs->ctr[BTS_CTR_PAGING_ALREADY]);
return -EEXIST;
@@ -342,7 +342,7 @@ static int _paging_request(const struct bsc_paging_params *params, struct bsc_su
LOG_PAGING_BTS(params, bts, DPAG, LOGL_DEBUG, "Start paging\n");
req = talloc_zero(tall_paging_ctx, struct gsm_paging_request);
OSMO_ASSERT(req);
- req->bsub = bsc_subscr_get(bsub);
+ req->bsub = bsc_subscr_get(params->bsub);
req->bts = bts;
req->chan_type = params->chan_needed;
req->msc = params->msc;
@@ -361,7 +361,7 @@ static int _paging_request(const struct bsc_paging_params *params, struct bsc_su
* \param[in] type type of radio channel we're requirign
* \param[in] msc MSC which has issue this paging
* returns 1 on success; 0 in case of error (e.g. TRX down) */
-int paging_request_bts(const struct bsc_paging_params *params, struct bsc_subscr *bsub, struct gsm_bts *bts)
+int paging_request_bts(const struct bsc_paging_params *params, struct gsm_bts *bts)
{
int rc;
@@ -373,7 +373,7 @@ int paging_request_bts(const struct bsc_paging_params *params, struct bsc_subscr
paging_init_if_needed(bts);
/* Trigger paging, pass any error to the caller */
- rc = _paging_request(params, bsub, bts);
+ rc = _paging_request(params, bts);
if (rc < 0)
return 0;
return 1;