change return type of page_subscriber() to void

We deliberately ignore errors from page_subscriber() so there is
no point in having a non-void return value.
Provide more context in the error message logged if paging failed.

Add a comment in an implementation override of base_grace_paging_request()
in the test suite to make return value semantics more clear.

Change-Id: Ie18c2ba53d2055d3eaff8c9ed939eb844af6dd2e
Related: I48f5efbcddd98e15256edfca06ba0ae6acb5bab1
This commit is contained in:
Stefan Sperling 2018-03-27 13:22:06 +02:00
parent ecb0308e74
commit a8eafef966
2 changed files with 12 additions and 21 deletions

View File

@ -237,46 +237,42 @@ static int bssmap_handle_reset(struct bsc_msc_data *msc,
/* Page a subscriber based on TMSI and LAC via the specified BTS. /* Page a subscriber based on TMSI and LAC via the specified BTS.
* The msc parameter is the MSC which issued the corresponding paging request. * The msc parameter is the MSC which issued the corresponding paging request.
* Returns 1 if the paging request could be issued, 0 if not. * Log an error if paging failed. */
* A negative return value indicates an error. */ static void
static int
page_subscriber(struct bsc_msc_data *msc, struct gsm_bts *bts, page_subscriber(struct bsc_msc_data *msc, struct gsm_bts *bts,
uint32_t tmsi, uint32_t lac, const char *mi_string, uint8_t chan_needed) uint32_t tmsi, uint32_t lac, const char *mi_string, uint8_t chan_needed)
{ {
struct bsc_subscr *subscr; struct bsc_subscr *subscr;
int ret; int ret;
LOGP(DMSC, LOGL_INFO, "Paging request from MSC BTS: %d IMSI: '%s' TMSI: '0x%x/%u' LAC: 0x%x\n",
bts->nr, mi_string, tmsi, tmsi, lac);
subscr = bsc_subscr_find_or_create_by_imsi(msc->network->bsc_subscribers, subscr = bsc_subscr_find_or_create_by_imsi(msc->network->bsc_subscribers,
mi_string); mi_string);
if (!subscr) { if (!subscr) {
LOGP(DMSC, LOGL_ERROR, "Failed to allocate a subscriber for %s\n", mi_string); LOGP(DMSC, LOGL_ERROR, "Paging request failed: Could not allocate subscriber for %s\n", mi_string);
return -1; return;
} }
subscr->lac = lac; subscr->lac = lac;
subscr->tmsi = tmsi; subscr->tmsi = tmsi;
LOGP(DMSC, LOGL_INFO, "Paging request from MSC BTS: %d IMSI: '%s' TMSI: '0x%x/%u' LAC: 0x%x\n",
bts->nr, mi_string, tmsi, tmsi, lac);
ret = bsc_grace_paging_request(msc->network->bsc_data->rf_ctrl->policy, subscr, chan_needed, msc, bts); ret = bsc_grace_paging_request(msc->network->bsc_data->rf_ctrl->policy, subscr, chan_needed, msc, bts);
if (!ret) if (ret == 0)
LOGP(DMSC, LOGL_ERROR, "Paging request not handled!\n"); LOGP(DMSC, LOGL_ERROR, "Paging request failed: BTS: %d IMSI: '%s' TMSI: '0x%x/%u' LAC: 0x%x\n",
bts->nr, mi_string, tmsi, tmsi, lac);
/* the paging code has grabbed its own references */ /* the paging code has grabbed its own references */
bsc_subscr_put(subscr); bsc_subscr_put(subscr);
return ret;
} }
static void static void
page_all_bts(struct bsc_msc_data *msc, uint32_t tmsi, const char *mi_string, uint8_t chan_needed) page_all_bts(struct bsc_msc_data *msc, uint32_t tmsi, const char *mi_string, uint8_t chan_needed)
{ {
struct gsm_bts *bts; struct gsm_bts *bts;
llist_for_each_entry(bts, &msc->network->bts_list, list) { llist_for_each_entry(bts, &msc->network->bts_list, list)
/* ignore errors from page_subscriber(); try all BTS */
page_subscriber(msc, bts, tmsi, GSM_LAC_RESERVED_ALL_BTS, mi_string, chan_needed); page_subscriber(msc, bts, tmsi, GSM_LAC_RESERVED_ALL_BTS, mi_string, chan_needed);
}
} }
static void static void
@ -294,7 +290,6 @@ page_cgi(struct bsc_msc_data *msc, struct gsm0808_cell_id_list2 *cil,
continue; continue;
if (bts->cell_identity != id->cell_identity) if (bts->cell_identity != id->cell_identity)
continue; continue;
/* ignore errors from page_subscriber(); keep trying other BTS */
page_subscriber(msc, bts, tmsi, id->lai.lac, mi_string, chan_needed); page_subscriber(msc, bts, tmsi, id->lai.lac, mi_string, chan_needed);
paged = 1; paged = 1;
} }
@ -326,7 +321,6 @@ page_lac_and_ci(struct bsc_msc_data *msc, struct gsm0808_cell_id_list2 *cil,
continue; continue;
if (bts->cell_identity != id->ci) if (bts->cell_identity != id->ci)
continue; continue;
/* ignore errors from page_subscriber(); keep trying other BTS */
page_subscriber(msc, bts, tmsi, id->lac, mi_string, chan_needed); page_subscriber(msc, bts, tmsi, id->lac, mi_string, chan_needed);
paged = 1; paged = 1;
} }
@ -350,7 +344,6 @@ page_ci(struct bsc_msc_data *msc, struct gsm0808_cell_id_list2 *cil,
llist_for_each_entry(bts, &msc->network->bts_list, list) { llist_for_each_entry(bts, &msc->network->bts_list, list) {
if (bts->cell_identity != ci) if (bts->cell_identity != ci)
continue; continue;
/* ignore errors from page_subscriber(); keep trying other BTS */
page_subscriber(msc, bts, tmsi, GSM_LAC_RESERVED_ALL_BTS, mi_string, chan_needed); page_subscriber(msc, bts, tmsi, GSM_LAC_RESERVED_ALL_BTS, mi_string, chan_needed);
paged = 1; paged = 1;
} }
@ -375,7 +368,6 @@ page_lai_and_lac(struct bsc_msc_data *msc, struct gsm0808_cell_id_list2 *cil,
llist_for_each_entry(bts, &msc->network->bts_list, list) { llist_for_each_entry(bts, &msc->network->bts_list, list) {
if (bts->location_area_code != id->lac) if (bts->location_area_code != id->lac)
continue; continue;
/* ignore errors from page_subscriber(); keep trying other BTS */
page_subscriber(msc, bts, tmsi, id->lac, mi_string, chan_needed); page_subscriber(msc, bts, tmsi, id->lac, mi_string, chan_needed);
paged = 1; paged = 1;
} }
@ -405,7 +397,6 @@ page_lac(struct bsc_msc_data *msc, struct gsm0808_cell_id_list2 *cil,
llist_for_each_entry(bts, &msc->network->bts_list, list) { llist_for_each_entry(bts, &msc->network->bts_list, list) {
if (bts->location_area_code != lac) if (bts->location_area_code != lac)
continue; continue;
/* ignore errors from page_subscriber(); keep trying other BTS */
page_subscriber(msc, bts, tmsi, lac, mi_string, chan_needed); page_subscriber(msc, bts, tmsi, lac, mi_string, chan_needed);
paged = 1; paged = 1;
} }

View File

@ -50,7 +50,7 @@ int __wrap_bsc_grace_paging_request(enum signal_rf rf_policy, struct bsc_subscr
else else
fprintf(stderr, "BSC paging started with LAC %u\n", subscr->lac); fprintf(stderr, "BSC paging started with LAC %u\n", subscr->lac);
OSMO_ASSERT(gl_expect_lac == subscr->lac); OSMO_ASSERT(gl_expect_lac == subscr->lac);
return 1; return 1; /* pretend one BTS was paged */
} }
struct { struct {