aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2018-01-09 23:48:25 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2018-03-07 16:39:01 +0100
commit2556ed1bbbabd52a22f70121363264f0ff87cf0c (patch)
tree4b649f2ce21f72fc6ee7afa56d8029357757e06d
parentf93970b167aba2805cc67e1326591f31fbe93ada (diff)
associate conn with bsc subscriber where possible (TODO)neels/ho2
Various logging in the code (e.g. handover) attempts to log the subscriber information from conn->bsub, but so far, the only time we set conn->bsub is during paging. We do though get IMSI and/or TMSI information from Layer 3 Complete messaging, not only from the Paging Request, which is already used for IMSI filtering. Also extract TMSI and create a conn->bsub subscriber. <-- TODO Make sure conn->bsub also gets cleaned up by bsc_subscr_put() when the conn is freed. Change-Id: Icc20c141ec339385181949b93548a73121bb7615
-rw-r--r--src/libbsc/bsc_api.c5
-rw-r--r--src/libbsc/bsc_subscriber.c5
-rw-r--r--src/libbsc/paging.c1
-rw-r--r--src/osmo-bsc/osmo_bsc_api.c7
-rw-r--r--tests/handover/handover_test.c8
-rw-r--r--tests/subscr/bsc_subscr_test.err3
6 files changed, 26 insertions, 3 deletions
diff --git a/src/libbsc/bsc_api.c b/src/libbsc/bsc_api.c
index d792b5899..affc78273 100644
--- a/src/libbsc/bsc_api.c
+++ b/src/libbsc/bsc_api.c
@@ -354,6 +354,11 @@ void bsc_subscr_con_free(struct gsm_subscriber_connection *conn)
penalty_timers_free(&conn->hodec2.penalty_timers);
+ if (conn->bsub) {
+ bsc_subscr_put(conn->bsub);
+ conn->bsub = NULL;
+ }
+
llist_del(&conn->entry);
talloc_free(conn);
}
diff --git a/src/libbsc/bsc_subscriber.c b/src/libbsc/bsc_subscriber.c
index d9d90baa9..65a660b40 100644
--- a/src/libbsc/bsc_subscriber.c
+++ b/src/libbsc/bsc_subscriber.c
@@ -41,7 +41,6 @@ static struct bsc_subscr *bsc_subscr_alloc(struct llist_head *list)
return NULL;
llist_add_tail(&bsub->entry, list);
- bsub->use_count = 1;
return bsub;
}
@@ -92,7 +91,7 @@ struct bsc_subscr *bsc_subscr_find_or_create_by_imsi(struct llist_head *list,
return bsub;
bsub = bsc_subscr_alloc(list);
bsc_subscr_set_imsi(bsub, imsi);
- return bsub;
+ return bsc_subscr_get(bsub);
}
struct bsc_subscr *bsc_subscr_find_or_create_by_tmsi(struct llist_head *list,
@@ -104,7 +103,7 @@ struct bsc_subscr *bsc_subscr_find_or_create_by_tmsi(struct llist_head *list,
return bsub;
bsub = bsc_subscr_alloc(list);
bsub->tmsi = tmsi;
- return bsub;
+ return bsc_subscr_get(bsub);
}
const char *bsc_subscr_name(struct bsc_subscr *bsub)
diff --git a/src/libbsc/paging.c b/src/libbsc/paging.c
index 43532d1a8..131064e63 100644
--- a/src/libbsc/paging.c
+++ b/src/libbsc/paging.c
@@ -386,6 +386,7 @@ void paging_request_stop(struct llist_head *bts_list,
struct gsm_bts *bts;
log_set_context(LOG_CTX_BSC_SUBSCR, bsub);
+ conn->bsub = bsc_subscr_get(bsub);
/* Stop this first and dispatch the request */
if (_bts) {
diff --git a/src/osmo-bsc/osmo_bsc_api.c b/src/osmo-bsc/osmo_bsc_api.c
index 75dae1293..075dff928 100644
--- a/src/osmo-bsc/osmo_bsc_api.c
+++ b/src/osmo-bsc/osmo_bsc_api.c
@@ -19,6 +19,7 @@
#include <osmocom/bsc/osmo_bsc.h>
#include <osmocom/bsc/bsc_msc_data.h>
+#include <osmocom/bsc/bsc_subscriber.h>
#include <osmocom/bsc/debug.h>
#include <osmocom/bsc/gsm_04_80.h>
@@ -249,6 +250,12 @@ static int complete_layer3(struct gsm_subscriber_connection *conn,
return BSC_API_CONN_POL_REJECT;
}
+ /* TODO: also extract TMSI. We get an IMSI is only because the filtering functions extract the
+ * IMSI to filter by IMSI. A TMSI identity is never returned here, see e.g. _cr_check_loc_upd()
+ * and other similar functions called from bsc_msg_filter_initial(). */
+ if (imsi)
+ conn->bsub = bsc_subscr_find_or_create_by_imsi(msc->network->bsc_subscribers, imsi);
+
/* allocate resource for a new connection */
//ret = bsc_create_new_connection(conn, msc, send_ping);
ret = osmo_bsc_sigtran_new_conn(conn, msc);
diff --git a/tests/handover/handover_test.c b/tests/handover/handover_test.c
index 8ba97fd8e..4d2afda84 100644
--- a/tests/handover/handover_test.c
+++ b/tests/handover/handover_test.c
@@ -186,7 +186,15 @@ static struct gsm_bts *create_bts(int arfcn)
void create_conn(struct gsm_lchan *lchan)
{
+ static unsigned int next_imsi = 0;
+ struct gsm_network *net = lchan->ts->trx->bts->network;
+ char imsi[sizeof(lchan->conn->bsub->imsi)];
+
+ next_imsi ++;
+ snprintf(imsi, sizeof(imsi), "%06u", next_imsi);
+
lchan->conn = bsc_subscr_con_allocate(lchan);
+ lchan->conn->bsub = bsc_subscr_find_or_create_by_imsi(net->bsc_subscribers, imsi);
}
/* create lchan */
diff --git a/tests/subscr/bsc_subscr_test.err b/tests/subscr/bsc_subscr_test.err
index a66317a36..afc8bf778 100644
--- a/tests/subscr/bsc_subscr_test.err
+++ b/tests/subscr/bsc_subscr_test.err
@@ -1,5 +1,8 @@
+DREF BSC subscr IMSI:1234567890 usage increases to: 1
DREF BSC subscr IMSI:1234567890 usage increases to: 2
DREF BSC subscr IMSI:1234567890 usage decreases to: 1
+DREF BSC subscr IMSI:9876543210 usage increases to: 1
+DREF BSC subscr IMSI:5656565656 usage increases to: 1
DREF BSC subscr IMSI:1234567890 usage increases to: 2
DREF BSC subscr IMSI:1234567890 usage decreases to: 1
DREF BSC subscr IMSI:9876543210 usage increases to: 2