aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeith <keith@rhizomatica.org>2023-01-06 20:30:39 +0100
committerKeith Whyte <keith@rhizomatica.org>2023-11-22 19:56:48 +0000
commit90be671102c424eb44c30e600d07f6cca764693c (patch)
tree0b20c83e66074b66ceb090fddd5e607128d78b12
parent193306896a312790b441c3650cc6ee16899da236 (diff)
Implement subscriber-create-on-demand fallback
If the mslookup client gets no response with the configured timeout, then go ahead and create a local subscriber if subscriber-create-on-demand is so configured. Change-Id: I3755baa393f6cc6b766abf90ba0f3a062e4c0f5f
-rw-r--r--include/osmocom/hlr/hlr.h2
-rw-r--r--include/osmocom/hlr/proxy.h2
-rw-r--r--src/dgsm.c6
-rw-r--r--src/dgsm_vty.c22
-rw-r--r--src/hlr.c12
-rw-r--r--src/proxy.c13
6 files changed, 54 insertions, 3 deletions
diff --git a/include/osmocom/hlr/hlr.h b/include/osmocom/hlr/hlr.h
index badcf12..4ec5064 100644
--- a/include/osmocom/hlr/hlr.h
+++ b/include/osmocom/hlr/hlr.h
@@ -119,6 +119,7 @@ struct hlr {
char *domain_suffix;
struct osmo_mslookup_client_method *running;
} mdns;
+ bool subscr_create_on_demand_fallback;
} client;
bool auth_imsi_only;
bool ignore_created_on_demand;
@@ -131,3 +132,4 @@ struct hlr_subscriber;
void osmo_hlr_subscriber_update_notify(struct hlr_subscriber *subscr);
int hlr_subscr_nam(struct hlr *hlr, struct hlr_subscriber *subscr, bool nam_val, bool is_ps);
+void dgsm_fallback_to_hlr();
diff --git a/include/osmocom/hlr/proxy.h b/include/osmocom/hlr/proxy.h
index 0169038..eab3d77 100644
--- a/include/osmocom/hlr/proxy.h
+++ b/include/osmocom/hlr/proxy.h
@@ -71,6 +71,8 @@ void proxy_init(struct osmo_gsup_server *gsup_server_to_vlr);
void proxy_del(struct proxy *proxy);
void proxy_set_gc_period(struct proxy *proxy, uint32_t gc_period);
+struct osmo_gsup_req *proxy_deferred_gsup_req_get_by_imsi(struct proxy *proxy, const char *imsi);
+
/* The API to access / modify proxy entries keeps the implementation opaque, to make sure that we can easily move proxy
* storage to SQLite db. */
int proxy_subscr_get_by_imsi(struct proxy_subscr *dst, struct proxy *proxy, const char *imsi);
diff --git a/src/dgsm.c b/src/dgsm.c
index 50b3773..a798512 100644
--- a/src/dgsm.c
+++ b/src/dgsm.c
@@ -58,6 +58,12 @@ static void resolve_hlr_result_cb(struct osmo_mslookup_client *client,
if (result->rc != OSMO_MSLOOKUP_RC_RESULT) {
LOG_DGSM(query->id.imsi, LOGL_ERROR, "Failed to resolve remote HLR: %s\n",
osmo_mslookup_result_name_c(OTC_SELECT, query, result));
+ if (g_hlr->mslookup.client.subscr_create_on_demand_fallback &&
+ db_subscr_exists_by_imsi(g_hlr->dbc, query->id.imsi) != 0) {
+ struct osmo_gsup_req *req = proxy_deferred_gsup_req_get_by_imsi(proxy, query->id.imsi);
+ if (req && req->gsup.message_type == OSMO_GSUP_MSGT_CHECK_IMEI_REQUEST)
+ dgsm_fallback_to_hlr(req);
+ }
proxy_subscr_del(proxy, query->id.imsi);
return;
}
diff --git a/src/dgsm_vty.c b/src/dgsm_vty.c
index 6b0648d..4c686da 100644
--- a/src/dgsm_vty.c
+++ b/src/dgsm_vty.c
@@ -386,6 +386,24 @@ DEFUN(cfg_mslookup_no_client,
return CMD_SUCCESS;
}
+DEFUN(cfg_mslookup_client_subscr_cod_fallback,
+ cfg_mslookup_client_subscr_cod_fallback_cmd,
+ "create-on-demand-fallback",
+ "If the msclient does not get a response from mDNS, proceed according to this HLR subscriber-create-on-demand config")
+{
+ g_hlr->mslookup.client.subscr_create_on_demand_fallback = true;
+ return CMD_SUCCESS;
+}
+
+DEFUN(cfg_mslookup_client_no_subscr_cod_fallback,
+ cfg_mslookup_client_no_subscr_cod_fallback_cmd,
+ "no create-on-demand-fallback",
+ NO_STR "Return IMSI UNKNOWN if the mslookup client does not receive a response from mDNS")
+{
+ g_hlr->mslookup.client.subscr_create_on_demand_fallback = false;
+ return CMD_SUCCESS;
+}
+
DEFUN(cfg_mslookup_client_timeout,
cfg_mslookup_client_timeout_cmd,
"timeout <1-100000>",
@@ -520,6 +538,8 @@ int config_write_mslookup(struct vty *vty)
vty_out(vty, " timeout %u%s",
g_hlr->mslookup.client.result_timeout_milliseconds,
VTY_NEWLINE);
+ if (g_hlr->mslookup.client.subscr_create_on_demand_fallback)
+ vty_out(vty, " create-on-demand-fallback%s", VTY_NEWLINE);
}
return CMD_SUCCESS;
@@ -618,6 +638,8 @@ void dgsm_vty_init(void)
install_element(MSLOOKUP_NODE, &cfg_mslookup_client_cmd);
install_element(MSLOOKUP_NODE, &cfg_mslookup_no_client_cmd);
install_node(&mslookup_client_node, NULL);
+ install_element(MSLOOKUP_CLIENT_NODE, &cfg_mslookup_client_subscr_cod_fallback_cmd);
+ install_element(MSLOOKUP_CLIENT_NODE, &cfg_mslookup_client_no_subscr_cod_fallback_cmd);
install_element(MSLOOKUP_CLIENT_NODE, &cfg_mslookup_client_timeout_cmd);
install_element(MSLOOKUP_CLIENT_NODE, &cfg_mslookup_client_mdns_bind_cmd);
install_element(MSLOOKUP_CLIENT_NODE, &cfg_mslookup_client_mdns_domain_suffix_cmd);
diff --git a/src/hlr.c b/src/hlr.c
index 457850e..1b0b3cb 100644
--- a/src/hlr.c
+++ b/src/hlr.c
@@ -379,7 +379,7 @@ static int rx_purge_ms_req(struct osmo_gsup_req *req)
return rc;
}
-static int rx_check_imei_req(struct osmo_gsup_req *req)
+static int rx_check_imei_req(struct osmo_gsup_req *req, bool final)
{
struct osmo_gsup_message gsup_reply;
char imei[GSM23003_IMEI_NUM_DIGITS_NO_CHK+1] = {0};
@@ -433,7 +433,7 @@ static int rx_check_imei_req(struct osmo_gsup_req *req)
.message_type = OSMO_GSUP_MSGT_CHECK_IMEI_RESULT,
.imei_result = OSMO_GSUP_IMEI_RESULT_ACK,
};
- return osmo_gsup_req_respond(req, &gsup_reply, false, true);
+ return osmo_gsup_req_respond(req, &gsup_reply, false, final);
}
static char namebuf[255];
@@ -554,7 +554,7 @@ static int read_cb(struct osmo_gsup_conn *conn, struct msgb *msg)
lu_rx_gsup(req);
break;
case OSMO_GSUP_MSGT_CHECK_IMEI_REQUEST:
- rx_check_imei_req(req);
+ rx_check_imei_req(req, true);
break;
default:
LOGP(DMAIN, LOGL_DEBUG, "Unhandled GSUP message type %s\n",
@@ -565,6 +565,12 @@ static int read_cb(struct osmo_gsup_conn *conn, struct msgb *msg)
return 0;
}
+void dgsm_fallback_to_hlr(struct osmo_gsup_req *req) {
+ LOGP(DDGSM, LOGL_DEBUG, "Fall back to HLR from DGSM for [%s]\n",
+ osmo_gsup_message_type_name(req->gsup.message_type));
+ rx_check_imei_req(req, false);
+}
+
static void print_usage(void)
{
printf("Usage: osmo-hlr\n");
diff --git a/src/proxy.c b/src/proxy.c
index e909d5a..7c7f551 100644
--- a/src/proxy.c
+++ b/src/proxy.c
@@ -113,6 +113,19 @@ static bool proxy_deferred_gsup_req_waiting(struct proxy *proxy, const char *ims
return false;
}
+struct osmo_gsup_req *proxy_deferred_gsup_req_get_by_imsi(struct proxy *proxy, const char *imsi)
+{
+ struct proxy_pending_gsup_req *p;
+ OSMO_ASSERT(imsi);
+
+ llist_for_each_entry(p, &proxy->pending_gsup_reqs, entry) {
+ if (strcmp(p->req->gsup.imsi, imsi))
+ continue;
+ return p->req;
+ }
+ return NULL;
+}
+
/* Result of looking for remote HLR. If it failed, pass remote_hlr as NULL. On failure, the remote_hlr may be passed
* NULL. */
static void proxy_deferred_gsup_req_pop(struct proxy *proxy, const char *imsi, struct remote_hlr *remote_hlr)