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
diff --git a/tests/db/db_test.c b/tests/db/db_test.c
index 4a0f3e8..bbc728e 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_gsup_peer_id vlr; \
+ OSMO_ASSERT(!osmo_gsup_peer_id_set_str(&vlr, OSMO_GSUP_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_gsup_peer_id vlr; \
+ OSMO_ASSERT(!osmo_gsup_peer_id_set_str(&vlr, OSMO_GSUP_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 = {
@@ -998,6 +1042,7 @@
test_subscr_aud();
test_subscr_aud_invalid_len();
test_subscr_sqn();
+ test_ind();
printf("Done\n");
db_close(dbc);