aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Chemeris <Alexander.Chemeris@gmail.com>2017-07-11 01:42:41 +0630
committerNeels Hofmeyr <neels@hofmeyr.de>2018-01-12 00:43:32 +0100
commiteca0aa1c081dc7cf3605f277d3b5c45523176b21 (patch)
tree0a4001817ce181b05e17664b0891041dd7faf4fd
parent5ba6fb3ef4421b8fb98137a77b6fe0dd8bcc7283 (diff)
libcommon: Fix log output for bts>0.
Fixes regression probably introduced in c696cc28. For bts>0 logging doesn't show bts number correctly when printing lchan identification string - it will always show it as "bts=0". The reason for this is that the identification string is cached before bts->nr value is set to a proper value. This patch sets bts->nr as part of the first step of the bts structure initialization, before caching happens thus making sure the cached identification string is cached with the correct values. Change-Id: I61c18a7f021fcb1ec00d34a745f4e3ab03416c2d
-rw-r--r--openbsc/include/openbsc/gsm_data_shared.h2
-rw-r--r--openbsc/src/libcommon/gsm_data.c5
-rw-r--r--openbsc/src/libcommon/gsm_data_shared.c3
-rw-r--r--openbsc/tests/channel/channel_test.c2
-rw-r--r--openbsc/tests/gsm0408/gsm0408_test.c8
5 files changed, 11 insertions, 9 deletions
diff --git a/openbsc/include/openbsc/gsm_data_shared.h b/openbsc/include/openbsc/gsm_data_shared.h
index 91bdfcef4..b44796163 100644
--- a/openbsc/include/openbsc/gsm_data_shared.h
+++ b/openbsc/include/openbsc/gsm_data_shared.h
@@ -828,7 +828,7 @@ struct gsm_bts {
};
-struct gsm_bts *gsm_bts_alloc(void *talloc_ctx);
+struct gsm_bts *gsm_bts_alloc(void *talloc_ctx, uint8_t bts_num);
struct gsm_bts *gsm_bts_num(struct gsm_network *net, int num);
struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts);
diff --git a/openbsc/src/libcommon/gsm_data.c b/openbsc/src/libcommon/gsm_data.c
index 75475db09..eb2be72e3 100644
--- a/openbsc/src/libcommon/gsm_data.c
+++ b/openbsc/src/libcommon/gsm_data.c
@@ -304,12 +304,13 @@ struct gsm_bts *gsm_bts_alloc_register(struct gsm_network *net, enum gsm_bts_typ
if (!model && type != GSM_BTS_TYPE_UNKNOWN)
return NULL;
- bts = gsm_bts_alloc(net);
+ bts = gsm_bts_alloc(net, net->num_bts);
if (!bts)
return NULL;
+ net->num_bts++;
+
bts->network = net;
- bts->nr = net->num_bts++;
bts->type = type;
bts->model = model;
bts->bsic = bsic;
diff --git a/openbsc/src/libcommon/gsm_data_shared.c b/openbsc/src/libcommon/gsm_data_shared.c
index 387af7068..9cf90f82b 100644
--- a/openbsc/src/libcommon/gsm_data_shared.c
+++ b/openbsc/src/libcommon/gsm_data_shared.c
@@ -233,7 +233,7 @@ static const struct gprs_rlc_cfg rlc_cfg_default = {
.initial_mcs = 6,
};
-struct gsm_bts *gsm_bts_alloc(void *ctx)
+struct gsm_bts *gsm_bts_alloc(void *ctx, uint8_t bts_num)
{
struct gsm_bts *bts = talloc_zero(ctx, struct gsm_bts);
int i;
@@ -241,6 +241,7 @@ struct gsm_bts *gsm_bts_alloc(void *ctx)
if (!bts)
return NULL;
+ bts->nr = bts_num;
bts->num_trx = 0;
INIT_LLIST_HEAD(&bts->trx_list);
bts->ms_max_power = 15; /* dBm */
diff --git a/openbsc/tests/channel/channel_test.c b/openbsc/tests/channel/channel_test.c
index c69c70139..4aa5c4a16 100644
--- a/openbsc/tests/channel/channel_test.c
+++ b/openbsc/tests/channel/channel_test.c
@@ -70,7 +70,7 @@ void test_request_chan(void)
network = bsc_network_init(tall_bsc_ctx, 1, 1, NULL);
if (!network)
exit(1);
- bts = gsm_bts_alloc(network);
+ bts = gsm_bts_alloc(network, 0);
bts->location_area_code = 23;
/* Create a dummy subscriber */
diff --git a/openbsc/tests/gsm0408/gsm0408_test.c b/openbsc/tests/gsm0408/gsm0408_test.c
index 08cf43f50..9c966a959 100644
--- a/openbsc/tests/gsm0408/gsm0408_test.c
+++ b/openbsc/tests/gsm0408/gsm0408_test.c
@@ -128,7 +128,7 @@ static inline void test_si2q_segfault(void)
if (!network)
exit(1);
- bts = gsm_bts_alloc(network);
+ bts = gsm_bts_alloc(network, 0);
_bts_uarfcn_add(bts, 10564, 319, 0);
_bts_uarfcn_add(bts, 10612, 319, 0);
@@ -143,7 +143,7 @@ static inline void test_si2q_mu(void)
if (!network)
exit(1);
- bts = gsm_bts_alloc(network);
+ bts = gsm_bts_alloc(network, 0);
_bts_uarfcn_add(bts, 10564, 318, 0);
_bts_uarfcn_add(bts, 10612, 319, 0);
@@ -163,7 +163,7 @@ static inline void test_si2q_u(void)
if (!network)
exit(1);
- bts = gsm_bts_alloc(network);
+ bts = gsm_bts_alloc(network, 0);
/* first generate invalid SI as no UARFCN added */
gen(bts);
@@ -190,7 +190,7 @@ static inline void test_si2q_e(void)
if (!network)
exit(1);
- bts = gsm_bts_alloc(network);
+ bts = gsm_bts_alloc(network, 0);
bts->si_common.si2quater_neigh_list.arfcn =
bts->si_common.data.earfcn_list;