Change in osmo-hlr[master]: db v6: determine 3G AUC IND from VLR name

laforge gerrit-no-reply at lists.osmocom.org
Mon Jul 19 09:01:06 UTC 2021


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-hlr/+/16764 )

Change subject: db v6: determine 3G AUC IND from VLR name
......................................................................

db v6: determine 3G AUC IND from VLR name

Each VLR requesting auth tuples should use a distinct IND pool for 3G
auth.  So far we tied the IND to the GSUP peer connection; MSC and SGSN
were always distinct GSUP peers, they ended up using distinct INDs.

However, we have implemented a GSUP proxy, so that, in a distributed
setup, a remotely roaming subscriber has only one direct GSUP peer
proxying for both remote MSC and SGSN. That means as soon as a
subscriber roams to a different site, we would use the GSUP proxy name
to determine the IND instead of the separate MSC and SGSN. The site's
MSC and SGSN appear as the same client, get the same IND bucket, waste
SQNs rapidly and cause auth tuple generation load.

So instead of using the local client as IND, persistently keep a list of
VLR names and assign a different IND to each. Use the
gsup_req->source_name as indicator, which reflects the actual remote
VLR's name (remote MSC or SGSN).

Persist the site <-> IND assignments in the database.

Add an IND test to db_test.c

There was an earlier patch version that separated the IND pools by
cn_domain, but it turned out to add complex semantics, while only
solving one aspect of the "adjacent VLR" problem. We need a solution not
only for CS vs PS, but also for 2,3G vs 4G, and for sites that are
physically adjacent to each other. This patch version does not offer any
automatic solution for that -- as soon as more than 2^IND_bitlen
(usually 32) VLRs show up, it is the responsibility of the admin to
ensure the 'ind' table in the hlr.db does not have unfortunate IND
assignments. So far no VTY commands exist for that, they may be added in
the future.

Related: OS#4319
Change-Id: I6f0a6bbef3a27507605c3b4a0e1a89bdfd468374
---
M configure.ac
M include/osmocom/hlr/db.h
M include/osmocom/hlr/gsup_server.h
M sql/hlr.sql
M src/db.c
M src/db_hlr.c
M src/gsup_server.c
M src/hlr.c
M src/hlr_vty.c
M tests/Makefile.am
M tests/db/db_test.c
M tests/db/db_test.err
M tests/db_upgrade/db_upgrade_test.ok
D tests/gsup_server/Makefile.am
D tests/gsup_server/gsup_server_test.c
D tests/gsup_server/gsup_server_test.err
D tests/gsup_server/gsup_server_test.ok
M tests/testsuite.at
18 files changed, 296 insertions(+), 341 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  daniel: Looks good to me, but someone else must approve
  pespin: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/configure.ac b/configure.ac
index c496409..d1c14a0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -206,7 +206,6 @@
 	tests/Makefile
 	tests/auc/Makefile
 	tests/auc/gen_ts_55_205_test_sets/Makefile
-	tests/gsup_server/Makefile
 	tests/gsup/Makefile
 	tests/db/Makefile
 	tests/db_upgrade/Makefile
diff --git a/include/osmocom/hlr/db.h b/include/osmocom/hlr/db.h
index a771409..c43aa4f 100644
--- a/include/osmocom/hlr/db.h
+++ b/include/osmocom/hlr/db.h
@@ -4,6 +4,7 @@
 #include <sqlite3.h>
 
 #include <osmocom/gsupclient/cni_peer_id.h>
+#include <osmocom/gsm/gsup.h>
 
 struct hlr;
 
@@ -40,6 +41,9 @@
 	DB_STMT_SET_LAST_LU_SEEN_PS,
 	DB_STMT_EXISTS_BY_IMSI,
 	DB_STMT_EXISTS_BY_MSISDN,
+	DB_STMT_IND_ADD,
+	DB_STMT_IND_SELECT,
+	DB_STMT_IND_DEL,
 	_NUM_DB_STMT
 };
 
@@ -173,6 +177,9 @@
 int db_subscr_purge(struct db_context *dbc, const char *by_imsi,
 		    bool purge_val, bool is_ps);
 
+int db_ind(struct db_context *dbc, const struct osmo_cni_peer_id *vlr, unsigned int *ind);
+int db_ind_del(struct db_context *dbc, const struct osmo_cni_peer_id *vlr);
+
 /*! Call sqlite3_column_text() and copy result to a char[].
  * \param[out] buf  A char[] used as sizeof() arg(!) and osmo_strlcpy() target.
  * \param[in] stmt  An sqlite3_stmt*.
diff --git a/include/osmocom/hlr/gsup_server.h b/include/osmocom/hlr/gsup_server.h
index ce7556e..9c562e2 100644
--- a/include/osmocom/hlr/gsup_server.h
+++ b/include/osmocom/hlr/gsup_server.h
@@ -42,8 +42,6 @@
 	//struct oap_state oap_state;
 	struct tlv_parsed ccm;
 
-	unsigned int auc_3g_ind; /*!< IND index used for UMTS AKA SQN */
-
 	/* Set when Location Update is received: */
 	bool supports_cs; /* client supports OSMO_GSUP_CN_DOMAIN_CS */
 	bool supports_ps; /* client supports OSMO_GSUP_CN_DOMAIN_PS */
diff --git a/sql/hlr.sql b/sql/hlr.sql
index 98e586d..e855a6c 100644
--- a/sql/hlr.sql
+++ b/sql/hlr.sql
@@ -79,8 +79,16 @@
 	ind_bitlen	INTEGER NOT NULL DEFAULT 5
 );
 
+CREATE TABLE ind (
+	-- 3G auth IND pool to be used for this VLR
+	ind     INTEGER PRIMARY KEY,
+	-- VLR identification, usually the GSUP source_name
+	vlr     TEXT NOT NULL,
+	UNIQUE (vlr)
+);
+
 CREATE UNIQUE INDEX idx_subscr_imsi ON subscriber (imsi);
 
 -- Set HLR database schema version number
 -- Note: This constant is currently duplicated in src/db.c and must be kept in sync!
-PRAGMA user_version = 5;
+PRAGMA user_version = 6;
diff --git a/src/db.c b/src/db.c
index 4fd2654..23dcbbc 100644
--- a/src/db.c
+++ b/src/db.c
@@ -28,7 +28,7 @@
 #include "db_bootstrap.h"
 
 /* This constant is currently duplicated in sql/hlr.sql and must be kept in sync! */
-#define CURRENT_SCHEMA_VERSION	5
+#define CURRENT_SCHEMA_VERSION	6
 
 #define SEL_COLUMNS \
 	"id," \
@@ -93,6 +93,9 @@
 	[DB_STMT_SET_LAST_LU_SEEN_PS] = "UPDATE subscriber SET last_lu_seen_ps = datetime($val, 'unixepoch') WHERE id = $subscriber_id",
 	[DB_STMT_EXISTS_BY_IMSI] = "SELECT 1 FROM subscriber WHERE imsi = $imsi",
 	[DB_STMT_EXISTS_BY_MSISDN] = "SELECT 1 FROM subscriber WHERE msisdn = $msisdn",
+	[DB_STMT_IND_ADD] = "INSERT INTO ind (vlr) VALUES ($vlr)",
+	[DB_STMT_IND_SELECT] = "SELECT ind FROM ind WHERE vlr = $vlr",
+	[DB_STMT_IND_DEL] = "DELETE FROM ind WHERE vlr = $vlr",
 };
 
 static void sql3_error_log_cb(void *arg, int err_code, const char *msg)
@@ -487,6 +490,29 @@
 	return rc;
 }
 
+static int db_upgrade_v6(struct db_context *dbc)
+{
+	int rc;
+	const char *statements[] = {
+		"CREATE TABLE ind (\n"
+		"	-- 3G auth IND pool to be used for this VLR\n"
+		"	ind     INTEGER PRIMARY KEY,\n"
+		"	-- VLR identification, usually the GSUP source_name\n"
+		"	vlr     TEXT NOT NULL,\n"
+		"	UNIQUE (vlr)\n"
+		")"
+		,
+		"PRAGMA user_version = 6",
+	};
+
+	rc = db_run_statements(dbc, statements, ARRAY_SIZE(statements));
+	if (rc != SQLITE_DONE) {
+		LOGP(DDB, LOGL_ERROR, "Unable to update HLR database schema to version 6\n");
+		return rc;
+	}
+	return rc;
+}
+
 typedef int (*db_upgrade_func_t)(struct db_context *dbc);
 static db_upgrade_func_t db_upgrade_path[] = {
 	db_upgrade_v1,
@@ -494,6 +520,7 @@
 	db_upgrade_v3,
 	db_upgrade_v4,
 	db_upgrade_v5,
+	db_upgrade_v6,
 };
 
 static int db_get_user_version(struct db_context *dbc)
diff --git a/src/db_hlr.c b/src/db_hlr.c
index e88b5fc..591908f 100644
--- a/src/db_hlr.c
+++ b/src/db_hlr.c
@@ -972,3 +972,106 @@
 
 	return ret;
 }
+
+static int _db_ind_run(struct db_context *dbc, sqlite3_stmt *stmt, const char *vlr, bool reset)
+{
+	int rc;
+
+	if (!db_bind_text(stmt, "$vlr", vlr))
+		return -EIO;
+
+	/* execute the statement */
+	rc = sqlite3_step(stmt);
+	if (reset)
+		db_remove_reset(stmt);
+	return rc;
+}
+
+static int _db_ind_add(struct db_context *dbc, const char *vlr)
+{
+	sqlite3_stmt *stmt = dbc->stmt[DB_STMT_IND_ADD];
+	if (_db_ind_run(dbc, stmt, vlr, true) != SQLITE_DONE) {
+		LOGP(DDB, LOGL_ERROR, "Cannot create IND entry for %s\n", osmo_quote_str_c(OTC_SELECT, vlr, -1));
+		return -EIO;
+	}
+	return 0;
+}
+
+static int _db_ind_del(struct db_context *dbc, const char *vlr)
+{
+	sqlite3_stmt *stmt = dbc->stmt[DB_STMT_IND_DEL];
+	_db_ind_run(dbc, stmt, vlr, true);
+	/* We don't really care about the result. If it didn't exist, then that was the goal anyway. */
+	return 0;
+}
+
+static int _db_ind_get(struct db_context *dbc, const char *vlr, unsigned int *ind)
+{
+	int ret = 0;
+	sqlite3_stmt *stmt = dbc->stmt[DB_STMT_IND_SELECT];
+	int rc = _db_ind_run(dbc, stmt, vlr, false);
+	if (rc == SQLITE_DONE) {
+		/* Does not exist yet */
+		ret = -ENOENT;
+		goto out;
+	} else if (rc != SQLITE_ROW) {
+		LOGP(DDB, LOGL_ERROR, "Error executing SQL: %d\n", rc);
+		ret = -EIO;
+		goto out;
+	}
+
+	OSMO_ASSERT(ind);
+	*ind = sqlite3_column_int64(stmt, 0);
+out:
+	db_remove_reset(stmt);
+	return ret;
+}
+
+int _db_ind(struct db_context *dbc, const struct osmo_cni_peer_id *vlr,
+	    unsigned int *ind, bool del)
+{
+	const char *vlr_name = NULL;
+	int rc;
+
+	switch (vlr->type) {
+	case OSMO_CNI_PEER_ID_IPA_NAME:
+		if (vlr->ipa_name.len < 2 || vlr->ipa_name.val[vlr->ipa_name.len - 1] != '\0') {
+			LOGP(DDB, LOGL_ERROR, "Expecting VLR ipa_name to be zero terminated; found %s\n",
+			     osmo_ipa_name_to_str(&vlr->ipa_name));
+			return -ENOTSUP;
+		}
+		vlr_name = (const char*)vlr->ipa_name.val;
+		break;
+	default:
+		LOGP(DDB, LOGL_ERROR, "Unsupported osmo_cni_peer_id type: %s\n",
+		     osmo_cni_peer_id_type_name(vlr->type));
+		return -ENOTSUP;
+	}
+
+	if (del)
+		return _db_ind_del(dbc, vlr_name);
+
+	rc = _db_ind_get(dbc, vlr_name, ind);
+	if (!rc)
+		return 0;
+
+	/* Does not exist yet, create. */
+	rc = _db_ind_add(dbc, vlr_name);
+	if (rc) {
+		LOGP(DDB, LOGL_ERROR, "Error creating IND entry for %s\n", osmo_quote_str_c(OTC_SELECT, vlr_name, -1));
+		return rc;
+	}
+
+	/* To be sure, query again from scratch. */
+	return _db_ind_get(dbc, vlr_name, ind);
+}
+
+int db_ind(struct db_context *dbc, const struct osmo_cni_peer_id *vlr, unsigned int *ind)
+{
+	return _db_ind(dbc, vlr, ind, false);
+}
+
+int db_ind_del(struct db_context *dbc, const struct osmo_cni_peer_id *vlr)
+{
+	return _db_ind(dbc, vlr, NULL, true);
+}
diff --git a/src/gsup_server.c b/src/gsup_server.c
index 756473a..f0d8101 100644
--- a/src/gsup_server.c
+++ b/src/gsup_server.c
@@ -317,43 +317,6 @@
 	return 0;
 }
 
-/* Add conn to the clients list in a way that conn->auc_3g_ind takes the lowest
- * unused integer and the list of clients remains sorted by auc_3g_ind.
- * Keep this function non-static to allow linking in a unit test. */
-void osmo_gsup_server_add_conn(struct llist_head *clients,
-			       struct osmo_gsup_conn *conn)
-{
-	struct osmo_gsup_conn *c;
-	struct osmo_gsup_conn *prev_conn;
-
-	c = llist_first_entry_or_null(clients, struct osmo_gsup_conn, list);
-
-	/* Is the first index, 0, unused? */
-	if (!c || c->auc_3g_ind > 0) {
-		conn->auc_3g_ind = 0;
-		llist_add(&conn->list, clients);
-		return;
-	}
-
-	/* Look for a gap later on */
-	prev_conn = NULL;
-	llist_for_each_entry(c, clients, list) {
-		/* skip first item, we know it has auc_3g_ind == 0. */
-		if (!prev_conn) {
-			prev_conn = c;
-			continue;
-		}
-		if (c->auc_3g_ind > prev_conn->auc_3g_ind + 1)
-			break;
-		prev_conn = c;
-	}
-
-	OSMO_ASSERT(prev_conn);
-
-	conn->auc_3g_ind = prev_conn->auc_3g_ind + 1;
-	llist_add(&conn->list, &prev_conn->list);
-}
-
 static void update_fd_settings(int fd)
 {
 	int ret;
@@ -386,10 +349,9 @@
 
 	/* link data structure with server structure */
 	conn->server = gsups;
-	osmo_gsup_server_add_conn(&gsups->clients, conn);
+	llist_add_tail(&conn->list, &gsups->clients);
 
-	LOGP(DLGSUP, LOGL_INFO, "New GSUP client %s:%d (IND=%u)\n",
-	     conn->conn->addr, conn->conn->port, conn->auc_3g_ind);
+	LOGP(DLGSUP, LOGL_INFO, "New GSUP client %s:%d\n", conn->conn->addr, conn->conn->port);
 
 	update_fd_settings(fd);
 
diff --git a/src/hlr.c b/src/hlr.c
index 45d0b90..294da23 100644
--- a/src/hlr.c
+++ b/src/hlr.c
@@ -281,13 +281,14 @@
  ***********************************************************************/
 
 /* process an incoming SAI request */
-static int rx_send_auth_info(unsigned int auc_3g_ind, struct osmo_gsup_req *req)
+static int rx_send_auth_info(struct osmo_gsup_req *req)
 {
 	struct osmo_gsup_message gsup_out = {
 		.message_type = OSMO_GSUP_MSGT_SEND_AUTH_INFO_RESULT,
 	};
 	bool separation_bit = false;
 	int num_auth_vectors = OSMO_GSUP_MAX_NUM_AUTH_INFO;
+	unsigned int auc_3g_ind;
 	int rc;
 
 	subscr_create_on_demand(req->gsup.imsi);
@@ -298,6 +299,14 @@
 	if (req->gsup.num_auth_vectors > 0 &&
 			req->gsup.num_auth_vectors <= OSMO_GSUP_MAX_NUM_AUTH_INFO)
 		num_auth_vectors = req->gsup.num_auth_vectors;
+	rc = db_ind(g_hlr->dbc, &req->source_name, &auc_3g_ind);
+	if (rc) {
+		LOG_GSUP_REQ(req, LOGL_ERROR,
+			     "Unable to determine 3G auth IND for source %s (rc=%d),"
+			     " generating tuples with IND = 0\n",
+			     osmo_cni_peer_id_to_str(&req->source_name), rc);
+		auc_3g_ind = 0;
+	}
 
 	rc = db_get_auc(g_hlr->dbc, req->gsup.imsi, auc_3g_ind,
 			gsup_out.auth_vectors,
@@ -517,7 +526,7 @@
 	switch (req->gsup.message_type) {
 	/* requests sent to us */
 	case OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST:
-		rx_send_auth_info(conn->auc_3g_ind, req);
+		rx_send_auth_info(req);
 		break;
 	case OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST:
 		rx_upd_loc_req(conn, req);
diff --git a/src/hlr_vty.c b/src/hlr_vty.c
index df2270b..2fd4783 100644
--- a/src/hlr_vty.c
+++ b/src/hlr_vty.c
@@ -116,8 +116,8 @@
 	rc = osmo_gsup_conn_ccm_get(conn, (uint8_t **) &name, IPAC_IDTAG_SERNR);
 	OSMO_ASSERT(rc);
 
-	vty_out(vty, " '%s' from %s:%5u, CS=%u, PS=%u, 3G_IND=%u%s",
-		name, isc->addr, isc->port, conn->supports_cs, conn->supports_ps, conn->auc_3g_ind,
+	vty_out(vty, " '%s' from %s:%5u, CS=%u, PS=%u%s",
+		name, isc->addr, isc->port, conn->supports_cs, conn->supports_ps,
 		VTY_NEWLINE);
 }
 
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9015494..9270efa 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,6 +1,5 @@
 SUBDIRS = \
 	auc \
-	gsup_server \
 	db \
 	gsup \
 	db_upgrade \
diff --git a/tests/db/db_test.c b/tests/db/db_test.c
index 0c68238..00434cf 100644
--- a/tests/db/db_test.c
+++ b/tests/db/db_test.c
@@ -918,6 +918,50 @@
 	comment_end();
 }
 
+static void test_ind()
+{
+	comment_start();
+
+#define ASSERT_IND(VLR, IND) do { \
+		unsigned int ind; \
+		struct osmo_cni_peer_id vlr; \
+		OSMO_ASSERT(!osmo_cni_peer_id_set_str(&vlr, OSMO_CNI_PEER_ID_IPA_NAME, VLR)); \
+		ASSERT_RC(db_ind(dbc, &vlr, &ind), 0); \
+		fprintf(stderr, "%s ind = %u\n\n", osmo_quote_str((char*)vlr.ipa_name.val, vlr.ipa_name.len), ind); \
+		if (ind != (IND)) \
+			fprintf(stderr, "  ERROR: expected " #IND "\n"); \
+	} while (0)
+#define IND_DEL(VLR) do { \
+		struct osmo_cni_peer_id vlr; \
+		OSMO_ASSERT(!osmo_cni_peer_id_set_str(&vlr, OSMO_CNI_PEER_ID_IPA_NAME, VLR)); \
+		ASSERT_RC(db_ind_del(dbc, &vlr), 0); \
+		fprintf(stderr, "%s ind deleted\n\n", osmo_quote_str((char*)vlr.ipa_name.val, vlr.ipa_name.len)); \
+	} while (0)
+
+	ASSERT_IND("msc-23", 1);
+	ASSERT_IND("sgsn-11", 2);
+	ASSERT_IND("msc-42", 3);
+	ASSERT_IND("sgsn-22", 4);
+	ASSERT_IND("msc-0x17", 5);
+	ASSERT_IND("sgsn-0xaa", 6);
+	ASSERT_IND("msc-42", 3);
+	ASSERT_IND("sgsn-22", 4);
+	ASSERT_IND("msc-0x17", 5);
+	ASSERT_IND("sgsn-0xaa", 6);
+	ASSERT_IND("sgsn-0xbb", 7);
+	ASSERT_IND("msc-0x2a", 8);
+	ASSERT_IND("msc-42", 3);
+	ASSERT_IND("sgsn-22", 4);
+	ASSERT_IND("msc-23", 1);
+	ASSERT_IND("sgsn-11", 2);
+
+	IND_DEL("msc-0x17"); /* dropped IND == 5 */
+	ASSERT_IND("msc-0x2a", 8); /* known CS remains where it is */
+	ASSERT_IND("any-unknown", 9); /* new VLR takes a new IND from the end */
+
+	comment_end();
+}
+
 static struct {
 	bool verbose;
 } cmdline_opts = {
@@ -1002,6 +1046,7 @@
 	test_subscr_aud();
 	test_subscr_aud_invalid_len();
 	test_subscr_sqn();
+	test_ind();
 
 	printf("Done\n");
 	db_close(dbc);
diff --git a/tests/db/db_test.err b/tests/db/db_test.err
index 871e722..ddf6d00 100644
--- a/tests/db/db_test.err
+++ b/tests/db/db_test.err
@@ -1613,3 +1613,83 @@
 
 ===== test_subscr_sqn: SUCCESS
 
+
+===== test_ind
+db_ind(dbc, &vlr, &ind) --> 0
+
+"msc-23\0" ind = 1
+
+db_ind(dbc, &vlr, &ind) --> 0
+
+"sgsn-11\0" ind = 2
+
+db_ind(dbc, &vlr, &ind) --> 0
+
+"msc-42\0" ind = 3
+
+db_ind(dbc, &vlr, &ind) --> 0
+
+"sgsn-22\0" ind = 4
+
+db_ind(dbc, &vlr, &ind) --> 0
+
+"msc-0x17\0" ind = 5
+
+db_ind(dbc, &vlr, &ind) --> 0
+
+"sgsn-0xaa\0" ind = 6
+
+db_ind(dbc, &vlr, &ind) --> 0
+
+"msc-42\0" ind = 3
+
+db_ind(dbc, &vlr, &ind) --> 0
+
+"sgsn-22\0" ind = 4
+
+db_ind(dbc, &vlr, &ind) --> 0
+
+"msc-0x17\0" ind = 5
+
+db_ind(dbc, &vlr, &ind) --> 0
+
+"sgsn-0xaa\0" ind = 6
+
+db_ind(dbc, &vlr, &ind) --> 0
+
+"sgsn-0xbb\0" ind = 7
+
+db_ind(dbc, &vlr, &ind) --> 0
+
+"msc-0x2a\0" ind = 8
+
+db_ind(dbc, &vlr, &ind) --> 0
+
+"msc-42\0" ind = 3
+
+db_ind(dbc, &vlr, &ind) --> 0
+
+"sgsn-22\0" ind = 4
+
+db_ind(dbc, &vlr, &ind) --> 0
+
+"msc-23\0" ind = 1
+
+db_ind(dbc, &vlr, &ind) --> 0
+
+"sgsn-11\0" ind = 2
+
+db_ind_del(dbc, &vlr) --> 0
+
+"msc-0x17\0" ind deleted
+
+db_ind(dbc, &vlr, &ind) --> 0
+
+"msc-0x2a\0" ind = 8
+
+db_ind(dbc, &vlr, &ind) --> 0
+
+"any-unknown\0" ind = 9
+
+===== test_ind: SUCCESS
+
diff --git a/tests/db_upgrade/db_upgrade_test.ok b/tests/db_upgrade/db_upgrade_test.ok
index 2bc6a39..0a45f7c 100644
--- a/tests/db_upgrade/db_upgrade_test.ok
+++ b/tests/db_upgrade/db_upgrade_test.ok
@@ -85,6 +85,7 @@
 DDB Database <PATH>test.db' has been upgraded to HLR DB schema version 3
 DDB Database <PATH>test.db' has been upgraded to HLR DB schema version 4
 DDB Database <PATH>test.db' has been upgraded to HLR DB schema version 5
+DDB Database <PATH>test.db' has been upgraded to HLR DB schema version 6
 DMAIN Cmdline option --db-check: Database was opened successfully, quitting.
 
 Resulting db:
@@ -117,6 +118,13 @@
 5|5|44444444444444444444444444444444|44444444444444444444444444444444||0|5
 5|5|55555555555555555555555555555555||55555555555555555555555555555555|0|6
 
+Table: ind
+name|type|notnull|dflt_value|pk
+ind|INTEGER|0||1
+vlr|TEXT|1||0
+
+Table ind contents:
+
 Table: subscriber
 name|type|notnull|dflt_value|pk
 ggsn_number|VARCHAR(15)|0||0
@@ -171,5 +179,5 @@
 rc = 0
 DMAIN hlr starting
 DDB using database: <PATH>test.db
-DDB Database <PATH>test.db' has HLR DB schema version 5
+DDB Database <PATH>test.db' has HLR DB schema version 6
 DMAIN Cmdline option --db-check: Database was opened successfully, quitting.
diff --git a/tests/gsup_server/Makefile.am b/tests/gsup_server/Makefile.am
deleted file mode 100644
index 34acd30..0000000
--- a/tests/gsup_server/Makefile.am
+++ /dev/null
@@ -1,44 +0,0 @@
-AM_CPPFLAGS = \
-	$(all_includes) \
-	$(NULL)
-
-AM_CFLAGS = \
-	-Wall \
-	-ggdb3 \
-	-I$(top_srcdir)/include \
-	$(LIBOSMOCORE_CFLAGS) \
-	$(LIBOSMOGSM_CFLAGS) \
-	$(LIBOSMOABIS_CFLAGS) \
-	$(NULL)
-
-AM_LDFLAGS = \
-	-no-install \
-	$(NULL)
-
-EXTRA_DIST = \
-	gsup_server_test.ok \
-	gsup_server_test.err \
-	$(NULL)
-
-noinst_PROGRAMS = \
-	gsup_server_test \
-	$(NULL)
-
-gsup_server_test_SOURCES = \
-	gsup_server_test.c \
-	$(NULL)
-
-gsup_server_test_LDADD = \
-	$(top_srcdir)/src/gsup_server.c \
-	$(top_srcdir)/src/gsup_router.c \
-	$(top_srcdir)/src/gsup_send.c \
-	$(top_srcdir)/src/gsupclient/cni_peer_id.c \
-	$(top_srcdir)/src/gsupclient/gsup_req.c \
-	$(LIBOSMOCORE_LIBS) \
-	$(LIBOSMOGSM_LIBS) \
-	$(LIBOSMOABIS_LIBS) \
-	$(NULL)
-
-.PHONY: update_exp
-update_exp:
-	$(builddir)/gsup_server_test >"$(srcdir)/gsup_server_test.ok" 2>"$(srcdir)/gsup_server_test.err"
diff --git a/tests/gsup_server/gsup_server_test.c b/tests/gsup_server/gsup_server_test.c
deleted file mode 100644
index 4aec69b..0000000
--- a/tests/gsup_server/gsup_server_test.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/* (C) 2017 by sysmocom s.f.m.c. GmbH <info at sysmocom.de>
- * All Rights Reserved
- *
- * Author: Neels Hofmeyr <nhofmeyr at sysmocom.de>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include <stdio.h>
-#include <osmocom/core/utils.h>
-#include <osmocom/hlr/gsup_server.h>
-
-#define comment_start() printf("\n===== %s\n", __func__)
-#define comment_end() printf("===== %s: SUCCESS\n\n", __func__)
-#define btw(fmt, args...) printf("\n" fmt "\n", ## args)
-
-#define VERBOSE_ASSERT(val, expect_op, fmt) \
-	do { \
-		printf(#val " == " fmt "\n", (val)); \
-		OSMO_ASSERT((val) expect_op); \
-	} while (0)
-
-void osmo_gsup_server_add_conn(struct llist_head *clients,
-			       struct osmo_gsup_conn *conn);
-
-static void test_add_conn(void)
-{
-	struct llist_head _list;
-	struct llist_head *clients = &_list;
-	struct osmo_gsup_conn conn_inst[23] = {};
-	struct osmo_gsup_conn *conn;
-	unsigned int i;
-
-	comment_start();
-
-	INIT_LLIST_HEAD(clients);
-
-	btw("Add 10 items");
-	for (i = 0; i < 10; i++) {
-		osmo_gsup_server_add_conn(clients, &conn_inst[i]);
-		printf("conn_inst[%u].auc_3g_ind == %u\n", i, conn_inst[i].auc_3g_ind);
-		OSMO_ASSERT(clients->next == &conn_inst[0].list);
-	}
-
-	btw("Expecting a list of 0..9");
-	i = 0;
-	llist_for_each_entry(conn, clients, list) {
-		printf("conn[%u].auc_3g_ind == %u\n", i, conn->auc_3g_ind);
-		OSMO_ASSERT(conn->auc_3g_ind == i);
-		OSMO_ASSERT(conn == &conn_inst[i]);
-		i++;
-	}
-
-	btw("Punch two holes in the sequence in arbitrary order,"
-	    " a larger one from 2..4 and a single one at 7.");
-	llist_del(&conn_inst[4].list);
-	llist_del(&conn_inst[2].list);
-	llist_del(&conn_inst[3].list);
-	llist_del(&conn_inst[7].list);
-
-	btw("Expecting a list of 0,1, 5,6, 8,9");
-	i = 0;
-	llist_for_each_entry(conn, clients, list) {
-		printf("conn[%u].auc_3g_ind == %u\n", i, conn->auc_3g_ind);
-		i++;
-	}
-
-	btw("Add conns, expecting them to take the open slots");
-	osmo_gsup_server_add_conn(clients, &conn_inst[12]);
-	VERBOSE_ASSERT(conn_inst[12].auc_3g_ind, == 2, "%u");
-
-	osmo_gsup_server_add_conn(clients, &conn_inst[13]);
-	VERBOSE_ASSERT(conn_inst[13].auc_3g_ind, == 3, "%u");
-
-	osmo_gsup_server_add_conn(clients, &conn_inst[14]);
-	VERBOSE_ASSERT(conn_inst[14].auc_3g_ind, == 4, "%u");
-
-	osmo_gsup_server_add_conn(clients, &conn_inst[17]);
-	VERBOSE_ASSERT(conn_inst[17].auc_3g_ind, == 7, "%u");
-
-	osmo_gsup_server_add_conn(clients, &conn_inst[18]);
-	VERBOSE_ASSERT(conn_inst[18].auc_3g_ind, == 10, "%u");
-
-	btw("Expecting a list of 0..10");
-	i = 0;
-	llist_for_each_entry(conn, clients, list) {
-		printf("conn[%u].auc_3g_ind == %u\n", i, conn->auc_3g_ind);
-		OSMO_ASSERT(conn->auc_3g_ind == i);
-		i++;
-	}
-
-	btw("Does it also work for the first item?");
-	llist_del(&conn_inst[0].list);
-
-	btw("Expecting a list of 1..10");
-	i = 0;
-	llist_for_each_entry(conn, clients, list) {
-		printf("conn[%u].auc_3g_ind == %u\n", i, conn->auc_3g_ind);
-		OSMO_ASSERT(conn->auc_3g_ind == i + 1);
-		i++;
-	}
-
-	btw("Add another conn, should take auc_3g_ind == 0");
-	osmo_gsup_server_add_conn(clients, &conn_inst[20]);
-	VERBOSE_ASSERT(conn_inst[20].auc_3g_ind, == 0, "%u");
-
-	btw("Expecting a list of 0..10");
-	i = 0;
-	llist_for_each_entry(conn, clients, list) {
-		printf("conn[%u].auc_3g_ind == %u\n", i, conn->auc_3g_ind);
-		OSMO_ASSERT(conn->auc_3g_ind == i);
-		i++;
-	}
-
-	btw("If a client reconnects, it will (likely) get the same auc_3g_ind");
-	VERBOSE_ASSERT(conn_inst[5].auc_3g_ind, == 5, "%u");
-	llist_del(&conn_inst[5].list);
-	conn_inst[5].auc_3g_ind = 423;
-	osmo_gsup_server_add_conn(clients, &conn_inst[5]);
-	VERBOSE_ASSERT(conn_inst[5].auc_3g_ind, == 5, "%u");
-
-	comment_end();
-}
-
-int main(int argc, char **argv)
-{
-	printf("test_gsup_server.c\n");
-
-	test_add_conn();
-
-	printf("Done\n");
-	return 0;
-}
diff --git a/tests/gsup_server/gsup_server_test.err b/tests/gsup_server/gsup_server_test.err
deleted file mode 100644
index e69de29..0000000
--- a/tests/gsup_server/gsup_server_test.err
+++ /dev/null
diff --git a/tests/gsup_server/gsup_server_test.ok b/tests/gsup_server/gsup_server_test.ok
deleted file mode 100644
index 80d944c..0000000
--- a/tests/gsup_server/gsup_server_test.ok
+++ /dev/null
@@ -1,94 +0,0 @@
-test_gsup_server.c
-
-===== test_add_conn
-
-Add 10 items
-conn_inst[0].auc_3g_ind == 0
-conn_inst[1].auc_3g_ind == 1
-conn_inst[2].auc_3g_ind == 2
-conn_inst[3].auc_3g_ind == 3
-conn_inst[4].auc_3g_ind == 4
-conn_inst[5].auc_3g_ind == 5
-conn_inst[6].auc_3g_ind == 6
-conn_inst[7].auc_3g_ind == 7
-conn_inst[8].auc_3g_ind == 8
-conn_inst[9].auc_3g_ind == 9
-
-Expecting a list of 0..9
-conn[0].auc_3g_ind == 0
-conn[1].auc_3g_ind == 1
-conn[2].auc_3g_ind == 2
-conn[3].auc_3g_ind == 3
-conn[4].auc_3g_ind == 4
-conn[5].auc_3g_ind == 5
-conn[6].auc_3g_ind == 6
-conn[7].auc_3g_ind == 7
-conn[8].auc_3g_ind == 8
-conn[9].auc_3g_ind == 9
-
-Punch two holes in the sequence in arbitrary order, a larger one from 2..4 and a single one at 7.
-
-Expecting a list of 0,1, 5,6, 8,9
-conn[0].auc_3g_ind == 0
-conn[1].auc_3g_ind == 1
-conn[2].auc_3g_ind == 5
-conn[3].auc_3g_ind == 6
-conn[4].auc_3g_ind == 8
-conn[5].auc_3g_ind == 9
-
-Add conns, expecting them to take the open slots
-conn_inst[12].auc_3g_ind == 2
-conn_inst[13].auc_3g_ind == 3
-conn_inst[14].auc_3g_ind == 4
-conn_inst[17].auc_3g_ind == 7
-conn_inst[18].auc_3g_ind == 10
-
-Expecting a list of 0..10
-conn[0].auc_3g_ind == 0
-conn[1].auc_3g_ind == 1
-conn[2].auc_3g_ind == 2
-conn[3].auc_3g_ind == 3
-conn[4].auc_3g_ind == 4
-conn[5].auc_3g_ind == 5
-conn[6].auc_3g_ind == 6
-conn[7].auc_3g_ind == 7
-conn[8].auc_3g_ind == 8
-conn[9].auc_3g_ind == 9
-conn[10].auc_3g_ind == 10
-
-Does it also work for the first item?
-
-Expecting a list of 1..10
-conn[0].auc_3g_ind == 1
-conn[1].auc_3g_ind == 2
-conn[2].auc_3g_ind == 3
-conn[3].auc_3g_ind == 4
-conn[4].auc_3g_ind == 5
-conn[5].auc_3g_ind == 6
-conn[6].auc_3g_ind == 7
-conn[7].auc_3g_ind == 8
-conn[8].auc_3g_ind == 9
-conn[9].auc_3g_ind == 10
-
-Add another conn, should take auc_3g_ind == 0
-conn_inst[20].auc_3g_ind == 0
-
-Expecting a list of 0..10
-conn[0].auc_3g_ind == 0
-conn[1].auc_3g_ind == 1
-conn[2].auc_3g_ind == 2
-conn[3].auc_3g_ind == 3
-conn[4].auc_3g_ind == 4
-conn[5].auc_3g_ind == 5
-conn[6].auc_3g_ind == 6
-conn[7].auc_3g_ind == 7
-conn[8].auc_3g_ind == 8
-conn[9].auc_3g_ind == 9
-conn[10].auc_3g_ind == 10
-
-If a client reconnects, it will (likely) get the same auc_3g_ind
-conn_inst[5].auc_3g_ind == 5
-conn_inst[5].auc_3g_ind == 5
-===== test_add_conn: SUCCESS
-
-Done
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 956ef87..65f90b4 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -22,13 +22,6 @@
 AT_CHECK([$abs_top_builddir/tests/gsup/gsup_test], [], [expout], [experr])
 AT_CLEANUP
 
-AT_SETUP([gsup_server])
-AT_KEYWORDS([gsup_server])
-cat $abs_srcdir/gsup_server/gsup_server_test.ok > expout
-cat $abs_srcdir/gsup_server/gsup_server_test.err > experr
-AT_CHECK([$abs_top_builddir/tests/gsup_server/gsup_server_test], [], [expout], [experr])
-AT_CLEANUP
-
 AT_SETUP([db])
 AT_KEYWORDS([db])
 cat $abs_srcdir/db/db_test.ok > expout

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/16764
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Change-Id: I6f0a6bbef3a27507605c3b4a0e1a89bdfd468374
Gerrit-Change-Number: 16764
Gerrit-PatchSet: 16
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210719/bccb087f/attachment.htm>


More information about the gerrit-log mailing list