recurring issue with OpenBSC

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.

Holger Hans Peter Freyther holger at freyther.de
Tue Dec 2 07:59:29 UTC 2014


On Sun, Nov 30, 2014 at 01:57:58PM -0600, Ciaby wrote:

> That would be great. Can you point me in the right direction? Which
> file/library is responsible for that?
> Cheers

Hi,

something like the below would be a start. You could add a VTY
command to dump the queue including the state and the reason
string. And also show the last reason as this shows the item
that is currently being dispatched.

Going through the "FIXME"/HACKs notes. Depending on how much
time/budget you have this whole code could be cleaned up. In
real systems the voice and SMS services are independent. They
shouldn't share the same "queue".. but I am drifting away.


diff --git a/openbsc/include/openbsc/gsm_subscriber.h b/openbsc/include/openbsc/gsm_subscriber.h
index 7e0a419..207c010 100644
--- a/openbsc/include/openbsc/gsm_subscriber.h
+++ b/openbsc/include/openbsc/gsm_subscriber.h
@@ -60,6 +60,9 @@ struct gsm_subscriber {
 
 	/* GPRS/SGSN related fields */
 	struct sgsn_mm_ctx *mm;
+
+	/* debugging */
+	const char *last_reason;
 };
 
 enum gsm_subscriber_field {
@@ -92,7 +95,7 @@ struct gsm_subscriber *subscr_get_or_create(struct gsm_network *net,
 int subscr_update(struct gsm_subscriber *s, struct gsm_bts *bts, int reason);
 void subscr_put_channel(struct gsm_subscriber *subscr);
 void subscr_get_channel(struct gsm_subscriber *subscr,
-                        int type, gsm_cbfn *cbfn, void *param);
+                        int type, gsm_cbfn *cbfn, void *param, const char *reason);
 struct gsm_subscriber *subscr_active_by_tmsi(struct gsm_network *net,
 					     uint32_t tmsi);
 struct gsm_subscriber *subscr_active_by_imsi(struct gsm_network *net,
@@ -114,4 +117,38 @@ int subscr_update_expire_lu(struct gsm_subscriber *subscr, struct gsm_bts *bts);
 struct gsm_subscriber *subscr_alloc(void);
 extern struct llist_head active_subscribers;
 
+/*
+ * Struct for pending channel requests. This is managed in the
+ * llist_head requests of each subscriber. The reference counting
+ * should work in such a way that a subscriber with a pending request
+ * remains in memory.
+ */
+struct subscr_request {
+	struct llist_head entry;
+
+	/* back reference */
+	struct gsm_subscriber *subscr;
+
+	/* the requested channel type */
+	int channel_type;
+
+	/* what did we do */
+	int state;
+
+	/* the callback data */
+	gsm_cbfn *cbfn;
+	void *param;
+
+	/* debugging */
+	const char *reason;
+};
+
+enum {
+	REQ_STATE_INITIAL,
+	REQ_STATE_QUEUED,
+	REQ_STATE_PAGED,
+	REQ_STATE_FAILED_START,
+	REQ_STATE_DISPATCHED,
+};
+
 #endif /* _GSM_SUBSCR_H */
diff --git a/openbsc/src/libbsc/bsc_ctrl_commands.c b/openbsc/src/libbsc/bsc_ctrl_commands.c
index 7c8636c..a806670 100644
--- a/openbsc/src/libbsc/bsc_ctrl_commands.c
+++ b/openbsc/src/libbsc/bsc_ctrl_commands.c
@@ -237,7 +237,6 @@ static int verify_trx_max_power(struct ctrl_cmd *cmd, const char *value, void *_
 
 	return 0;
 }
-CTRL_CMD_DEFINE_RANGE(trx_arfcn, "arfcn", struct gsm_bts_trx, arfcn, 0, 1023);
 
 static int set_trx_max_power(struct ctrl_cmd *cmd, void *_data)
 {
@@ -259,6 +258,7 @@ static int set_trx_max_power(struct ctrl_cmd *cmd, void *_data)
 	return get_trx_max_power(cmd, _data);
 }
 CTRL_CMD_DEFINE(trx_max_power, "max-power-reduction");
+CTRL_CMD_DEFINE_RANGE(trx_arfcn, "arfcn", struct gsm_bts_trx, arfcn, 0, 1023);
 
 int bsc_base_ctrl_cmds_install(void)
 {
diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c
index db6fc5f..dbe1393 100644
--- a/openbsc/src/libmsc/gsm_04_08.c
+++ b/openbsc/src/libmsc/gsm_04_08.c
@@ -3115,7 +3115,7 @@ int mncc_tx_to_cc(struct gsm_network *net, int msg_type, void *arg)
 			}
 
 			*trans->paging_request = subscr->net;
-			subscr_get_channel(subscr, RSL_CHANNEED_TCH_F, setup_trig_pag_evt, trans->paging_request);
+			subscr_get_channel(subscr, RSL_CHANNEED_TCH_F, setup_trig_pag_evt, trans->paging_request, "MNCC RX call");
 
 			subscr_put(subscr);
 			return 0;
diff --git a/openbsc/src/libmsc/gsm_04_11.c b/openbsc/src/libmsc/gsm_04_11.c
index b2100d8..802ec17 100644
--- a/openbsc/src/libmsc/gsm_04_11.c
+++ b/openbsc/src/libmsc/gsm_04_11.c
@@ -944,7 +944,7 @@ int gsm411_send_sms_subscr(struct gsm_subscriber *subscr,
 	}
 
 	/* if not, we have to start paging */
-	subscr_get_channel(subscr, RSL_CHANNEED_SDCCH, paging_cb_send_sms, sms);
+	subscr_get_channel(subscr, RSL_CHANNEED_SDCCH, paging_cb_send_sms, sms, "SEND SMS");
 	return 0;
 }
 
diff --git a/openbsc/src/libmsc/gsm_subscriber.c b/openbsc/src/libmsc/gsm_subscriber.c
index bc6f3cf..881604b 100644
--- a/openbsc/src/libmsc/gsm_subscriber.c
+++ b/openbsc/src/libmsc/gsm_subscriber.c
@@ -47,37 +47,6 @@ int gsm48_secure_channel(struct gsm_subscriber_connection *conn, int key_seq,
                          gsm_cbfn *cb, void *cb_data);
 
 
-/*
- * Struct for pending channel requests. This is managed in the
- * llist_head requests of each subscriber. The reference counting
- * should work in such a way that a subscriber with a pending request
- * remains in memory.
- */
-struct subscr_request {
-	struct llist_head entry;
-
-	/* back reference */
-	struct gsm_subscriber *subscr;
-
-	/* the requested channel type */
-	int channel_type;
-
-	/* what did we do */
-	int state;
-
-	/* the callback data */
-	gsm_cbfn *cbfn;
-	void *param;
-};
-
-enum {
-	REQ_STATE_INITIAL,
-	REQ_STATE_QUEUED,
-	REQ_STATE_PAGED,
-	REQ_STATE_FAILED_START,
-	REQ_STATE_DISPATCHED,
-};
-
 static struct gsm_subscriber *get_subscriber(struct gsm_network *net,
 						int type, const char *ident)
 {
@@ -125,6 +94,7 @@ static int subscr_paging_dispatch(unsigned int hooknum, unsigned int event,
 	request->state = REQ_STATE_DISPATCHED;
 	llist_del(&request->entry);
 	subscr->in_callback = 1;
+	subscr->last_reason = request->reason;
 	request->cbfn(hooknum, event, msg, data, request->param);
 	subscr->in_callback = 0;
 
@@ -216,7 +186,7 @@ static void subscr_send_paging_request(struct gsm_subscriber *subscr)
 }
 
 void subscr_get_channel(struct gsm_subscriber *subscr,
-			int type, gsm_cbfn *cbfn, void *param)
+			int type, gsm_cbfn *cbfn, void *param, const char *reason)
 {
 	struct subscr_request *request;
 
@@ -234,6 +204,7 @@ void subscr_get_channel(struct gsm_subscriber *subscr,
 	request->cbfn = cbfn;
 	request->param = param;
 	request->state = REQ_STATE_INITIAL;
+	request->reason = reason;
 
 	/*
 	 * FIXME: We might be able to assign more than one
diff --git a/openbsc/tests/channel/channel_test.c b/openbsc/tests/channel/channel_test.c
index 9fb1e9e..75b441a 100644
--- a/openbsc/tests/channel/channel_test.c
+++ b/openbsc/tests/channel/channel_test.c
@@ -77,7 +77,7 @@ int main(int argc, char **argv)
 	subscr->net = network;
 
 	/* Ask for a channel... */
-	subscr_get_channel(subscr, RSL_CHANNEED_TCH_F, subscr_cb, (void*)0x2342L);
+	subscr_get_channel(subscr, RSL_CHANNEED_TCH_F, subscr_cb, (void*)0x2342L, "dummy");
 
 	while (!s_end) {
 		osmo_select_main(0);



More information about the OpenBSC mailing list