From 2556ed1bbbabd52a22f70121363264f0ff87cf0c Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Tue, 9 Jan 2018 23:48:25 +0100 Subject: associate conn with bsc subscriber where possible (TODO) 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 --- src/libbsc/bsc_api.c | 5 +++++ src/libbsc/bsc_subscriber.c | 5 ++--- src/libbsc/paging.c | 1 + src/osmo-bsc/osmo_bsc_api.c | 7 +++++++ 4 files changed, 15 insertions(+), 3 deletions(-) (limited to 'src') 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 #include +#include #include #include @@ -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); -- cgit v1.2.3