keith submitted this change.

View Change

Approvals: laforge: Looks good to me, but someone else must approve fixeria: Looks good to me, approved Jenkins Builder: Verified
Add vty `reject-cause` to set the reject cause

Allow to set the LU reject cause independently for both of the
following cases; either when an IMSI is unknown to the HLR or
when the mslookup client does not a receive a timely response
to a GSUP request for the remote home HLR.

Original patchset modified by <keith@rhizomatica.org>

Change-Id: Icea39020c23fbbea9e92847df76af8986fdbf48a
---
M include/osmocom/hlr/hlr.h
M include/osmocom/hlr/hlr_vty.h
M src/hlr.c
M src/hlr_vty.c
M src/lu_fsm.c
M src/proxy.c
M tests/test_nodes.vty
7 files changed, 98 insertions(+), 6 deletions(-)

diff --git a/include/osmocom/hlr/hlr.h b/include/osmocom/hlr/hlr.h
index 3acb3c5..b27fb3d 100644
--- a/include/osmocom/hlr/hlr.h
+++ b/include/osmocom/hlr/hlr.h
@@ -23,6 +23,7 @@
#pragma once

#include <stdbool.h>
+#include <osmocom/gsm/protocol/gsm_04_08_gprs.h>
#include <osmocom/core/linuxlist.h>
#include <osmocom/gsm/ipa.h>
#include <osmocom/core/tdef.h>
@@ -55,6 +56,8 @@

struct llist_head euse_list;
struct hlr_euse *euse_default;
+ enum gsm48_gmm_cause reject_cause;
+ enum gsm48_gmm_cause no_proxy_reject_cause;

/* NCSS (call independent) session guard timeout value */
int ncss_guard_timeout;
diff --git a/include/osmocom/hlr/hlr_vty.h b/include/osmocom/hlr/hlr_vty.h
index 10eddc3..83691b8 100644
--- a/include/osmocom/hlr/hlr_vty.h
+++ b/include/osmocom/hlr/hlr_vty.h
@@ -45,5 +45,5 @@

int hlr_vty_is_config_node(struct vty *vty, int node);
int hlr_vty_go_parent(struct vty *vty);
-void hlr_vty_init(void);
+void hlr_vty_init(void *hlr_ctx);
void dgsm_vty_init(void);
diff --git a/src/hlr.c b/src/hlr.c
index c6ae4fc..8183d9b 100644
--- a/src/hlr.c
+++ b/src/hlr.c
@@ -324,7 +324,7 @@
" Returning slightly inaccurate cause 'IMSI Unknown' via GSUP");
return rc;
case -ENOENT:
- osmo_gsup_req_respond_err(req, GMM_CAUSE_IMSI_UNKNOWN, "IMSI unknown");
+ osmo_gsup_req_respond_err(req, g_hlr->reject_cause, "IMSI unknown");
return rc;
default:
osmo_gsup_req_respond_err(req, GMM_CAUSE_NET_FAIL, "failure to look up IMSI in db");
@@ -759,6 +759,8 @@
g_hlr->db_file_path = talloc_strdup(g_hlr, HLR_DEFAULT_DB_FILE_PATH);
g_hlr->mslookup.server.mdns.domain_suffix = talloc_strdup(g_hlr, OSMO_MDNS_DOMAIN_SUFFIX_DEFAULT);
g_hlr->mslookup.client.mdns.domain_suffix = talloc_strdup(g_hlr, OSMO_MDNS_DOMAIN_SUFFIX_DEFAULT);
+ g_hlr->reject_cause = GMM_CAUSE_IMSI_UNKNOWN;
+ g_hlr->no_proxy_reject_cause = GMM_CAUSE_IMSI_UNKNOWN;

/* Init default (call independent) SS session guard timeout value */
g_hlr->ncss_guard_timeout = NCSS_GUARD_TIMEOUT_DEFAULT;
@@ -775,7 +777,7 @@
osmo_stats_init(hlr_ctx);
vty_init(&vty_info);
ctrl_vty_init(hlr_ctx);
- hlr_vty_init();
+ hlr_vty_init(hlr_ctx);
dgsm_vty_init();
osmo_cpu_sched_vty_init(hlr_ctx);
handle_options(argc, argv);
diff --git a/src/hlr_vty.c b/src/hlr_vty.c
index a440c42..02e0cde 100644
--- a/src/hlr_vty.c
+++ b/src/hlr_vty.c
@@ -25,7 +25,10 @@
*
*/

+#include <errno.h>
+
#include <osmocom/core/talloc.h>
+#include <osmocom/gsm/protocol/gsm_04_08_gprs.h>
#include <osmocom/vty/vty.h>
#include <osmocom/vty/stats.h>
#include <osmocom/vty/command.h>
@@ -40,6 +43,36 @@
#include <osmocom/hlr/hlr_ussd.h>
#include <osmocom/hlr/gsup_server.h>

+static const struct value_string gsm48_gmm_cause_vty_names[] = {
+ { GMM_CAUSE_IMSI_UNKNOWN, "imsi-unknown" },
+ { GMM_CAUSE_ILLEGAL_MS, "illegal-ms" },
+ { GMM_CAUSE_PLMN_NOTALLOWED, "plmn-not-allowed" },
+ { GMM_CAUSE_LA_NOTALLOWED, "la-not-allowed" },
+ { GMM_CAUSE_ROAMING_NOTALLOWED, "roaming-not-allowed" },
+ { GMM_CAUSE_NO_SUIT_CELL_IN_LA, "no-suitable-cell-in-la" },
+ { GMM_CAUSE_NET_FAIL, "net-fail" },
+ { GMM_CAUSE_CONGESTION, "congestion" },
+ { GMM_CAUSE_GSM_AUTH_UNACCEPT, "auth-unacceptable" },
+ { GMM_CAUSE_PROTO_ERR_UNSPEC, "proto-error-unspec" },
+ { 0, NULL },
+};
+
+/* TS 24.008 4.4.4.7 */
+static const struct value_string gsm48_gmm_cause_vty_descs[] = {
+ { GMM_CAUSE_IMSI_UNKNOWN, " #02: (IMSI unknown in HLR)" },
+ { GMM_CAUSE_ILLEGAL_MS, " #03 (Illegal MS)" },
+ { GMM_CAUSE_PLMN_NOTALLOWED, " #11: (PLMN not allowed)" },
+ { GMM_CAUSE_LA_NOTALLOWED, " #12: (Location Area not allowed)" },
+ { GMM_CAUSE_ROAMING_NOTALLOWED, " #13: (Roaming not allowed in this location area)" },
+ { GMM_CAUSE_NO_SUIT_CELL_IN_LA, " #15: (No Suitable Cells In Location Area [continue search in PLMN])." },
+ { GMM_CAUSE_NET_FAIL, " #17: (Network Failure)" },
+ { GMM_CAUSE_CONGESTION, " #22: (Congestion)" },
+ { GMM_CAUSE_GSM_AUTH_UNACCEPT, " #23: (GSM authentication unacceptable [UMTS])" },
+ { GMM_CAUSE_PROTO_ERR_UNSPEC, "#111: (Protocol error, unspecified)" },
+ { 0, NULL },
+};
+
+
struct cmd_node hlr_node = {
HLR_NODE,
"%s(config-hlr)# ",
@@ -73,6 +106,15 @@
static int config_write_hlr(struct vty *vty)
{
vty_out(vty, "hlr%s", VTY_NEWLINE);
+
+ if (g_hlr->reject_cause != GMM_CAUSE_IMSI_UNKNOWN)
+ vty_out(vty, " reject-cause not-found %s%s",
+ get_value_string_or_null(gsm48_gmm_cause_vty_names,
+ (uint32_t) g_hlr->reject_cause), VTY_NEWLINE);
+ if (g_hlr->no_proxy_reject_cause != GMM_CAUSE_IMSI_UNKNOWN)
+ vty_out(vty, " reject-cause no-proxy %s%s",
+ get_value_string_or_null(gsm48_gmm_cause_vty_names,
+ (uint32_t) g_hlr->no_proxy_reject_cause), VTY_NEWLINE);
if (g_hlr->store_imei)
vty_out(vty, " store-imei%s", VTY_NEWLINE);
if (g_hlr->db_file_path && strcmp(g_hlr->db_file_path, HLR_DEFAULT_DB_FILE_PATH))
@@ -358,6 +400,21 @@
return CMD_SUCCESS;
}

+
+DEFUN(cfg_reject_cause, cfg_reject_cause_cmd,
+ "reject-cause TYPE CAUSE", "") /* Dynamically Generated */
+{
+ int cause_code = get_string_value(gsm48_gmm_cause_vty_names, argv[1]);
+ OSMO_ASSERT(cause_code >= 0);
+
+ if (strcmp(argv[0], "not-found") == 0)
+ g_hlr->reject_cause = (enum gsm48_gmm_cause) cause_code;
+ if (strcmp(argv[0], "no-proxy") == 0)
+ g_hlr->no_proxy_reject_cause = (enum gsm48_gmm_cause) cause_code;
+
+ return CMD_SUCCESS;
+}
+
DEFUN(cfg_store_imei, cfg_store_imei_cmd,
"store-imei",
"Save the IMEI in the database when receiving Check IMEI requests. Note that an MSC does not necessarily send"
@@ -450,8 +507,22 @@
}
}

-void hlr_vty_init(void)
+void hlr_vty_init(void *hlr_ctx)
{
+ cfg_reject_cause_cmd.string =
+ vty_cmd_string_from_valstr(hlr_ctx,
+ gsm48_gmm_cause_vty_names,
+ "reject-cause (not-found|no-proxy) (", "|", ")",
+ VTY_DO_LOWER);
+
+ cfg_reject_cause_cmd.doc =
+ vty_cmd_string_from_valstr(hlr_ctx,
+ gsm48_gmm_cause_vty_descs,
+ "GSUP/GMM cause to be sent\n"
+ "in the case the IMSI could not be found in the database\n"
+ "in the case no remote HLR reponded to mslookup GSUP request\n",
+ "\n", "", 0);
+
logging_vty_add_cmds();
osmo_talloc_vty_add_cmds();
osmo_stats_vty_add_cmds();
@@ -478,6 +549,7 @@
install_element(HLR_NODE, &cfg_ussd_defaultroute_cmd);
install_element(HLR_NODE, &cfg_ussd_no_defaultroute_cmd);
install_element(HLR_NODE, &cfg_ncss_guard_timeout_cmd);
+ install_element(HLR_NODE, &cfg_reject_cause_cmd);
install_element(HLR_NODE, &cfg_store_imei_cmd);
install_element(HLR_NODE, &cfg_no_store_imei_cmd);
install_element(HLR_NODE, &cfg_subscr_create_on_demand_cmd);
diff --git a/src/lu_fsm.c b/src/lu_fsm.c
index 8f02f5a..deb180b 100644
--- a/src/lu_fsm.c
+++ b/src/lu_fsm.c
@@ -136,7 +136,7 @@
}

if (db_subscr_get_by_imsi(g_hlr->dbc, update_location_req->gsup.imsi, &lu->subscr) < 0) {
- lu_failure(lu, GMM_CAUSE_IMSI_UNKNOWN, "Subscriber does not exist");
+ lu_failure(lu, g_hlr->reject_cause, "Subscriber does not exist");
return;
}

diff --git a/src/proxy.c b/src/proxy.c
index 152fce8..e909d5a 100644
--- a/src/proxy.c
+++ b/src/proxy.c
@@ -29,6 +29,7 @@
#include <osmocom/gsupclient/gsup_client.h>
#include <osmocom/gsupclient/gsup_req.h>

+#include <osmocom/hlr/hlr.h>
#include <osmocom/hlr/logging.h>
#include <osmocom/hlr/proxy.h>
#include <osmocom/hlr/remote_hlr.h>
@@ -80,7 +81,19 @@
static void proxy_pending_req_remote_hlr_connect_result(struct osmo_gsup_req *req, struct remote_hlr *remote_hlr)
{
if (!remote_hlr || !remote_hlr_is_up(remote_hlr)) {
- osmo_gsup_req_respond_err(req, GMM_CAUSE_IMSI_UNKNOWN, "Proxy: Failed to connect to home HLR");
+ /* Do not respond with an error to a CHECK_IMEI_REQUEST as osmo-msc will send a LU Reject Cause #6
+ * Just respond ACK and deal with the IMSI check that comes next. */
+ if (req->gsup.message_type == OSMO_GSUP_MSGT_CHECK_IMEI_REQUEST) {
+ /* Accept all IMEIs */
+ struct osmo_gsup_message gsup_reply = (struct osmo_gsup_message){
+ .message_type = OSMO_GSUP_MSGT_CHECK_IMEI_RESULT,
+ .imei_result = OSMO_GSUP_IMEI_RESULT_ACK,
+ };
+ osmo_gsup_req_respond(req, &gsup_reply, false, true);
+ return;
+ }
+ osmo_gsup_req_respond_err(req, g_hlr->no_proxy_reject_cause,
+ "Proxy: Failed to connect to home HLR");
return;
}

diff --git a/tests/test_nodes.vty b/tests/test_nodes.vty
index 0f02f22..ac5d88d 100644
--- a/tests/test_nodes.vty
+++ b/tests/test_nodes.vty
@@ -47,6 +47,7 @@
no Negate a command or set its defaults
ussd USSD Configuration
ncss-guard-timeout Set guard timer for NCSS (call independent SS) session activity
+ reject-cause GSUP/GMM cause to be sent
store-imei Save the IMEI in the database when receiving Check IMEI requests. Note that an MSC does not necessarily send Check IMEI requests (for OsmoMSC, you may want to set 'check-imei-rqd 1').
subscriber-create-on-demand Make a new record when a subscriber is first seen.
OsmoHLR(config-hlr)# list
@@ -61,6 +62,7 @@
ussd default-route external EUSE
no ussd default-route
ncss-guard-timeout <0-255>
+ reject-cause (not-found|no-proxy) (imsi-unknown|illegal-ms|plmn-not-allowed|la-not-allowed|roaming-not-allowed|no-suitable-cell-in-la|net-fail|congestion|auth-unacceptable|proto-error-unspec)
store-imei
no store-imei
subscriber-create-on-demand (no-msisdn|<3-15>) (none|cs|ps|cs+ps)

To view, visit change 16808. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Change-Id: Icea39020c23fbbea9e92847df76af8986fdbf48a
Gerrit-Change-Number: 16808
Gerrit-PatchSet: 12
Gerrit-Owner: lynxis lazus <lynxis@fe80.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann@sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de>
Gerrit-Reviewer: keith <keith@rhizomatica.org>
Gerrit-Reviewer: laforge <laforge@osmocom.org>
Gerrit-Reviewer: lynxis lazus <lynxis@fe80.eu>
Gerrit-Reviewer: neels <nhofmeyr@sysmocom.de>
Gerrit-CC: pespin <pespin@sysmocom.de>
Gerrit-MessageType: merged