Change in osmo-sgsn[master]: tests: remove gmm unit tests

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/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Thu Sep 13 13:51:37 UTC 2018


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/9258 )

Change subject: tests: remove gmm unit tests
......................................................................

tests: remove gmm unit tests

The test cases now implemented by TTCN3 which should not be as fragile
as the unit tests. Because the unit tests expect a quite strong internal
state to be happen.

Change-Id: Iac1c8854b5ea4aa03279990390ebc110c979aac2
---
M tests/sgsn/sgsn_test.c
M tests/sgsn/sgsn_test.ok
2 files changed, 0 insertions(+), 836 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/tests/sgsn/sgsn_test.c b/tests/sgsn/sgsn_test.c
index 0e5267b..3e86266 100644
--- a/tests/sgsn/sgsn_test.c
+++ b/tests/sgsn/sgsn_test.c
@@ -925,166 +925,6 @@
 	cleanup_test();
 }
 
-/*
- * Test the GMM Attach procedure
- */
-static void test_gmm_attach(int retry)
-{
-	struct gprs_ra_id raid = { 0, };
-	struct sgsn_mm_ctx *ctx = NULL;
-	struct sgsn_mm_ctx *ictx;
-	uint32_t ptmsi1;
-	uint32_t foreign_tlli;
-	uint32_t local_tlli = 0;
-	struct gprs_llc_lle *lle;
-
-	/* DTAP - Attach Request */
-	/* The P-TMSI is not known by the SGSN */
-	static const unsigned char attach_req[] = {
-		0x08, 0x01, 0x02, 0xf5, 0xe0, 0x21, 0x08, 0x02, 0x05, 0xf4,
-		0xfb, 0xc5, 0x46, 0x79, 0x11, 0x22, 0x33, 0x40, 0x50, 0x60,
-		0x19, 0x18, 0xb3, 0x43, 0x2b, 0x25, 0x96, 0x62, 0x00, 0x60,
-		0x80, 0x9a, 0xc2, 0xc6, 0x62, 0x00, 0x60, 0x80, 0xba, 0xc8,
-		0xc6, 0x62, 0x00, 0x60, 0x80, 0x00
-	};
-
-	/* DTAP - Identity Response IMEI */
-	static const unsigned char ident_resp_imei[] = {
-		0x08, 0x16, 0x08, 0x9a, 0x78, 0x56, 0x34, 0x12, 0x90, 0x78,
-		0x56
-	};
-
-	/* DTAP - Identity Response IMSI */
-	static const unsigned char ident_resp_imsi[] = {
-		0x08, 0x16, 0x08, 0x19, 0x32, 0x54, 0x76, 0x98, 0x10, 0x32,
-		0x54
-	};
-
-	/* DTAP - Authentication and Ciphering Resp */
-	static const unsigned char auth_ciph_resp[] = {
-		0x08, 0x13, 0x00, 0x22, 0x51, 0xe5, 0x51, 0xe5, 0x23, 0x09,
-		0x9a, 0x78, 0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x01
-	};
-
-	/* DTAP - Attach Complete */
-	static const unsigned char attach_compl[] = {
-		0x08, 0x03
-	};
-
-	/* DTAP - Detach Request (MO) */
-	/* normal detach, power_off = 0 */
-	static const unsigned char detach_req[] = {
-		0x08, 0x05, 0x01, 0x18, 0x05, 0xf4, 0xeb, 0x8b,
-		0x45, 0x67, 0x19, 0x03, 0xb9, 0x97, 0xcb
-	};
-
-	printf("Testing GMM attach%s\n", retry ? " with retry" : "");
-
-	foreign_tlli = gprs_tmsi2tlli(0xc0000023, TLLI_FOREIGN);
-
-	/* Create a LLE/LLME */
-	OSMO_ASSERT(count(gprs_llme_list()) == 0);
-	lle = gprs_lle_get_or_create(foreign_tlli, 3);
-	OSMO_ASSERT(count(gprs_llme_list()) == 1);
-
-	/* inject the attach request */
-	send_0408_message(lle->llme, foreign_tlli, &raid,
-			  attach_req, ARRAY_SIZE(attach_req));
-
-	ctx = sgsn_mm_ctx_by_tlli(foreign_tlli, &raid);
-	OSMO_ASSERT(ctx != NULL);
-	OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT);
-
-	/* we expect an identity request (IMEI) */
-	OSMO_ASSERT(sgsn_tx_counter == 1);
-
-	/* inject the identity response (IMEI) */
-	send_0408_message(ctx->gb.llme, foreign_tlli, &raid,
-			  ident_resp_imei, ARRAY_SIZE(ident_resp_imei));
-
-	/* we expect an identity request (IMSI) */
-	OSMO_ASSERT(sgsn_tx_counter == 1);
-
-	/* inject the identity response (IMSI) */
-	send_0408_message(ctx->gb.llme, foreign_tlli, &raid,
-			  ident_resp_imsi, ARRAY_SIZE(ident_resp_imsi));
-
-	/* check that the MM context has not been removed due to a failed
-	 * authorization */
-	OSMO_ASSERT(ctx == sgsn_mm_ctx_by_tlli(foreign_tlli, &raid));
-
-	OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT);
-
-retry_attach_req:
-
-	if (retry && sgsn_tx_counter == 0) {
-		fprintf(stderr, "Retrying attach request\n");
-		/* re-inject the attach request */
-		send_0408_message(lle->llme, foreign_tlli, &raid,
-				  attach_req, ARRAY_SIZE(attach_req));
-	}
-
-	if (ctx->auth_state == SGSN_AUTH_AUTHENTICATE && sgsn_tx_counter == 1) {
-		/* we got an auth & ciph request */
-
-		/* inject the auth & ciph response */
-		send_0408_message(ctx->gb.llme, foreign_tlli, &raid,
-				  auth_ciph_resp, ARRAY_SIZE(auth_ciph_resp));
-
-		/* check that the MM context has not been removed due to a
-		 * failed authorization */
-		OSMO_ASSERT(ctx == sgsn_mm_ctx_by_tlli(foreign_tlli, &raid));
-		if (ctx->subscr && ctx->subscr->sgsn_data->msisdn_len > 0)
-			OSMO_ASSERT(strcmp(ctx->msisdn, "+49166213323") == 0);
-	}
-
-	if (retry && sgsn_tx_counter == 0)
-		goto retry_attach_req;
-
-	/* we expect an attach accept/reject */
-	OSMO_ASSERT(sgsn_tx_counter == 1);
-	ptmsi1 = get_new_ptmsi(&last_dl_parse_ctx);
-	OSMO_ASSERT(ptmsi1 != GSM_RESERVED_TMSI);
-
-	/* this has been randomly assigned by the SGSN */
-	local_tlli = gprs_tmsi2tlli(ptmsi1, TLLI_LOCAL);
-
-	/* inject the attach complete */
-	send_0408_message(ctx->gb.llme, local_tlli, &raid,
-			  attach_compl, ARRAY_SIZE(attach_compl));
-
-	OSMO_ASSERT(ctx->gmm_state == GMM_REGISTERED_NORMAL);
-
-	/* we don't expect a response */
-	OSMO_ASSERT(sgsn_tx_counter == 0);
-
-	/* inject the detach */
-	send_0408_message(ctx->gb.llme, local_tlli, &raid,
-			  detach_req, ARRAY_SIZE(detach_req));
-
-	/* verify that things are gone */
-	OSMO_ASSERT(count(gprs_llme_list()) == 0);
-	ictx = sgsn_mm_ctx_by_tlli(local_tlli, &raid);
-	OSMO_ASSERT(!ictx);
-
-	cleanup_test();
-}
-
-static void test_gmm_attach_acl(void)
-{
-	const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy;
-
-	sgsn_inst.cfg.auth_policy = SGSN_AUTH_POLICY_CLOSED;
-	sgsn_acl_add("123456789012345", &sgsn->cfg);
-	printf("Auth policy 'closed': ");
-	test_gmm_attach(0);
-	sgsn_acl_del("123456789012345", &sgsn->cfg);
-
-	sgsn->cfg.auth_policy = saved_auth_policy;
-
-	cleanup_test();
-}
-
 int my_subscr_request_update_location(struct sgsn_mm_ctx *mmctx)
 {
 	int rc;
@@ -1103,30 +943,6 @@
 	return 0;
 }
 
-static void test_gmm_attach_subscr(void)
-{
-	const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy;
-	struct gprs_subscr *subscr;
-
-	sgsn_inst.cfg.auth_policy = SGSN_AUTH_POLICY_REMOTE;
-	subscr_request_update_location_cb = my_subscr_request_update_location;
-	subscr_request_auth_info_cb = my_subscr_request_auth_info;
-
-	subscr = gprs_subscr_get_or_create("123456789012345");
-	subscr->authorized = 1;
-
-	printf("Auth policy 'remote': ");
-	test_gmm_attach(0);
-	gprs_subscr_put(subscr);
-	assert_no_subscrs();
-
-	sgsn->cfg.auth_policy = saved_auth_policy;
-	subscr_request_update_location_cb = __real_gprs_subscr_request_update_location;
-	subscr_request_auth_info_cb = __real_gprs_subscr_request_auth_info;
-
-	cleanup_test();
-}
-
 int my_subscr_request_auth_info_fake_auth(struct sgsn_mm_ctx *mmctx, const uint8_t *auts,
 						const uint8_t *auts_rand)
 {
@@ -1138,32 +954,6 @@
 	return 0;
 }
 
-static void test_gmm_attach_subscr_fake_auth(void)
-{
-	const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy;
-	struct gprs_subscr *subscr;
-
-	sgsn_inst.cfg.auth_policy = SGSN_AUTH_POLICY_REMOTE;
-	subscr_request_update_location_cb = my_subscr_request_update_location;
-	subscr_request_auth_info_cb = my_subscr_request_auth_info_fake_auth;
-
-	subscr = gprs_subscr_get_or_create("123456789012345");
-	subscr->authorized = 1;
-	sgsn->cfg.require_authentication = 1;
-	sgsn->cfg.require_update_location = 1;
-
-	printf("Auth policy 'remote', auth faked: ");
-	test_gmm_attach(0);
-	gprs_subscr_put(subscr);
-	assert_no_subscrs();
-
-	sgsn->cfg.auth_policy = saved_auth_policy;
-	subscr_request_update_location_cb = __real_gprs_subscr_request_update_location;
-	subscr_request_auth_info_cb = __real_gprs_subscr_request_auth_info;
-
-	cleanup_test();
-}
-
 int my_subscr_request_auth_info_real_auth(struct sgsn_mm_ctx *mmctx, const uint8_t *auts, const uint8_t *auts_rand)
 {
 	struct gsm_auth_tuple at = {
@@ -1181,33 +971,6 @@
 	return 0;
 }
 
-static void test_gmm_attach_subscr_real_auth(void)
-{
-	const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy;
-	struct gprs_subscr *subscr;
-
-	sgsn_inst.cfg.auth_policy = SGSN_AUTH_POLICY_REMOTE;
-	subscr_request_update_location_cb = my_subscr_request_update_location;
-	subscr_request_auth_info_cb = my_subscr_request_auth_info_real_auth;
-
-	subscr = gprs_subscr_get_or_create("123456789012345");
-	subscr->authorized = 1;
-	sgsn->cfg.require_authentication = 1;
-	sgsn->cfg.require_update_location = 1;
-
-	printf("Auth policy 'remote', triplet based auth: ");
-
-	test_gmm_attach(0);
-	gprs_subscr_put(subscr);
-	assert_no_subscrs();
-
-	sgsn->cfg.auth_policy = saved_auth_policy;
-	subscr_request_update_location_cb = __real_gprs_subscr_request_update_location;
-	subscr_request_auth_info_cb = __real_gprs_subscr_request_auth_info;
-
-	cleanup_test();
-}
-
 #define TEST_GSUP_IMSI_LONG_IE 0x01, 0x08, \
 			       0x21, 0x43, 0x65, 0x87, 0x09, 0x21, 0x43, 0xf5
 
@@ -1269,39 +1032,6 @@
 	return rx_gsup_message(update_location_res, sizeof(update_location_res));
 };
 
-
-static void test_gmm_attach_subscr_gsup_auth(int retry)
-{
-	const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy;
-	struct gprs_subscr *subscr;
-
-	sgsn_inst.cfg.auth_policy = SGSN_AUTH_POLICY_REMOTE;
-	subscr_request_update_location_cb = my_subscr_request_update_gsup_auth;
-	subscr_request_auth_info_cb = my_subscr_request_auth_info_gsup_auth;
-	if (retry) {
-		upd_loc_skip = 3;
-		auth_info_skip = 3;
-	}
-
-	subscr = gprs_subscr_get_or_create("123456789012345");
-	subscr->authorized = 1;
-	sgsn->cfg.require_authentication = 1;
-	sgsn->cfg.require_update_location = 1;
-	gprs_subscr_put(subscr);
-
-	printf("Auth policy 'remote', GSUP based auth: ");
-	test_gmm_attach(retry);
-	assert_no_subscrs();
-
-	sgsn->cfg.auth_policy = saved_auth_policy;
-	subscr_request_update_location_cb = __real_gprs_subscr_request_update_location;
-	subscr_request_auth_info_cb = __real_gprs_subscr_request_auth_info;
-	upd_loc_skip = 0;
-	auth_info_skip = 0;
-
-	cleanup_test();
-}
-
 int my_gsup_client_send(struct gsup_client *gsupc, struct msgb *msg)
 {
 	struct osmo_gsup_message to_peer = {0};
@@ -1353,38 +1083,6 @@
 	return 0;
 };
 
-static void test_gmm_attach_subscr_real_gsup_auth(int retry)
-{
-	const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy;
-	struct gprs_subscr *subscr;
-
-	sgsn_inst.cfg.auth_policy = SGSN_AUTH_POLICY_REMOTE;
-	gsup_client_send_cb = my_gsup_client_send;
-
-	sgsn->gsup_client = talloc_zero(tall_bsc_ctx, struct gsup_client);
-
-	if (retry) {
-		upd_loc_skip = 3;
-		auth_info_skip = 3;
-	}
-
-	printf("Auth policy 'remote', real GSUP based auth: ");
-	test_gmm_attach(retry);
-
-	subscr = gprs_subscr_get_by_imsi("123456789012345");
-	OSMO_ASSERT(subscr == NULL);
-	assert_no_subscrs();
-
-	sgsn->cfg.auth_policy = saved_auth_policy;
-	gsup_client_send_cb = __real_gsup_client_send;
-	upd_loc_skip = 0;
-	auth_info_skip = 0;
-	talloc_free(sgsn->gsup_client);
-	sgsn->gsup_client = NULL;
-
-	cleanup_test();
-}
-
 /*
  * Test the GMM Rejects
  */
@@ -1639,513 +1337,6 @@
 	cleanup_test();
 }
 
-/*
- * Test the dynamic allocation of P-TMSIs
- */
-static void test_gmm_ptmsi_allocation(void)
-{
-	struct gprs_ra_id raid = { .mnc=332, .mcc=112, .lac=16464, .rac=96};
-	struct sgsn_mm_ctx *ctx = NULL;
-	struct sgsn_mm_ctx *ictx;
-	uint32_t foreign_tlli;
-	uint32_t ptmsi1;
-	uint32_t ptmsi2;
-	uint32_t received_ptmsi;
-	uint32_t old_ptmsi;
-	uint32_t local_tlli = 0;
-	struct gprs_llc_lle *lle;
-	const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy;
-
-	/* DTAP - Attach Request (IMSI 12131415161718) */
-	static const unsigned char attach_req[] = {
-		0x08, 0x01, 0x02, 0xf5, 0xe0, 0x21, 0x08, 0x02,
-		0x08, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
-		0x18, 0x11, 0x22, 0x33, 0x40, 0x50, 0x60, 0x19,
-		0x18, 0xb3, 0x43, 0x2b, 0x25, 0x96, 0x62, 0x00,
-		0x60, 0x80, 0x9a, 0xc2, 0xc6, 0x62, 0x00, 0x60,
-		0x80, 0xba, 0xc8, 0xc6, 0x62, 0x00, 0x60, 0x80,
-		0x00,
-	};
-
-	/* DTAP - Identity Response IMEI */
-	static const unsigned char ident_resp_imei[] = {
-		0x08, 0x16, 0x08, 0x9a, 0x78, 0x56, 0x34, 0x12, 0x90, 0x78,
-		0x56
-	};
-
-	/* DTAP - Attach Complete */
-	static const unsigned char attach_compl[] = {
-		0x08, 0x03
-	};
-
-	/* DTAP - Routing Area Update Request */
-	static const unsigned char ra_upd_req[] = {
-		0x08, 0x08, 0x10, 0x11, 0x22, 0x33, 0x40, 0x50,
-		0x60, 0x1d, 0x19, 0x13, 0x42, 0x33, 0x57, 0x2b,
-		0xf7, 0xc8, 0x48, 0x02, 0x13, 0x48, 0x50, 0xc8,
-		0x48, 0x02, 0x14, 0x48, 0x50, 0xc8, 0x48, 0x02,
-		0x17, 0x49, 0x10, 0xc8, 0x48, 0x02, 0x00, 0x19,
-		0x8b, 0xb2, 0x92, 0x17, 0x16, 0x27, 0x07, 0x04,
-		0x31, 0x02, 0xe5, 0xe0, 0x32, 0x02, 0x20, 0x00
-	};
-
-	/* DTAP - Routing Area Update Complete */
-	static const unsigned char ra_upd_complete[] = {
-		0x08, 0x0a
-	};
-
-	/* DTAP - Detach Request (MO) */
-	/* normal detach, power_off = 1 */
-	static const unsigned char detach_req[] = {
-		0x08, 0x05, 0x09, 0x18, 0x05, 0xf4, 0xef, 0xe2,
-		0xb7, 0x00, 0x19, 0x03, 0xb9, 0x97, 0xcb
-	};
-
-	sgsn->cfg.auth_policy = SGSN_AUTH_POLICY_OPEN;
-
-	printf("Testing P-TMSI allocation\n");
-
-	printf("  - sgsn_alloc_ptmsi\n");
-
-	/* reset the PRNG used by sgsn_alloc_ptmsi */
-	srand(1);
-
-	ptmsi1 = sgsn_alloc_ptmsi();
-	OSMO_ASSERT(ptmsi1 != GSM_RESERVED_TMSI);
-
-	ptmsi2 = sgsn_alloc_ptmsi();
-	OSMO_ASSERT(ptmsi2 != GSM_RESERVED_TMSI);
-
-	OSMO_ASSERT(ptmsi1 != ptmsi2);
-
-	ptmsi1 = ptmsi2 = GSM_RESERVED_TMSI;
-
-	printf("  - Repeated Attach Request\n");
-
-	foreign_tlli = gprs_tmsi2tlli(0xc0000023, TLLI_FOREIGN);
-
-	/* Create a LLE/LLME */
-	OSMO_ASSERT(count(gprs_llme_list()) == 0);
-	lle = gprs_lle_get_or_create(foreign_tlli, 3);
-	OSMO_ASSERT(count(gprs_llme_list()) == 1);
-
-	/* inject the attach request */
-	send_0408_message(lle->llme, foreign_tlli, &raid,
-			  attach_req, ARRAY_SIZE(attach_req));
-
-	ctx = sgsn_mm_ctx_by_tlli(foreign_tlli, &raid);
-	OSMO_ASSERT(ctx != NULL);
-	OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT);
-	OSMO_ASSERT(ctx->p_tmsi != GSM_RESERVED_TMSI);
-	ptmsi1 = ctx->p_tmsi;
-
-	old_ptmsi = ctx->p_tmsi_old;
-
-	/* we expect an identity request (IMEI) */
-	OSMO_ASSERT(sgsn_tx_counter == 1);
-
-	/* inject the identity response (IMEI) */
-	send_0408_message(ctx->gb.llme, foreign_tlli, &raid,
-			  ident_resp_imei, ARRAY_SIZE(ident_resp_imei));
-
-	/* check that the MM context has not been removed due to a failed
-	 * authorization */
-	OSMO_ASSERT(ctx == sgsn_mm_ctx_by_tlli(foreign_tlli, &raid));
-
-	OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT);
-	OSMO_ASSERT(ctx->p_tmsi == ptmsi1);
-
-	/* we expect an attach accept */
-	OSMO_ASSERT(sgsn_tx_counter == 1);
-	received_ptmsi = get_new_ptmsi(&last_dl_parse_ctx);
-	OSMO_ASSERT(received_ptmsi == ptmsi1);
-
-	/* we ignore this and send the attach again */
-	send_0408_message(lle->llme, foreign_tlli, &raid,
-			  attach_req, ARRAY_SIZE(attach_req));
-
-	/* the allocated P-TMSI should be the same */
-	ctx = sgsn_mm_ctx_by_tlli(foreign_tlli, &raid);
-	OSMO_ASSERT(ctx != NULL);
-	OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT);
-	OSMO_ASSERT(ctx->p_tmsi_old == old_ptmsi);
-	OSMO_ASSERT(ctx->p_tmsi == ptmsi1);
-
-	/* we expect an attach accept */
-	OSMO_ASSERT(sgsn_tx_counter == 1);
-	received_ptmsi = get_new_ptmsi(&last_dl_parse_ctx);
-	OSMO_ASSERT(received_ptmsi == ptmsi1);
-
-	/* inject the attach complete */
-	local_tlli = gprs_tmsi2tlli(ptmsi1, TLLI_LOCAL);
-	send_0408_message(ctx->gb.llme, local_tlli, &raid,
-			  attach_compl, ARRAY_SIZE(attach_compl));
-
-	/* we don't expect a response */
-	OSMO_ASSERT(sgsn_tx_counter == 0);
-
-	OSMO_ASSERT(ctx->gmm_state == GMM_REGISTERED_NORMAL);
-	OSMO_ASSERT(ctx->p_tmsi_old == 0);
-	OSMO_ASSERT(ctx->p_tmsi == ptmsi1);
-
-	printf("  - Repeated RA Update Request\n");
-
-	/* inject the RA update request */
-	send_0408_message(ctx->gb.llme, local_tlli, &raid,
-			  ra_upd_req, ARRAY_SIZE(ra_upd_req));
-
-	/* we expect an RA update accept */
-	OSMO_ASSERT(sgsn_tx_counter == 1);
-
-	OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT);
-	OSMO_ASSERT(ctx->p_tmsi_old == ptmsi1);
-	OSMO_ASSERT(ctx->p_tmsi != GSM_RESERVED_TMSI);
-	OSMO_ASSERT(ctx->p_tmsi != ptmsi1);
-	ptmsi2 = ctx->p_tmsi;
-
-	/* repeat the RA update request */
-	send_0408_message(ctx->gb.llme, local_tlli, &raid,
-			  ra_upd_req, ARRAY_SIZE(ra_upd_req));
-
-	/* we expect an RA update accept */
-	OSMO_ASSERT(sgsn_tx_counter == 1);
-	received_ptmsi = get_new_ptmsi(&last_dl_parse_ctx);
-	OSMO_ASSERT(received_ptmsi == ptmsi2);
-
-	OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT);
-	OSMO_ASSERT(ctx->p_tmsi_old == ptmsi1);
-	OSMO_ASSERT(ctx->p_tmsi == ptmsi2);
-
-	/* inject the RA update complete */
-	local_tlli = gprs_tmsi2tlli(ptmsi2, TLLI_LOCAL);
-	send_0408_message(ctx->gb.llme, local_tlli, &raid,
-			  ra_upd_complete, ARRAY_SIZE(ra_upd_complete));
-
-	/* we don't expect a response */
-	OSMO_ASSERT(sgsn_tx_counter == 0);
-
-	OSMO_ASSERT(ctx->gmm_state == GMM_REGISTERED_NORMAL);
-	OSMO_ASSERT(ctx->p_tmsi_old == 0);
-	OSMO_ASSERT(ctx->p_tmsi == ptmsi2);
-
-	/* inject the detach */
-	send_0408_message(ctx->gb.llme, local_tlli, &raid,
-			  detach_req, ARRAY_SIZE(detach_req));
-
-	/* verify that things are gone */
-	OSMO_ASSERT(count(gprs_llme_list()) == 0);
-	ictx = sgsn_mm_ctx_by_tlli(local_tlli, &raid);
-	OSMO_ASSERT(!ictx);
-
-	sgsn->cfg.auth_policy = saved_auth_policy;
-
-	cleanup_test();
-}
-
-/*
- * Test changing of routing areas
- */
-static void test_gmm_routing_areas(void)
-{
-	struct gprs_ra_id raid1 = { .mnc=332, .mcc=112, .lac=16464, .rac=96};
-	struct gprs_ra_id raid2 = { .mnc=332, .mcc=112, .lac=16464, .rac=97};
-	struct sgsn_mm_ctx *ctx = NULL;
-	struct sgsn_mm_ctx *ictx;
-	uint32_t ptmsi1;
-	uint32_t received_ptmsi;
-	uint32_t ms_tlli = 0;
-	struct gprs_llc_lle *lle;
-	const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy;
-
-	/* DTAP - Attach Request (IMSI 12131415161718) */
-	static const unsigned char attach_req[] = {
-		0x08, 0x01, 0x02, 0xf5, 0xe0, 0x21, 0x08, 0x02,
-		0x08, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
-		0x18, 0x11, 0x22, 0x33, 0x40, 0x50, 0x60, 0x19,
-		0x18, 0xb3, 0x43, 0x2b, 0x25, 0x96, 0x62, 0x00,
-		0x60, 0x80, 0x9a, 0xc2, 0xc6, 0x62, 0x00, 0x60,
-		0x80, 0xba, 0xc8, 0xc6, 0x62, 0x00, 0x60, 0x80,
-		0x00,
-	};
-
-	/* DTAP - Attach Request (IMSI 12131415161718) (RA 2) */
-	static const unsigned char attach_req2[] = {
-		0x08, 0x01, 0x02, 0xf5, 0xe0, 0x21, 0x08, 0x02,
-		0x08, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
-		0x18, 0x11, 0x22, 0x33, 0x40, 0x50, 0x61, 0x19,
-		0x18, 0xb3, 0x43, 0x2b, 0x25, 0x96, 0x62, 0x00,
-		0x60, 0x80, 0x9a, 0xc2, 0xc6, 0x62, 0x00, 0x60,
-		0x80, 0xba, 0xc8, 0xc6, 0x62, 0x00, 0x60, 0x80,
-		0x00,
-	};
-
-	/* DTAP - Identity Response IMEI */
-	static const unsigned char ident_resp_imei[] = {
-		0x08, 0x16, 0x08, 0x9a, 0x78, 0x56, 0x34, 0x12, 0x90, 0x78,
-		0x56
-	};
-
-	/* DTAP - Attach Complete */
-	static const unsigned char attach_compl[] = {
-		0x08, 0x03
-	};
-
-	/* DTAP - Routing Area Update Request (coming from RA 1) */
-	static const unsigned char ra_upd_req1[] = {
-		0x08, 0x08, 0x10, 0x11, 0x22, 0x33, 0x40, 0x50,
-		0x60, 0x1d, 0x19, 0x13, 0x42, 0x33, 0x57, 0x2b,
-		0xf7, 0xc8, 0x48, 0x02, 0x13, 0x48, 0x50, 0xc8,
-		0x48, 0x02, 0x14, 0x48, 0x50, 0xc8, 0x48, 0x02,
-		0x17, 0x49, 0x10, 0xc8, 0x48, 0x02, 0x00, 0x19,
-		0x8b, 0xb2, 0x92, 0x17, 0x16, 0x27, 0x07, 0x04,
-		0x31, 0x02, 0xe5, 0xe0, 0x32, 0x02, 0x20, 0x00
-	};
-
-	/* DTAP - Routing Area Update Request (coming from RA 2) */
-	static const unsigned char ra_upd_req2[] = {
-		0x08, 0x08, 0x10, 0x11, 0x22, 0x33, 0x40, 0x50,
-		0x61, 0x1d, 0x19, 0x13, 0x42, 0x33, 0x57, 0x2b,
-		0xf7, 0xc8, 0x48, 0x02, 0x13, 0x48, 0x50, 0xc8,
-		0x48, 0x02, 0x14, 0x48, 0x50, 0xc8, 0x48, 0x02,
-		0x17, 0x49, 0x10, 0xc8, 0x48, 0x02, 0x00, 0x19,
-		0x8b, 0xb2, 0x92, 0x17, 0x16, 0x27, 0x07, 0x04,
-		0x31, 0x02, 0xe5, 0xe0, 0x32, 0x02, 0x20, 0x00
-	};
-
-	/* DTAP - Routing Area Update Request (coming from RA other) */
-	/* raid_other = {443, 223, 16464, 98}; */
-	static const unsigned char ra_upd_req_other[] = {
-		0x08, 0x08, 0x10, 0x22, 0x33, 0x44, 0x40, 0x50,
-		0x62, 0x1d, 0x19, 0x13, 0x42, 0x33, 0x57, 0x2b,
-		0xf7, 0xc8, 0x48, 0x02, 0x13, 0x48, 0x50, 0xc8,
-		0x48, 0x02, 0x14, 0x48, 0x50, 0xc8, 0x48, 0x02,
-		0x17, 0x49, 0x10, 0xc8, 0x48, 0x02, 0x00, 0x19,
-		0x8b, 0xb2, 0x92, 0x17, 0x16, 0x27, 0x07, 0x04,
-		0x31, 0x02, 0xe5, 0xe0, 0x32, 0x02, 0x20, 0x00
-	};
-
-	/* DTAP - Routing Area Update Complete */
-	static const unsigned char ra_upd_complete[] = {
-		0x08, 0x0a
-	};
-
-	/* DTAP - Detach Request (MO) */
-	/* normal detach, power_off = 1 */
-	static const unsigned char detach_req[] = {
-		0x08, 0x05, 0x09, 0x18, 0x05, 0xf4, 0xef, 0xe2,
-		0xb7, 0x00, 0x19, 0x03, 0xb9, 0x97, 0xcb
-	};
-
-	sgsn->cfg.auth_policy = SGSN_AUTH_POLICY_OPEN;
-
-	printf("Testing routing area changes\n");
-
-	/* reset the PRNG used by sgsn_alloc_ptmsi */
-	srand(1);
-
-	ptmsi1 = GSM_RESERVED_TMSI;
-
-	printf("  - Attach Request (RA 1)\n");
-
-	ms_tlli = gprs_tmsi2tlli(0x00000023, TLLI_RANDOM);
-
-	/* Create a LLE/LLME */
-	OSMO_ASSERT(count(gprs_llme_list()) == 0);
-	lle = gprs_lle_get_or_create(ms_tlli, 3);
-	OSMO_ASSERT(count(gprs_llme_list()) == 1);
-
-	/* inject the attach request */
-	send_0408_message(lle->llme, ms_tlli, &raid1,
-			  attach_req, ARRAY_SIZE(attach_req));
-
-	ctx = sgsn_mm_ctx_by_tlli(ms_tlli, &raid1);
-	OSMO_ASSERT(ctx != NULL);
-	OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT);
-	OSMO_ASSERT(ctx->p_tmsi != GSM_RESERVED_TMSI);
-
-	/* we expect an identity request (IMEI) */
-	OSMO_ASSERT(sgsn_tx_counter == 1);
-	OSMO_ASSERT(last_dl_parse_ctx.g48_hdr->msg_type == GSM48_MT_GMM_ID_REQ);
-	OSMO_ASSERT(last_dl_parse_ctx.tlli == ms_tlli);
-
-	/* inject the identity response (IMEI) */
-	send_0408_message(ctx->gb.llme, ms_tlli, &raid1,
-			  ident_resp_imei, ARRAY_SIZE(ident_resp_imei));
-
-	/* check that the MM context has not been removed due to a failed
-	 * authorization */
-	OSMO_ASSERT(ctx == sgsn_mm_ctx_by_tlli(ms_tlli, &raid1));
-
-	OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT);
-
-	/* we expect an attach accept */
-	OSMO_ASSERT(sgsn_tx_counter == 1);
-	OSMO_ASSERT(last_dl_parse_ctx.g48_hdr->msg_type == GSM48_MT_GMM_ATTACH_ACK);
-	OSMO_ASSERT(last_dl_parse_ctx.tlli == ms_tlli);
-
-	received_ptmsi = get_new_ptmsi(&last_dl_parse_ctx);
-	OSMO_ASSERT(received_ptmsi == ctx->p_tmsi);
-	ptmsi1 = received_ptmsi;
-
-	/* inject the attach complete */
-	ms_tlli = gprs_tmsi2tlli(ptmsi1, TLLI_LOCAL);
-	send_0408_message(ctx->gb.llme, ms_tlli, &raid1,
-			  attach_compl, ARRAY_SIZE(attach_compl));
-
-	/* we don't expect a response */
-	OSMO_ASSERT(sgsn_tx_counter == 0);
-
-	OSMO_ASSERT(ctx->gmm_state == GMM_REGISTERED_NORMAL);
-	OSMO_ASSERT(ctx->p_tmsi_old == 0);
-	OSMO_ASSERT(ctx->p_tmsi == ptmsi1);
-
-	printf("  - RA Update Request (RA 1 -> RA 1)\n");
-
-	/* inject the RA update request */
-	send_0408_message(ctx->gb.llme, ms_tlli, &raid1,
-			  ra_upd_req1, ARRAY_SIZE(ra_upd_req1));
-
-	/* we expect an RA update accept */
-	OSMO_ASSERT(sgsn_tx_counter == 1);
-	OSMO_ASSERT(last_dl_parse_ctx.g48_hdr->msg_type == GSM48_MT_GMM_RA_UPD_ACK);
-	// OSMO_ASSERT(last_dl_parse_ctx.tlli == ms_tlli);
-
-	OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT);
-	OSMO_ASSERT(ctx->p_tmsi_old == ptmsi1);
-	OSMO_ASSERT(ctx->p_tmsi != GSM_RESERVED_TMSI);
-	OSMO_ASSERT(ctx->p_tmsi != ptmsi1);
-
-	received_ptmsi = get_new_ptmsi(&last_dl_parse_ctx);
-	OSMO_ASSERT(received_ptmsi == ctx->p_tmsi);
-	ptmsi1 = received_ptmsi;
-
-	/* inject the RA update complete */
-	ms_tlli = gprs_tmsi2tlli(ptmsi1, TLLI_LOCAL);
-	send_0408_message(ctx->gb.llme, ms_tlli, &raid1,
-			  ra_upd_complete, ARRAY_SIZE(ra_upd_complete));
-
-	/* we don't expect a response */
-	OSMO_ASSERT(sgsn_tx_counter == 0);
-
-	OSMO_ASSERT(ctx->gmm_state == GMM_REGISTERED_NORMAL);
-	OSMO_ASSERT(ctx->p_tmsi_old == 0);
-	OSMO_ASSERT(ctx->p_tmsi == ptmsi1);
-	OSMO_ASSERT(ctx->gb.tlli == ms_tlli);
-
-	printf("  - RA Update Request (RA 1 -> RA 2)\n");
-
-	/* inject the RA update request */
-	ms_tlli = gprs_tmsi2tlli(ptmsi1, TLLI_FOREIGN);
-
-	/* It is coming from RA 1 => ra_upd_req1 */
-	send_0408_message(ctx->gb.llme, ms_tlli, &raid2,
-			  ra_upd_req1, ARRAY_SIZE(ra_upd_req1));
-
-	/* we expect an RA update accept */
-	OSMO_ASSERT(sgsn_tx_counter == 1);
-	OSMO_ASSERT(last_dl_parse_ctx.g48_hdr->msg_type == GSM48_MT_GMM_RA_UPD_ACK);
-
-	printf("  - RA Update Request (RA other -> RA 2)\n");
-
-	/* inject the RA update request */
-	ms_tlli = gprs_tmsi2tlli(0x12345678, TLLI_FOREIGN);
-
-	/* It is coming from RA 1 => ra_upd_req1 */
-	send_0408_message(ctx->gb.llme, ms_tlli, &raid2,
-			  ra_upd_req_other, ARRAY_SIZE(ra_upd_req_other));
-
-	/* we expect an RA update reject (and a LLC XID RESET) */
-	OSMO_ASSERT(sgsn_tx_counter == 2);
-	OSMO_ASSERT(last_dl_parse_ctx.g48_hdr->msg_type == GSM48_MT_GMM_RA_UPD_REJ);
-	/* this has killed the LLE/LLME */
-
-	printf("  - Attach Request (RA 2)\n");
-
-	/* Create a LLE/LLME */
-	OSMO_ASSERT(count(gprs_llme_list()) == 1);
-	lle = gprs_lle_get_or_create(ms_tlli, 3);
-	OSMO_ASSERT(count(gprs_llme_list()) == 1);
-
-	/* inject the attach request */
-	send_0408_message(lle->llme, ms_tlli, &raid2,
-			  attach_req2, ARRAY_SIZE(attach_req2));
-
-	ctx = sgsn_mm_ctx_by_tlli(ms_tlli, &raid2);
-	OSMO_ASSERT(ctx != NULL);
-	OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT);
-	OSMO_ASSERT(ctx->p_tmsi != GSM_RESERVED_TMSI);
-
-	/* we expect an attach accept */
-	OSMO_ASSERT(sgsn_tx_counter == 1);
-	OSMO_ASSERT(last_dl_parse_ctx.g48_hdr->msg_type == GSM48_MT_GMM_ATTACH_ACK);
-
-	received_ptmsi = get_new_ptmsi(&last_dl_parse_ctx);
-	OSMO_ASSERT(received_ptmsi == ctx->p_tmsi);
-	ptmsi1 = received_ptmsi;
-
-	/* inject the attach complete */
-	ms_tlli = gprs_tmsi2tlli(ptmsi1, TLLI_LOCAL);
-	ictx = sgsn_mm_ctx_by_tlli(ms_tlli, &raid2);
-	OSMO_ASSERT(ictx != NULL);
-	OSMO_ASSERT(ictx == ctx);
-
-	send_0408_message(ctx->gb.llme, ms_tlli, &raid2,
-			  attach_compl, ARRAY_SIZE(attach_compl));
-
-	/* we don't expect a response */
-	OSMO_ASSERT(sgsn_tx_counter == 0);
-
-	OSMO_ASSERT(ctx->gmm_state == GMM_REGISTERED_NORMAL);
-	OSMO_ASSERT(ctx->p_tmsi_old == 0);
-	OSMO_ASSERT(ctx->p_tmsi == ptmsi1);
-
-	printf("  - RA Update Request (RA 2 -> RA 2)\n");
-
-	/* inject the RA update request */
-	send_0408_message(ctx->gb.llme, ms_tlli, &raid2,
-			  ra_upd_req2, ARRAY_SIZE(ra_upd_req2));
-
-	/* we expect an RA update accept */
-	OSMO_ASSERT(sgsn_tx_counter == 1);
-	OSMO_ASSERT(last_dl_parse_ctx.g48_hdr->msg_type == GSM48_MT_GMM_RA_UPD_ACK);
-
-	OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT);
-	OSMO_ASSERT(ctx->p_tmsi_old == ptmsi1);
-	OSMO_ASSERT(ctx->p_tmsi != GSM_RESERVED_TMSI);
-	OSMO_ASSERT(ctx->p_tmsi != ptmsi1);
-
-	received_ptmsi = get_new_ptmsi(&last_dl_parse_ctx);
-	OSMO_ASSERT(received_ptmsi == ctx->p_tmsi);
-	ptmsi1 = received_ptmsi;
-
-	/* inject the RA update complete */
-	ms_tlli = gprs_tmsi2tlli(ptmsi1, TLLI_LOCAL);
-	send_0408_message(ctx->gb.llme, ms_tlli, &raid2,
-			  ra_upd_complete, ARRAY_SIZE(ra_upd_complete));
-
-	/* we don't expect a response */
-	OSMO_ASSERT(sgsn_tx_counter == 0);
-
-	OSMO_ASSERT(ctx->gmm_state == GMM_REGISTERED_NORMAL);
-	OSMO_ASSERT(ctx->p_tmsi_old == 0);
-	OSMO_ASSERT(ctx->p_tmsi == ptmsi1);
-	OSMO_ASSERT(ctx->gb.tlli == ms_tlli);
-
-
-	/* inject the detach */
-	send_0408_message(ctx->gb.llme, ms_tlli, &raid2,
-			  detach_req, ARRAY_SIZE(detach_req));
-
-	/* verify that things are gone */
-	OSMO_ASSERT(count(gprs_llme_list()) == 0);
-	ictx = sgsn_mm_ctx_by_tlli(ms_tlli, &raid2);
-	OSMO_ASSERT(!ictx);
-
-	sgsn->cfg.auth_policy = saved_auth_policy;
-
-	cleanup_test();
-}
-
 static void test_apn_matching(void)
 {
 	struct apn_ctx *actx, *actxs[9];
@@ -2462,17 +1653,8 @@
 	test_gmm_detach_no_mmctx();
 	test_gmm_detach_accept_unexpected();
 	test_gmm_status_no_mmctx();
-	test_gmm_attach_acl();
-	test_gmm_attach_subscr();
-	test_gmm_attach_subscr_fake_auth();
-	test_gmm_attach_subscr_real_auth();
-	test_gmm_attach_subscr_gsup_auth(0);
-	test_gmm_attach_subscr_gsup_auth(1);
-	test_gmm_attach_subscr_real_gsup_auth(0);
 	test_gmm_reject();
 	test_gmm_cancel();
-	test_gmm_ptmsi_allocation();
-	test_gmm_routing_areas();
 	test_apn_matching();
 	test_ggsn_selection();
 	printf("Done\n");
diff --git a/tests/sgsn/sgsn_test.ok b/tests/sgsn/sgsn_test.ok
index f38d730..e7e7cf6 100644
--- a/tests/sgsn/sgsn_test.ok
+++ b/tests/sgsn/sgsn_test.ok
@@ -15,13 +15,6 @@
 Testing GMM detach (no MMCTX)
 Testing GMM detach accept (unexpected)
 Testing GMM Status (no MMCTX)
-Auth policy 'closed': Testing GMM attach
-Auth policy 'remote': Testing GMM attach
-Auth policy 'remote', auth faked: Testing GMM attach
-Auth policy 'remote', triplet based auth: Testing GMM attach
-Auth policy 'remote', GSUP based auth: Testing GMM attach
-Auth policy 'remote', GSUP based auth: Testing GMM attach with retry
-Auth policy 'remote', real GSUP based auth: Testing GMM attach
 Testing GMM reject
   - Attach Request (invalid MI length)
   - Attach Request (invalid MI type)
@@ -29,17 +22,6 @@
   - Routing Area Update Request (invalid type)
   - Routing Area Update Request (invalid CAP length)
 Testing cancellation
-Testing P-TMSI allocation
-  - sgsn_alloc_ptmsi
-  - Repeated Attach Request
-  - Repeated RA Update Request
-Testing routing area changes
-  - Attach Request (RA 1)
-  - RA Update Request (RA 1 -> RA 1)
-  - RA Update Request (RA 1 -> RA 2)
-  - RA Update Request (RA other -> RA 2)
-  - Attach Request (RA 2)
-  - RA Update Request (RA 2 -> RA 2)
 Testing APN matching
 Testing GGSN selection
 Done

-- 
To view, visit https://gerrit.osmocom.org/9258
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Iac1c8854b5ea4aa03279990390ebc110c979aac2
Gerrit-Change-Number: 9258
Gerrit-PatchSet: 6
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-CC: Vadim Yanitskiy <axilirator at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180913/2799d36f/attachment.htm>


More information about the gerrit-log mailing list