aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2018-01-09 23:48:25 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2018-01-12 05:26:30 +0100
commit090dd141cb88607213068853592594ce2c6f8e1a (patch)
treec18dc54a137d46946b0738b81825990c83a8fd06
parenta642c872e4c05dc3d20a72a9f2656ba1b09a0ade (diff)
associate conn with bsc subscriber where possible (TODO)neels/ho_with_on_change_cb
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 7cbe129..337aa1d 100644
--- a/src/libbsc/bsc_api.c
+++ b/src/libbsc/bsc_api.c
@@ -349,6 +349,11 @@ void bsc_subscr_con_free(struct gsm_subscriber_connection *conn)
/* drop pending messages */
ho_dtap_cache_flush(conn, 0);
+ 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 d9d90ba..65a660b 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 314dfdd..d738c1b 100644
--- a/src/libbsc/paging.c
+++ b/src/libbsc/paging.c
@@ -424,6 +424,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 1caaeee..679ecd1 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>
@@ -265,6 +266,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 f7b408b..fedaf7d 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 a66317a..afc8bf7 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