[PATCH] osmo-pcu[master]: Fix segfault in tbf test

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/gerrit-log@lists.osmocom.org/.

Max gerrit-no-reply at lists.osmocom.org
Thu Jan 12 12:50:10 UTC 2017


Review at  https://gerrit.osmocom.org/1579

Fix segfault in tbf test

Make vty init optional and only init it once per test.

Change-Id: I975cee6b2b21e1e83649f2ce23203568f225bd7a
---
M src/gprs_bssgp_pcu.cpp
M src/gprs_bssgp_pcu.h
M src/pcu_l1_if.cpp
M tests/emu/pcu_emu.cpp
M tests/tbf/TbfTest.cpp
5 files changed, 19 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/79/1579/1

diff --git a/src/gprs_bssgp_pcu.cpp b/src/gprs_bssgp_pcu.cpp
index da1d26c..6c90c27 100644
--- a/src/gprs_bssgp_pcu.cpp
+++ b/src/gprs_bssgp_pcu.cpp
@@ -824,7 +824,8 @@
 	uint16_t local_port, uint32_t sgsn_ip,
 	uint16_t sgsn_port, uint16_t nsei, uint16_t nsvci, uint16_t bvci,
 	uint16_t mcc, uint16_t mnc, uint16_t lac, uint16_t rac,
-	uint16_t cell_id)
+						     uint16_t cell_id,
+						     bool init_vty)
 {
 	struct sockaddr_in dest;
 	int rc;
@@ -844,7 +845,8 @@
 		LOGP(DBSSGP, LOGL_ERROR, "Failed to create NS instance\n");
 		return NULL;
 	}
-	gprs_ns_vty_init(bssgp_nsi);
+	if (init_vty)
+		gprs_ns_vty_init(bssgp_nsi);
 	bssgp_nsi->nsip.local_port = local_port;
 	rc = gprs_ns_nsip_listen(bssgp_nsi);
 	if (rc < 0) {
diff --git a/src/gprs_bssgp_pcu.h b/src/gprs_bssgp_pcu.h
index bb44903..a37c8a1 100644
--- a/src/gprs_bssgp_pcu.h
+++ b/src/gprs_bssgp_pcu.h
@@ -21,6 +21,7 @@
 #ifndef GPRS_BSSGP_PCU_H
 #define GPRS_BSSGP_PCU_H
 
+#include <stdbool.h>
 
 extern "C" {
 #include <osmocom/core/talloc.h>
@@ -80,7 +81,9 @@
 		uint16_t local_port,
 		uint32_t sgsn_ip, uint16_t sgsn_port, uint16_t nsei,
 		uint16_t nsvci, uint16_t bvci, uint16_t mcc, uint16_t mnc,
-		uint16_t lac, uint16_t rac, uint16_t cell_id);
+						     uint16_t lac, uint16_t rac,
+						     uint16_t cell_id,
+						     bool init_vty);
 
 void gprs_bssgp_destroy(void);
 int gprs_ns_reconnect(struct gprs_nsvc *nsvc);
diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp
index b892597..adc7cb7 100644
--- a/src/pcu_l1_if.cpp
+++ b/src/pcu_l1_if.cpp
@@ -18,6 +18,7 @@
  */
 
 #include <stdio.h>
+#include <stdbool.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
@@ -421,7 +422,7 @@
 		info_ind->remote_ip[0], info_ind->remote_port[0],
 		info_ind->nsei, info_ind->nsvci[0], info_ind->bvci,
 		info_ind->mcc, info_ind->mnc, info_ind->lac, info_ind->rac,
-		info_ind->cell_id);
+					    info_ind->cell_id, true);
 	if (!pcu) {
 		LOGP(DL1IF, LOGL_NOTICE, "SGSN not available\n");
 		goto bssgp_failed;
diff --git a/tests/emu/pcu_emu.cpp b/tests/emu/pcu_emu.cpp
index 3725c8d..cced031 100644
--- a/tests/emu/pcu_emu.cpp
+++ b/tests/emu/pcu_emu.cpp
@@ -31,6 +31,7 @@
 #include <gprs_rlcmac.h>
 #include <bts.h>
 
+#include <stdbool.h>
 #include <stdlib.h>
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -99,7 +100,8 @@
 	struct gprs_bssgp_pcu *pcu;
 
 	pcu = gprs_bssgp_create_and_connect(bts, 0, sgsn_ip, sgsn_port,
-					20, 20, 20, 0x901, 0x99, 1, 0, 0);
+					    20, 20, 20, 0x901, 0x99, 1, 0, 0,
+					    true);
 	pcu->on_unblock_ack = bvci_unblocked;
 	pcu->on_dl_unit_data = bssgp_data;
 }
diff --git a/tests/tbf/TbfTest.cpp b/tests/tbf/TbfTest.cpp
index bebb6ef..84475e1 100644
--- a/tests/tbf/TbfTest.cpp
+++ b/tests/tbf/TbfTest.cpp
@@ -41,6 +41,7 @@
 }
 
 #include <errno.h>
+#include <stdbool.h>
 
 void *tall_pcu_ctx;
 int16_t spoof_mnc = 0, spoof_mcc = 0;
@@ -453,7 +454,7 @@
 	bts = the_bts.bts_data();
 	setup_bts(&the_bts, ts_no);
 	gprs_bssgp_create_and_connect(bts, 33001, 0, 33001,
-		1234, 1234, 1234, 1, 1, 0, 0, 0);
+				      1234, 1234, 1234, 1, 1, 0, 0, 0, true);
 
 	for (i = 0; i < 1024; i++) {
 		uint32_t tlli = 0xc0000000 + i;
@@ -496,7 +497,7 @@
 	bts->ms_idle_sec = 10; /* keep the MS object */
 
 	gprs_bssgp_create_and_connect(bts, 33001, 0, 33001,
-		1234, 1234, 1234, 1, 1, 0, 0, 0);
+				      1234, 1234, 1234, 1, 1, 0, 0, 0, false);
 
 	/* Handle LLC frame 1 */
 	memset(buf, 1, sizeof(buf));
@@ -1792,7 +1793,7 @@
 	bts->egprs_enabled = 1;
 
 	gprs_bssgp_create_and_connect(bts, 33001, 0, 33001,
-		1234, 1234, 1234, 1, 1, 0, 0, 0);
+				      1234, 1234, 1234, 1, 1, 0, 0, 0, false);
 
 	/* Does not support EGPRS */
 	rc = gprs_rlcmac_dl_tbf::handle(bts, tlli, 0, imsi, ms_class, 0,
@@ -1826,7 +1827,7 @@
 	bts->trx[0].pdch[5].enable();
 
 	gprs_bssgp_create_and_connect(bts, 33001, 0, 33001,
-		1234, 1234, 1234, 1, 1, 0, 0, 0);
+				      1234, 1234, 1234, 1, 1, 0, 0, 0, false);
 
 	/* Does no support EGPRS */
 	dl_tbf = tbf_alloc_dl_tbf(bts, NULL, 0, ms_class, 0, 0);
@@ -1881,7 +1882,7 @@
 	bts->trx[0].pdch[5].enable();
 
 	gprs_bssgp_create_and_connect(bts, 33001, 0, 33001,
-		1234, 1234, 1234, 1, 1, 0, 0, 0);
+				      1234, 1234, 1234, 1, 1, 0, 0, 0, false);
 
 	/* EGPRS-only */
 	bts->egprs_enabled = 1;

-- 
To view, visit https://gerrit.osmocom.org/1579
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I975cee6b2b21e1e83649f2ce23203568f225bd7a
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>



More information about the gerrit-log mailing list