[MERGED] osmo-msc[master]: cosmetic: vlr: rename auth_tuple_max_use_count to _reuse_

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

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Tue Oct 31 01:03:46 UTC 2017


Neels Hofmeyr has submitted this change and it was merged.

Change subject: cosmetic: vlr: rename auth_tuple_max_use_count to _reuse_
......................................................................


cosmetic: vlr: rename auth_tuple_max_use_count to _reuse_

The name auth_tuple_max_use_count suggests that if I want to use each auth
tuple exactly once, I need to set it to 1. Curiously, so far you need to set
to intended uses - 1.

Reflect this in its name by renaming to auth_tuple_max_reuse_count.

I first considered to not rename but change the if-conditions so that == 1
means each tuple is used once, and upon struct vlr allocation, set the default
to 1. That would also logically entail that setting to 0 means to re-use
vectors infinitely often, like now a value < 0 does. That means, when
allocating a vlr struct zeroed out, we would by default have the most
dangerous/unsafe configuration. It's no problem to set a default to 1 upon
allocation, but by renaming the variable instead, we get safer alloc-zero
behavior and don't need to change any conditionals in the code (even though the
patch ends up considerably larger from all the renaming).

Change-Id: I0b036cae1536d5d6fb2304f837ed1a6c3713be55
---
M include/osmocom/msc/vlr.h
M src/libvlr/vlr_auth_fsm.c
M tests/msc_vlr/msc_vlr_test_hlr_reject.c
3 files changed, 21 insertions(+), 21 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved



diff --git a/include/osmocom/msc/vlr.h b/include/osmocom/msc/vlr.h
index e9afde3..d5306fa 100644
--- a/include/osmocom/msc/vlr.h
+++ b/include/osmocom/msc/vlr.h
@@ -222,7 +222,7 @@
 		bool retrieve_imeisv_ciphered;
 		bool assign_tmsi;
 		bool check_imei_rqd;
-		int auth_tuple_max_use_count;
+		int auth_tuple_max_reuse_count;
 		bool auth_reuse_old_sets_on_error;
 		bool parq_retrieve_imsi;
 		bool is_ps;
diff --git a/src/libvlr/vlr_auth_fsm.c b/src/libvlr/vlr_auth_fsm.c
index 1c9e191..f07e60f 100644
--- a/src/libvlr/vlr_auth_fsm.c
+++ b/src/libvlr/vlr_auth_fsm.c
@@ -59,7 +59,7 @@
 	bool is_utran;
 	bool auth_requested;
 
-	int auth_tuple_max_use_count; /* see vlr->cfg instead */
+	int auth_tuple_max_reuse_count; /* see vlr->cfg instead */
 };
 
 /***********************************************************************
@@ -69,13 +69,13 @@
 /* Always use either vlr_subscr_get_auth_tuple() or vlr_subscr_has_auth_tuple()
  * instead, to ensure proper use count.
  * Return an auth tuple with the lowest use_count among the auth tuples. If
- * max_use_count >= 0, return NULL if all available auth tuples have a use
- * count > max_use_count. If max_use_count is negative, return a currently
+ * max_reuse_count >= 0, return NULL if all available auth tuples have a use
+ * count > max_reuse_count. If max_reuse_count is negative, return a currently
  * least used auth tuple without enforcing a maximum use count.  If there are
  * no auth tuples, return NULL.
  */
 static struct gsm_auth_tuple *
-_vlr_subscr_next_auth_tuple(struct vlr_subscr *vsub, int max_use_count)
+_vlr_subscr_next_auth_tuple(struct vlr_subscr *vsub, int max_reuse_count)
 {
 	unsigned int count;
 	unsigned int idx;
@@ -104,7 +104,7 @@
 			at = &vsub->auth_tuples[idx];
 	}
 
-	if (!at || (max_use_count >= 0 && at->use_count > max_use_count))
+	if (!at || (max_reuse_count >= 0 && at->use_count > max_reuse_count))
 		return NULL;
 
 	return at;
@@ -112,21 +112,21 @@
 
 /* Return an auth tuple and increment its use count. */
 static struct gsm_auth_tuple *
-vlr_subscr_get_auth_tuple(struct vlr_subscr *vsub, int max_use_count)
+vlr_subscr_get_auth_tuple(struct vlr_subscr *vsub, int max_reuse_count)
 {
 	struct gsm_auth_tuple *at = _vlr_subscr_next_auth_tuple(vsub,
-							       max_use_count);
+							       max_reuse_count);
 	if (!at)
 		return NULL;
 	at->use_count++;
 	return at;
 }
 
-/* Return whether an auth tuple with the given max_use_count is available. */
+/* Return whether an auth tuple with a matching use_count is available. */
 static bool vlr_subscr_has_auth_tuple(struct vlr_subscr *vsub,
-				      int max_use_count)
+				      int max_reuse_count)
 {
-	return _vlr_subscr_next_auth_tuple(vsub, max_use_count) != NULL;
+	return _vlr_subscr_next_auth_tuple(vsub, max_reuse_count) != NULL;
 }
 
 static bool check_auth_resp(struct vlr_subscr *vsub, bool is_r99,
@@ -250,7 +250,7 @@
 	struct gsm_auth_tuple *at;
 
 	/* Caller ensures we have vectors available */
-	at = vlr_subscr_get_auth_tuple(vsub, afp->auth_tuple_max_use_count);
+	at = vlr_subscr_get_auth_tuple(vsub, afp->auth_tuple_max_reuse_count);
 	if (!at) {
 		LOGPFSML(fi, LOGL_ERROR, "A previous check ensured that an"
 			 " auth tuple was available, but now there is in fact"
@@ -284,12 +284,12 @@
 
 	OSMO_ASSERT(event == VLR_AUTH_E_START);
 
-	/* Start off with the default max_use_count, possibly change that if we
+	/* Start off with the default max_reuse_count, possibly change that if we
 	 * need to re-use an old tuple. */
-	afp->auth_tuple_max_use_count = vsub->vlr->cfg.auth_tuple_max_use_count;
+	afp->auth_tuple_max_reuse_count = vsub->vlr->cfg.auth_tuple_max_reuse_count;
 
 	/* Check if we have vectors available */
-	if (!vlr_subscr_has_auth_tuple(vsub, afp->auth_tuple_max_use_count)) {
+	if (!vlr_subscr_has_auth_tuple(vsub, afp->auth_tuple_max_reuse_count)) {
 		/* Obtain_Authentication_Sets_VLR */
 		vlr_subscr_req_sai(vsub, NULL, NULL);
 		osmo_fsm_inst_state_chg(fi, VLR_SUB_AS_NEEDS_AUTH_WAIT_AI,
@@ -323,9 +323,9 @@
 	    || (event == VLR_AUTH_E_HLR_SAI_ABORT)) {
 		if (vsub->vlr->cfg.auth_reuse_old_sets_on_error
 		    && vlr_subscr_has_auth_tuple(vsub, -1)) {
-			/* To re-use an old tuple, disable the max_use_count
+			/* To re-use an old tuple, disable the max_reuse_count
 			 * constraint. */
-			afp->auth_tuple_max_use_count = -1;
+			afp->auth_tuple_max_reuse_count = -1;
 			goto pass;
 		}
 		/* result = procedure error */
diff --git a/tests/msc_vlr/msc_vlr_test_hlr_reject.c b/tests/msc_vlr/msc_vlr_test_hlr_reject.c
index 095da81..6cf4afc 100644
--- a/tests/msc_vlr/msc_vlr_test_hlr_reject.c
+++ b/tests/msc_vlr/msc_vlr_test_hlr_reject.c
@@ -84,7 +84,7 @@
 
 	net->authentication_required = true;
 	net->vlr->cfg.auth_reuse_old_sets_on_error = false;
-	net->vlr->cfg.auth_tuple_max_use_count = 0;
+	net->vlr->cfg.auth_tuple_max_reuse_count = 0;
 
 	BTW("Submit a used auth tuple in the VLR");
 	btw("Location Update request causes a GSUP Send Auth Info request to HLR");
@@ -171,7 +171,7 @@
 
 	net->authentication_required = true;
 	net->vlr->cfg.auth_reuse_old_sets_on_error = true;
-	net->vlr->cfg.auth_tuple_max_use_count = 0;
+	net->vlr->cfg.auth_tuple_max_reuse_count = 0;
 
 	BTW("Submit a used auth tuple in the VLR");
 	btw("Location Update request causes a GSUP Send Auth Info request to HLR");
@@ -256,7 +256,7 @@
 
 	net->authentication_required = true;
 	net->vlr->cfg.auth_reuse_old_sets_on_error = true;
-	net->vlr->cfg.auth_tuple_max_use_count = 0;
+	net->vlr->cfg.auth_tuple_max_reuse_count = 0;
 
 	btw("Location Update request causes a GSUP Send Auth Info request to HLR");
 	lu_result_sent = RES_NONE;
@@ -291,7 +291,7 @@
 
 	net->authentication_required = true;
 	net->vlr->cfg.auth_reuse_old_sets_on_error = true;
-	net->vlr->cfg.auth_tuple_max_use_count = 0;
+	net->vlr->cfg.auth_tuple_max_reuse_count = 0;
 
 	BTW("Submit a used auth tuple in the VLR");
 	btw("Location Update request causes a GSUP Send Auth Info request to HLR");

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I0b036cae1536d5d6fb2304f837ed1a6c3713be55
Gerrit-PatchSet: 2
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list