neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/33130 )
Change subject: cnpool: make NRI mappings VTY configurable
......................................................................
cnpool: make NRI mappings VTY configurable
Implement only the VTY configuration part, applying NRI to select CN
links follows in I66fba27cfbe6e2b27ee3443718846ecfbbd8a974.
Use the osmo_nri_ranges API to manage each cnlink's NRI ranges by VTY
configuration.
Analogous to osmo-bsc
MSC pooling: make NRI mappings VTY configurable
4099f1db504c401e3d7211d9761b034d62d15f7c
I6c251f2744d7be26fc4ad74adefc96a6a3fe08b0
plus
vty: fix doc: default value for 'nri bitlen'
f15d236e3eee8e7cbdc184d401f33b062d1b1aac
I8af840a4589f47eaca6bf10e37e0859f9ae53dfa
Related: SYS#6412
Change-Id: Ifb87e01e5971962e5cfe5e127871af4a67806de1
---
M include/osmocom/hnbgw/hnbgw.h
M src/osmo-hnbgw/hnbgw.c
M src/osmo-hnbgw/hnbgw_cn.c
M src/osmo-hnbgw/hnbgw_vty.c
M tests/Makefile.am
M tests/cnpool.vty
A tests/nri_cfg.vty
7 files changed, 786 insertions(+), 19 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-hnbgw refs/changes/30/33130/1
diff --git a/include/osmocom/hnbgw/hnbgw.h b/include/osmocom/hnbgw/hnbgw.h
index 14552fb..cc32f93 100644
--- a/include/osmocom/hnbgw/hnbgw.h
+++ b/include/osmocom/hnbgw/hnbgw.h
@@ -101,9 +101,8 @@
/* User provided configuration for struct hnbgw_cnpool. */
struct hnbgw_cnpool_cfg {
- /* FUTURE: This will be added here shortly:
- * - global NRI config: bitlen and NULL-NRI.
- */
+ uint8_t nri_bitlen;
+ struct osmo_nri_ranges *null_nri_ranges;
};
/* User provided configuration for struct hnbgw_cnlink. */
@@ -112,9 +111,7 @@
* use. */
char *remote_addr_name;
- /* FUTURE: This will be added here shortly:
- * - per peer NRI config: NRI ranges assigned to this peer.
- */
+ struct osmo_nri_ranges *nri_ranges;
};
/* Collection of CN peers to distribute UE connections across. MSCs for DOMAIN_CS, SGSNs for DOMAIN_PS. */
@@ -134,9 +131,10 @@
/* List of struct hnbgw_cnlink */
struct llist_head cnlinks;
- /* FUTURE: This will be added here shortly:
- * - round robin state for new conns
- */
+ unsigned int round_robin_next_nr;
+ /* Emergency calls potentially select a different set of MSCs, so to not mess up the normal round-robin
+ * behavior, emergency calls need a separate round-robin counter. */
+ unsigned int round_robin_next_emerg_nr;
};
/* A CN peer, like 'msc 0' or 'sgsn 23' */
@@ -163,6 +161,9 @@
/* linked list of hnbgw_context_map */
struct llist_head map_list;
+
+ bool allow_attach;
+ bool allow_emerg;
};
#define LOG_CNLINK(CNLINK, SUBSYS, LEVEL, FMT, ARGS...) \
diff --git a/src/osmo-hnbgw/hnbgw.c b/src/osmo-hnbgw/hnbgw.c
index 205c683..0d64adf 100644
--- a/src/osmo-hnbgw/hnbgw.c
+++ b/src/osmo-hnbgw/hnbgw.c
@@ -24,6 +24,8 @@
#include <osmocom/vty/vty.h>
+#include <osmocom/gsm/gsm23236.h>
+
#include <osmocom/netif/stream.h>
#include "config.h"
@@ -67,9 +69,8 @@
.peer_name = "msc",
.default_remote_pc = DEFAULT_PC_MSC,
.vty = {
- /* FUTURE: This will be added here shortly:
- * - defaults for global NRI config: bitlen and NULL-NRI.
- */
+ .nri_bitlen = OSMO_NRI_BITLEN_DEFAULT,
+ .null_nri_ranges = osmo_nri_ranges_alloc(g_hnbgw),
},
};
INIT_LLIST_HEAD(&g_hnbgw->sccp.cnpool_iucs.cnlinks);
@@ -80,9 +81,8 @@
.peer_name = "sgsn",
.default_remote_pc = DEFAULT_PC_SGSN,
.vty = {
- /* FUTURE: This will be added here shortly:
- * - defaults for global NRI config: bitlen and NULL-NRI.
- */
+ .nri_bitlen = OSMO_NRI_BITLEN_DEFAULT,
+ .null_nri_ranges = osmo_nri_ranges_alloc(g_hnbgw),
},
};
INIT_LLIST_HEAD(&g_hnbgw->sccp.cnpool_iups.cnlinks);
diff --git a/src/osmo-hnbgw/hnbgw_cn.c b/src/osmo-hnbgw/hnbgw_cn.c
index d829718..9dc2016 100644
--- a/src/osmo-hnbgw/hnbgw_cn.c
+++ b/src/osmo-hnbgw/hnbgw_cn.c
@@ -27,6 +27,8 @@
#include <osmocom/core/utils.h>
#include <osmocom/core/timer.h>
+#include <osmocom/gsm/gsm23236.h>
+
#include <osmocom/sigtran/protocol/m3ua.h>
#include <osmocom/sigtran/sccp_sap.h>
#include <osmocom/sigtran/sccp_helpers.h>
@@ -453,12 +455,26 @@
void hnbgw_cnpool_apply_cfg(struct hnbgw_cnpool *cnpool)
{
- cnpool->use = cnpool->vty;
+ struct osmo_nri_range *r;
+
+ cnpool->use.nri_bitlen = cnpool->vty.nri_bitlen;
+
+ osmo_nri_ranges_free(cnpool->use.null_nri_ranges);
+ cnpool->use.null_nri_ranges = osmo_nri_ranges_alloc(g_hnbgw);
+ llist_for_each_entry(r, &cnpool->vty.null_nri_ranges->entries, entry)
+ osmo_nri_ranges_add(cnpool->use.null_nri_ranges, r);
}
static void hnbgw_cnlink_cfg_copy(struct hnbgw_cnlink *cnlink)
{
+ struct osmo_nri_range *r;
+
osmo_talloc_replace_string(cnlink, &cnlink->use.remote_addr_name, cnlink->vty.remote_addr_name);
+
+ osmo_nri_ranges_free(cnlink->use.nri_ranges);
+ cnlink->use.nri_ranges = osmo_nri_ranges_alloc(cnlink);
+ llist_for_each_entry(r, &cnlink->vty.nri_ranges->entries, entry)
+ osmo_nri_ranges_add(cnlink->use.nri_ranges, r);
}
static bool hnbgw_cnlink_sccp_cfg_changed(struct hnbgw_cnlink *cnlink)
@@ -636,7 +652,9 @@
.nr = nr,
.vty = {
/* VTY config defaults for the new cnlink */
+ .nri_ranges = osmo_nri_ranges_alloc(cnlink),
},
+ .allow_attach = true,
};
INIT_LLIST_HEAD(&cnlink->map_list);
diff --git a/src/osmo-hnbgw/hnbgw_vty.c b/src/osmo-hnbgw/hnbgw_vty.c
index 206db4f..3404a3f 100644
--- a/src/osmo-hnbgw/hnbgw_vty.c
+++ b/src/osmo-hnbgw/hnbgw_vty.c
@@ -26,6 +26,8 @@
#include <osmocom/vty/command.h>
#include <osmocom/vty/tdef_vty.h>
+#include <osmocom/gsm/gsm23236.h>
+
#include <osmocom/hnbgw/vty.h>
#include <osmocom/hnbgw/hnbgw.h>
@@ -346,6 +348,69 @@
return CMD_WARNING;
}
+#define NRI_STR "Mapping of Network Resource Indicators to this CN peer, for CN pooling\n"
+#define NULL_NRI_STR "Define NULL-NRI values that cause re-assignment of an MS to a different CN peer, for CN pooling.\n"
+#define NRI_FIRST_LAST_STR "First value of the NRI value range, should not surpass the configured 'nri bitlen'.\n" \
+ "Last value of the NRI value range, should not surpass the configured 'nri bitlen' and be larger than the" \
+ " first value; if omitted, apply only the first value.\n"
+#define NRI_ARGS_TO_STR_FMT "%s%s%s"
+#define NRI_ARGS_TO_STR_ARGS(ARGC, ARGV) ARGV[0], (ARGC>1)? ".." : "", (ARGC>1)? ARGV[1] : ""
+
+#define NRI_WARN(CNLINK, FORMAT, args...) do { \
+ vty_out(vty, "%% Warning: %s %d: " FORMAT "%s", CNLINK->pool->peer_name, CNLINK->nr, ##args, \
+ VTY_NEWLINE); \
+ LOGP(DCN, LOGL_ERROR, "%s %d: " FORMAT "\n", CNLINK->pool->peer_name, CNLINK->nr, ##args); \
+ } while (0)
+
+
+/* hnbgw/iucs/nri ... AND hnbgw/iups/nri ... */
+DEFUN(cfg_hnbgw_cnpool_nri_bitlen,
+ cfg_hnbgw_cnpool_nri_bitlen_cmd,
+ "nri bitlen <1-15>",
+ NRI_STR
+ "Set number of bits that an NRI has, to extract from TMSI identities (always starting just after the TMSI's most significant octet).\n"
+ "bit count (default: " OSMO_STRINGIFY_VAL(OSMO_NRI_BITLEN_DEFAULT) ")\n")
+{
+ struct hnbgw_cnpool *cnpool = vty->index;
+ cnpool->vty.nri_bitlen = atoi(argv[0]);
+ return CMD_SUCCESS;
+}
+
+/* hnbgw/iucs/nri ... AND hnbgw/iups/nri ... */
+DEFUN(cfg_hnbgw_cnpool_nri_null_add, cfg_hnbgw_cnpool_nri_null_add_cmd,
+ "nri null add <0-32767> [<0-32767>]",
+ NRI_STR NULL_NRI_STR "Add NULL-NRI value (or range)\n"
+ NRI_FIRST_LAST_STR)
+{
+ int rc;
+ const char *message;
+ struct hnbgw_cnpool *cnpool = vty->index;
+ rc = osmo_nri_ranges_vty_add(&message, NULL, cnpool->vty.null_nri_ranges, argc, argv, cnpool->vty.nri_bitlen);
+ if (message)
+ vty_out(vty, "%% %s: " NRI_ARGS_TO_STR_FMT, message, NRI_ARGS_TO_STR_ARGS(argc, argv));
+ if (rc < 0)
+ return CMD_WARNING;
+ return CMD_SUCCESS;
+}
+
+/* hnbgw/iucs/nri ... AND hnbgw/iups/nri ... */
+DEFUN(cfg_hnbgw_cnpool_nri_null_del, cfg_hnbgw_cnpool_nri_null_del_cmd,
+ "nri null del <0-32767> [<0-32767>]",
+ NRI_STR NULL_NRI_STR "Remove NRI value or range from the NRI mapping for this CN link\n"
+ NRI_FIRST_LAST_STR)
+{
+ int rc;
+ const char *message;
+ struct hnbgw_cnpool *cnpool = vty->index;
+ rc = osmo_nri_ranges_vty_del(&message, NULL, cnpool->vty.null_nri_ranges, argc, argv);
+ if (message)
+ vty_out(vty, "%% %s: " NRI_ARGS_TO_STR_FMT "%s", message, NRI_ARGS_TO_STR_ARGS(argc, argv),
+ VTY_NEWLINE);
+ if (rc < 0)
+ return CMD_WARNING;
+ return CMD_SUCCESS;
+}
+
/* Legacy from when there was only one IuCS and one IuPS peer. Instead, there are now 'msc 123' / 'sgsn 123' sub nodes.
* To yield legacy behavior, set the first cnlink config in this pool ('msc 0' / 'sgsn 0'). */
DEFUN_DEPRECATED(cfg_hnbgw_cnpool_remote_addr,
@@ -436,6 +501,217 @@
return CMD_SUCCESS;
}
+DEFUN_ATTR(cfg_cnlink_nri_add, cfg_cnlink_nri_add_cmd,
+ "nri add <0-32767> [<0-32767>]",
+ NRI_STR "Add NRI value or range to the NRI mapping for this CN link\n"
+ NRI_FIRST_LAST_STR,
+ CMD_ATTR_IMMEDIATE)
+{
+ struct hnbgw_cnlink *cnlink = vty->index;
+ struct hnbgw_cnlink *other_cnlink;
+ bool before;
+ int rc;
+ const char *message;
+ struct osmo_nri_range added_range;
+
+ rc = osmo_nri_ranges_vty_add(&message, &added_range, cnlink->vty.nri_ranges, argc, argv, cnlink->pool->vty.nri_bitlen);
+ if (message) {
+ NRI_WARN(cnlink, "%s: " NRI_ARGS_TO_STR_FMT, message, NRI_ARGS_TO_STR_ARGS(argc, argv));
+ }
+ if (rc < 0)
+ return CMD_WARNING;
+
+ /* Issue a warning about NRI range overlaps (but still allow them).
+ * Overlapping ranges will map to whichever CN link comes fist in the llist,
+ * which is not necessarily in the order of increasing cnlink->nr. */
+ before = true;
+ llist_for_each_entry(other_cnlink, &cnlink->pool->cnlinks, entry) {
+ if (other_cnlink == cnlink) {
+ before = false;
+ continue;
+ }
+ if (osmo_nri_range_overlaps_ranges(&added_range, other_cnlink->vty.nri_ranges)) {
+ NRI_WARN(cnlink, "NRI range [%d..%d] overlaps between %s %d and %s %d."
+ " For overlaps, %s %d has higher priority than %s %d",
+ added_range.first, added_range.last, cnlink->pool->peer_name, cnlink->nr,
+ other_cnlink->pool->peer_name, other_cnlink->nr,
+ (before ? other_cnlink : cnlink)->pool->peer_name,
+ (before ? other_cnlink : cnlink)->nr,
+ (before ? cnlink : other_cnlink)->pool->peer_name,
+ (before ? cnlink : other_cnlink)->nr);
+ }
+ }
+ return CMD_SUCCESS;
+}
+
+DEFUN_ATTR(cfg_cnlink_nri_del, cfg_cnlink_nri_del_cmd,
+ "nri del <0-32767> [<0-32767>]",
+ NRI_STR "Remove NRI value or range from the NRI mapping for this CN link\n"
+ NRI_FIRST_LAST_STR,
+ CMD_ATTR_IMMEDIATE)
+{
+ struct hnbgw_cnlink *cnlink = vty->index;
+ int rc;
+ const char *message;
+
+ rc = osmo_nri_ranges_vty_del(&message, NULL, cnlink->vty.nri_ranges, argc, argv);
+ if (message) {
+ NRI_WARN(cnlink, "%s: " NRI_ARGS_TO_STR_FMT, message, NRI_ARGS_TO_STR_ARGS(argc, argv));
+ }
+ if (rc < 0)
+ return CMD_WARNING;
+ return CMD_SUCCESS;
+}
+
+DEFUN_ATTR(cfg_cnlink_allow_attach, cfg_cnlink_allow_attach_cmd,
+ "allow-attach",
+ "Allow this CN link to attach new subscribers (default).\n",
+ CMD_ATTR_IMMEDIATE)
+{
+ struct hnbgw_cnlink *cnlink = vty->index;
+ cnlink->allow_attach = true;
+ return CMD_SUCCESS;
+}
+
+DEFUN_ATTR(cfg_cnlink_no_allow_attach, cfg_cnlink_no_allow_attach_cmd,
+ "no allow-attach",
+ NO_STR
+ "Do not assign new subscribers to this CN link."
+ " Useful if an CN link in an CN link pool is configured to off-load subscribers."
+ " The CN link will still be operational for already IMSI-Attached subscribers,"
+ " but the NAS node selection function will skip this CN link for new subscribers\n",
+ CMD_ATTR_IMMEDIATE)
+{
+ struct hnbgw_cnlink *cnlink = vty->index;
+ cnlink->allow_attach = false;
+ return CMD_SUCCESS;
+}
+
+DEFUN_ATTR(cfg_cnlink_allow_emerg,
+ cfg_cnlink_allow_emerg_cmd,
+ "allow-emergency",
+ "Allow CM ServiceRequests with type emergency on this CN link\n",
+ CMD_ATTR_IMMEDIATE)
+{
+ struct hnbgw_cnlink *cnlink = vty->index;
+ cnlink->allow_emerg = true;
+ return CMD_SUCCESS;
+}
+
+DEFUN_ATTR(cfg_cnlink_no_allow_emerg,
+ cfg_cnlink_no_allow_emerg_cmd,
+ "no allow-emergency",
+ NO_STR
+ "Do not serve CM ServiceRequests with type emergency on this CN link\n",
+ CMD_ATTR_IMMEDIATE)
+{
+ struct hnbgw_cnlink *cnlink = vty->index;
+ cnlink->allow_emerg = false;
+ return CMD_SUCCESS;
+}
+
+static void cnlink_write_nri(struct vty *vty, struct hnbgw_cnlink *cnlink, bool verbose)
+{
+ struct osmo_nri_range *r;
+
+ if (verbose) {
+ vty_out(vty, "%s %d%s", cnlink->pool->peer_name, cnlink->nr, VTY_NEWLINE);
+ if (llist_empty(&cnlink->vty.nri_ranges->entries)) {
+ vty_out(vty, " %% no NRI mappings%s", VTY_NEWLINE);
+ return;
+ }
+ }
+
+ llist_for_each_entry(r, &cnlink->vty.nri_ranges->entries, entry) {
+ if (osmo_nri_range_validate(r, 255))
+ vty_out(vty, " %% INVALID RANGE:");
+ vty_out(vty, " nri add %d", r->first);
+ if (r->first != r->last)
+ vty_out(vty, " %d", r->last);
+ vty_out(vty, "%s", VTY_NEWLINE);
+ }
+
+ if (!cnlink->allow_attach)
+ vty_out(vty, " no allow-attach%s", VTY_NEWLINE);
+ if (cnlink->allow_emerg)
+ vty_out(vty, " allow-emergency%s", VTY_NEWLINE);
+}
+
+DEFUN(cfg_cnlink_show_nri, cfg_cnlink_show_nri_cmd,
+ "show nri",
+ SHOW_STR NRI_STR)
+{
+ struct hnbgw_cnlink *cnlink = vty->index;
+ cnlink_write_nri(vty, cnlink, true);
+ return CMD_SUCCESS;
+}
+
+void cnlinks_write_nri(struct vty *vty, struct hnbgw_cnpool *cnpool, bool verbose)
+{
+ struct hnbgw_cnlink *cnlink;
+ llist_for_each_entry(cnlink, &cnpool->cnlinks, entry)
+ cnlink_write_nri(vty, cnlink, verbose);
+}
+
+void cnpool_write_nri(struct vty *vty, struct hnbgw_cnpool *cnpool, bool verbose)
+{
+ struct osmo_nri_range *r;
+
+ if (verbose)
+ vty_out(vty, " %s%s", cnpool->pool_name, VTY_NEWLINE);
+
+ if (verbose || cnpool->vty.nri_bitlen != OSMO_NRI_BITLEN_DEFAULT)
+ vty_out(vty, " nri bitlen %u%s", cnpool->vty.nri_bitlen, VTY_NEWLINE);
+
+ llist_for_each_entry(r, &cnpool->vty.null_nri_ranges->entries, entry) {
+ vty_out(vty, " nri null add %d", r->first);
+ if (r->first != r->last)
+ vty_out(vty, " %d", r->last);
+ vty_out(vty, "%s", VTY_NEWLINE);
+ }
+ if (verbose && llist_empty(&cnpool->vty.null_nri_ranges->entries))
+ vty_out(vty, " %% No NULL-NRI entries%s", VTY_NEWLINE);
+}
+
+DEFUN(show_nri, show_nri_cmd,
+ "show nri",
+ SHOW_STR NRI_STR)
+{
+ /* hnbgw
+ * iucs
+ * nri null add ...
+ */
+ vty_out(vty, "hnbgw%s", VTY_NEWLINE);
+ cnpool_write_nri(vty, &g_hnbgw->sccp.cnpool_iucs, true);
+ cnpool_write_nri(vty, &g_hnbgw->sccp.cnpool_iups, true);
+
+ /* msc 0
+ * nri add ...
+ */
+ cnlinks_write_nri(vty, &g_hnbgw->sccp.cnpool_iucs, true);
+ cnlinks_write_nri(vty, &g_hnbgw->sccp.cnpool_iups, true);
+ return CMD_SUCCESS;
+}
+
+/* Hidden since it exists only for use by ttcn3 tests */
+DEFUN_HIDDEN(cnpool_roundrobin_next, cnpool_roundrobin_next_cmd,
+ "cnpool roundrobin next (msc|sgsn) " CNLINK_NR_RANGE,
+ "CN pooling: load balancing across multiple CN links.\n"
+ "Adjust current state of the CN link round-robin algorithm (for testing).\n"
+ "Set the CN link nr to direct the next new subscriber to (for testing).\n"
+ "Set next MSC or next SGSN number\n"
+ "CN link number, as in the config file; if the number does not exist,"
+ " the round-robin continues to the next valid number.\n")
+{
+ struct hnbgw_cnpool *cnpool;
+ if (!strcmp("msc", argv[0]))
+ cnpool = &g_hnbgw->sccp.cnpool_iucs;
+ else
+ cnpool = &g_hnbgw->sccp.cnpool_iups;
+ cnpool->round_robin_next_nr = atoi(argv[1]);
+ return CMD_SUCCESS;
+}
+
#define APPLY_STR "Immediately use configuration modified via telnet VTY, and restart components as needed.\n"
#define SCCP_RESTART_STR \
" If 'remote-addr' changed, related SCCP links will be restarted, possibly dropping active UE contexts."
@@ -518,6 +794,21 @@
#endif /* ENABLE_PFCP */
+/* hnbgw
+ * iucs } this part
+ * foo }
+ */
+static void _config_write_cnpool(struct vty *vty, struct hnbgw_cnpool *cnpool)
+{
+ if (cnpool->vty.nri_bitlen == OSMO_NRI_BITLEN_DEFAULT
+ && llist_empty(&cnpool->vty.null_nri_ranges->entries))
+ return;
+
+ vty_out(vty, " %s%s", cnpool->pool_name, VTY_NEWLINE);
+
+ cnpool_write_nri(vty, cnpool, false);
+}
+
static int config_write_hnbgw(struct vty *vty)
{
vty_out(vty, "hnbgw%s", VTY_NEWLINE);
@@ -528,6 +819,9 @@
VTY_NEWLINE);
osmo_tdef_vty_groups_write(vty, " ");
+ _config_write_cnpool(vty, &g_hnbgw->sccp.cnpool_iucs);
+ _config_write_cnpool(vty, &g_hnbgw->sccp.cnpool_iups);
+
return CMD_SUCCESS;
}
@@ -565,7 +859,7 @@
vty_out(vty, "%s %d%s", cnpool->peer_name, cnlink->nr, VTY_NEWLINE);
if (cnlink->vty.remote_addr_name)
vty_out(vty, " remote-addr %s%s", cnlink->vty.remote_addr_name, VTY_NEWLINE);
- /* FUTURE: NRI config */
+ cnlink_write_nri(vty, cnlink, false);
}
}
@@ -597,7 +891,14 @@
static void install_cnlink_elements(int node)
{
install_element(node, &cfg_cnlink_remote_addr_cmd);
+ install_element(node, &cfg_cnlink_nri_add_cmd);
+ install_element(node, &cfg_cnlink_nri_del_cmd);
+ install_element(node, &cfg_cnlink_show_nri_cmd);
install_element(node, &cfg_cnlink_apply_sccp_cmd);
+ install_element(node, &cfg_cnlink_allow_attach_cmd);
+ install_element(node, &cfg_cnlink_no_allow_attach_cmd);
+ install_element(node, &cfg_cnlink_allow_emerg_cmd);
+ install_element(node, &cfg_cnlink_no_allow_emerg_cmd);
}
void hnbgw_vty_init(void)
@@ -618,9 +919,15 @@
install_element(HNBGW_NODE, &cfg_hnbgw_iucs_cmd);
install_node(&iucs_node, NULL);
+ install_element(IUCS_NODE, &cfg_hnbgw_cnpool_nri_bitlen_cmd);
+ install_element(IUCS_NODE, &cfg_hnbgw_cnpool_nri_null_add_cmd);
+ install_element(IUCS_NODE, &cfg_hnbgw_cnpool_nri_null_del_cmd);
install_element(HNBGW_NODE, &cfg_hnbgw_iups_cmd);
install_node(&iups_node, NULL);
+ install_element(IUPS_NODE, &cfg_hnbgw_cnpool_nri_bitlen_cmd);
+ install_element(IUPS_NODE, &cfg_hnbgw_cnpool_nri_null_add_cmd);
+ install_element(IUPS_NODE, &cfg_hnbgw_cnpool_nri_null_del_cmd);
/* deprecated: 'remote-addr' outside of 'msc 123' redirects to 'msc 0' / same for 'sgsn' */
install_element(IUCS_NODE, &cfg_hnbgw_cnpool_remote_addr_cmd);
@@ -647,6 +954,8 @@
install_element(PFCP_NODE, &cfg_pfcp_remote_addr_cmd);
#endif
+ osmo_tdef_vty_groups_init(HNBGW_NODE, hnbgw_tdef_group);
+
install_element(CONFIG_NODE, &cfg_msc_nr_cmd);
install_node(&msc_node, config_write_msc);
install_cnlink_elements(MSC_NODE);
@@ -658,5 +967,6 @@
/* global 'apply sccp' command. There are two more on MSC_NODE and SGSN_NODE from install_cnlink_elements(). */
install_element(CONFIG_NODE, &cfg_config_apply_sccp_cmd);
- osmo_tdef_vty_groups_init(HNBGW_NODE, hnbgw_tdef_group);
+ install_element_ve(&show_nri_cmd);
+ install_element(ENABLE_NODE, &cnpool_roundrobin_next_cmd);
}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 62fb6c6..f34d9a0 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -25,7 +25,7 @@
$(srcdir)/package.m4 \
$(TESTSUITE) \
osmo-hnbgw-vty-test.cfg \
- osmo-hnbgw.vty \
+ $(srcdir)/*.vty \
$(srcdir)/config/*.cfg \
$(srcdir)/config/*.vty \
$(srcdir)/config/run_tests.sh \
diff --git a/tests/cnpool.vty b/tests/cnpool.vty
index 6b57122..9745306 100644
--- a/tests/cnpool.vty
+++ b/tests/cnpool.vty
@@ -2,6 +2,17 @@
OsmoHNBGW# configure terminal
OsmoHNBGW(config)# ### cnpool doc strings
+OsmoHNBGW(config)# list
+...
+ apply sccp
+...
+
+OsmoHNBGW(config)# apply?
+ apply Immediately use configuration modified via telnet VTY, and restart components as needed.
+
+OsmoHNBGW(config)# apply ?
+ sccp For telnet VTY: apply all SCCP and NRI config changes made to any CN pools and CN links in the running osmo-hnbgw process. If 'remote-addr' changed, related SCCP links will be restarted, possibly dropping active UE contexts. This is run implicitly on program startup, only useful to apply changes made later via telnet VTY.
+
OsmoHNBGW(config)# hnbgw
OsmoHNBGW(config-hnbgw)# list
...
@@ -13,6 +24,79 @@
OsmoHNBGW(config-hnbgw)# iups?
iups Configure IuPS options
+OsmoHNBGW(config-hnbgw)# iucs
+
+OsmoHNBGW(config-hnbgw-iucs)# list
+...
+ nri bitlen <1-15>
+ nri null add <0-32767> [<0-32767>]
+ nri null del <0-32767> [<0-32767>]
+...
+
+OsmoHNBGW(config-hnbgw-iucs)# nri?
+ nri Mapping of Network Resource Indicators to this CN peer, for CN pooling
+
+OsmoHNBGW(config-hnbgw-iucs)# nri ?
+ bitlen Set number of bits that an NRI has, to extract from TMSI identities (always starting just after the TMSI's most significant octet).
+ null Define NULL-NRI values that cause re-assignment of an MS to a different CN peer, for CN pooling.
+
+OsmoHNBGW(config-hnbgw-iucs)# nri bitlen ?
+ <1-15> bit count (default: 10)
+
+OsmoHNBGW(config-hnbgw-iucs)# nri null ?
+ add Add NULL-NRI value (or range)
+ del Remove NRI value or range from the NRI mapping for this CN link
+
+OsmoHNBGW(config-hnbgw-iucs)# nri null add ?
+ <0-32767> First value of the NRI value range, should not surpass the configured 'nri bitlen'.
+
+OsmoHNBGW(config-hnbgw-iucs)# nri null add 0 ?
+ [<0-32767>] Last value of the NRI value range, should not surpass the configured 'nri bitlen' and be larger than the first value; if omitted, apply only the first value.
+
+OsmoHNBGW(config-hnbgw-iucs)# nri null del ?
+ <0-32767> First value of the NRI value range, should not surpass the configured 'nri bitlen'.
+
+OsmoHNBGW(config-hnbgw-iucs)# nri null del 0 ?
+ [<0-32767>] Last value of the NRI value range, should not surpass the configured 'nri bitlen' and be larger than the first value; if omitted, apply only the first value.
+
+OsmoHNBGW(config-hnbgw-iucs)# exit
+
+OsmoHNBGW(config-hnbgw)# iups
+
+OsmoHNBGW(config-hnbgw-iups)# list
+...
+ nri bitlen <1-15>
+ nri null add <0-32767> [<0-32767>]
+ nri null del <0-32767> [<0-32767>]
+...
+
+OsmoHNBGW(config-hnbgw-iups)# nri?
+ nri Mapping of Network Resource Indicators to this CN peer, for CN pooling
+
+OsmoHNBGW(config-hnbgw-iups)# nri ?
+ bitlen Set number of bits that an NRI has, to extract from TMSI identities (always starting just after the TMSI's most significant octet).
+ null Define NULL-NRI values that cause re-assignment of an MS to a different CN peer, for CN pooling.
+
+OsmoHNBGW(config-hnbgw-iups)# nri bitlen ?
+ <1-15> bit count (default: 10)
+
+OsmoHNBGW(config-hnbgw-iups)# nri null ?
+ add Add NULL-NRI value (or range)
+ del Remove NRI value or range from the NRI mapping for this CN link
+
+OsmoHNBGW(config-hnbgw-iups)# nri null add ?
+ <0-32767> First value of the NRI value range, should not surpass the configured 'nri bitlen'.
+
+OsmoHNBGW(config-hnbgw-iups)# nri null add 0 ?
+ [<0-32767>] Last value of the NRI value range, should not surpass the configured 'nri bitlen' and be larger than the first value; if omitted, apply only the first value.
+
+OsmoHNBGW(config-hnbgw-iups)# nri null del ?
+ <0-32767> First value of the NRI value range, should not surpass the configured 'nri bitlen'.
+
+OsmoHNBGW(config-hnbgw-iups)# nri null del 0 ?
+ [<0-32767>] Last value of the NRI value range, should not surpass the configured 'nri bitlen' and be larger than the first value; if omitted, apply only the first value.
+
+OsmoHNBGW(config-hnbgw-iups)# exit
OsmoHNBGW(config-hnbgw)# exit
OsmoHNBGW(config)# msc?
@@ -37,7 +121,14 @@
OsmoHNBGW(config-msc)# list
...
remote-addr NAME
+ nri add <0-32767> [<0-32767>]
+ nri del <0-32767> [<0-32767>]
+ show nri
apply sccp
+ allow-attach
+ no allow-attach
+ allow-emergency
+ no allow-emergency
...
OsmoHNBGW(config-msc)# remote-addr?
@@ -45,11 +136,25 @@
OsmoHNBGW(config-msc)# remote-addr ?
NAME SCCP address book entry name (see 'cs7 instance' / 'sccp-address')
+OsmoHNBGW(config-msc)# show nri?
+ nri Mapping of Network Resource Indicators to this CN peer, for CN pooling
+
OsmoHNBGW(config-msc)# apply?
apply Immediately use configuration modified via telnet VTY, and restart components as needed.
+
OsmoHNBGW(config-msc)# apply ?
sccp For telnet VTY: apply SCCP and NRI config changes made to this CN link in the running osmo-hnbgw process. If 'remote-addr' changed, related SCCP links will be restarted, possibly dropping active UE contexts. This is run implicitly on program startup, only useful to apply changes made later via telnet VTY.
+OsmoHNBGW(config-msc)# allow-attach?
+ allow-attach Allow this CN link to attach new subscribers (default).
+
+OsmoHNBGW(config-msc)# allow-emergency?
+ allow-emergency Allow CM ServiceRequests with type emergency on this CN link
+
+OsmoHNBGW(config-msc)# no ?
+ allow-attach Do not assign new subscribers to this CN link. Useful if an CN link in an CN link pool is configured to off-load subscribers. The CN link will still be operational for already IMSI-Attached subscribers, but the NAS node selection function will skip this CN link for new subscribers
+ allow-emergency Do not serve CM ServiceRequests with type emergency on this CN link
+
OsmoHNBGW(config-msc)# exit
OsmoHNBGW(config)# sgsn 1
@@ -57,7 +162,14 @@
OsmoHNBGW(config-sgsn)# list
...
remote-addr NAME
+ nri add <0-32767> [<0-32767>]
+ nri del <0-32767> [<0-32767>]
+ show nri
apply sccp
+ allow-attach
+ no allow-attach
+ allow-emergency
+ no allow-emergency
...
OsmoHNBGW(config-sgsn)# remote-addr?
@@ -65,11 +177,25 @@
OsmoHNBGW(config-sgsn)# remote-addr ?
NAME SCCP address book entry name (see 'cs7 instance' / 'sccp-address')
+OsmoHNBGW(config-sgsn)# show nri?
+ nri Mapping of Network Resource Indicators to this CN peer, for CN pooling
+
OsmoHNBGW(config-sgsn)# apply?
apply Immediately use configuration modified via telnet VTY, and restart components as needed.
+
OsmoHNBGW(config-sgsn)# apply ?
sccp For telnet VTY: apply SCCP and NRI config changes made to this CN link in the running osmo-hnbgw process. If 'remote-addr' changed, related SCCP links will be restarted, possibly dropping active UE contexts. This is run implicitly on program startup, only useful to apply changes made later via telnet VTY.
+OsmoHNBGW(config-sgsn)# allow-attach?
+ allow-attach Allow this CN link to attach new subscribers (default).
+
+OsmoHNBGW(config-sgsn)# allow-emergency?
+ allow-emergency Allow CM ServiceRequests with type emergency on this CN link
+
+OsmoHNBGW(config-sgsn)# no ?
+ allow-attach Do not assign new subscribers to this CN link. Useful if an CN link in an CN link pool is configured to off-load subscribers. The CN link will still be operational for already IMSI-Attached subscribers, but the NAS node selection function will skip this CN link for new subscribers
+ allow-emergency Do not serve CM ServiceRequests with type emergency on this CN link
+
OsmoHNBGW(config-sgsn)# exit
OsmoHNBGW(config)# ### Just by entering the nodes above, 'msc 1' and 'sgsn 1' now exist
@@ -85,10 +211,12 @@
OsmoHNBGW(config)# msc 2
OsmoHNBGW(config-msc)# remote-addr addr-msc2
+OsmoHNBGW(config-msc)# no allow-attach
OsmoHNBGW(config-msc)# exit
OsmoHNBGW(config)# msc 3
OsmoHNBGW(config-msc)# remote-addr addr-msc3
+OsmoHNBGW(config-msc)# allow-emergency
OsmoHNBGW(config-msc)# exit
OsmoHNBGW(config)# sgsn 2
@@ -105,8 +233,10 @@
msc 1
msc 2
remote-addr addr-msc2
+ no allow-attach
msc 3
remote-addr addr-msc3
+ allow-emergency
sgsn 0
sgsn 1
sgsn 2
@@ -116,8 +246,12 @@
...
OsmoHNBGW(config)# ### Re-entering existing nodes works (does not create new ones)
+OsmoHNBGW(config)# msc 2
+OsmoHNBGW(config-msc)# allow-attach
+OsmoHNBGW(config-msc)# exit
OsmoHNBGW(config)# msc 3
OsmoHNBGW(config-msc)# remote-addr addr-msc4
+OsmoHNBGW(config-msc)# no allow-emergency
OsmoHNBGW(config-msc)# exit
OsmoHNBGW(config)# sgsn 2
OsmoHNBGW(config-sgsn)# remote-addr addr-sgsn4
diff --git a/tests/nri_cfg.vty b/tests/nri_cfg.vty
new file mode 100644
index 0000000..e8a820b
--- /dev/null
+++ b/tests/nri_cfg.vty
@@ -0,0 +1,279 @@
+OsmoHNBGW> show nri
+hnbgw
+ iucs
+ nri bitlen 10
+ % No NULL-NRI entries
+ iups
+ nri bitlen 10
+ % No NULL-NRI entries
+msc 0
+ % no NRI mappings
+sgsn 0
+ % no NRI mappings
+
+OsmoHNBGW> enable
+OsmoHNBGW# configure terminal
+
+OsmoHNBGW(config)# msc 0
+
+OsmoHNBGW(config-msc)# list
+...
+ nri add <0-32767> [<0-32767>]
+ nri del <0-32767> [<0-32767>]
+ show nri
+...
+OsmoHNBGW(config-msc)# nri ?
+ add Add NRI value or range to the NRI mapping for this CN link
+ del Remove NRI value or range from the NRI mapping for this CN link
+OsmoHNBGW(config-msc)# nri add ?
+ <0-32767> First value of the NRI value range, should not surpass the configured 'nri bitlen'.
+OsmoHNBGW(config-msc)# nri add 23 ?
+ [<0-32767>] Last value of the NRI value range, should not surpass the configured 'nri bitlen' and be larger than the first value; if omitted, apply only the first value.
+
+OsmoHNBGW(config-msc)# nri add 23
+OsmoHNBGW(config-msc)# nri add 256 511
+OsmoHNBGW(config-msc)# nri add 100 200
+OsmoHNBGW(config-msc)# nri add 1024 1024
+% Warning: msc 0: Warning: NRI range surpasses current NRI bitlen: 1024..1024
+OsmoHNBGW(config-msc)# show nri
+msc 0
+ nri add 23
+ nri add 100 200
+ nri add 256 511
+ nri add 1024
+OsmoHNBGW(config-msc)# exit
+
+OsmoHNBGW(config)# ### Do msc 2 first, to see that the order of mscs in the internal list is not determined by the msc->nr,
+OsmoHNBGW(config)# ### and whichever was configured first gets higher priority for overlaps.
+
+OsmoHNBGW(config)# msc 2
+OsmoHNBGW(config-msc)# nri add 200 300
+% Warning: msc 2: NRI range [200..300] overlaps between msc 2 and msc 0. For overlaps, msc 0 has higher priority than msc 2
+OsmoHNBGW(config-msc)# nri add 1024 1025
+% Warning: msc 2: Warning: NRI range surpasses current NRI bitlen: 1024..1025
+% Warning: msc 2: NRI range [1024..1025] overlaps between msc 2 and msc 0. For overlaps, msc 0 has higher priority than msc 2
+OsmoHNBGW(config-msc)# exit
+
+OsmoHNBGW(config)# msc 1
+OsmoHNBGW(config-msc)# nri add 42
+OsmoHNBGW(config-msc)# nri add 512 767
+OsmoHNBGW(config-msc)# nri add 200 300
+% Warning: msc 1: NRI range [200..300] overlaps between msc 1 and msc 0. For overlaps, msc 0 has higher priority than msc 1
+% Warning: msc 1: NRI range [200..300] overlaps between msc 1 and msc 2. For overlaps, msc 2 has higher priority than msc 1
+OsmoHNBGW(config-msc)# nri add 1024 1025
+% Warning: msc 1: Warning: NRI range surpasses current NRI bitlen: 1024..1025
+% Warning: msc 1: NRI range [1024..1025] overlaps between msc 1 and msc 0. For overlaps, msc 0 has higher priority than msc 1
+% Warning: msc 1: NRI range [1024..1025] overlaps between msc 1 and msc 2. For overlaps, msc 2 has higher priority than msc 1
+OsmoHNBGW(config-msc)# show nri
+msc 1
+ nri add 42
+ nri add 200 300
+ nri add 512 767
+ nri add 1024 1025
+OsmoHNBGW(config-msc)# exit
+
+OsmoHNBGW(config)# do show nri
+hnbgw
+ iucs
+ nri bitlen 10
+ % No NULL-NRI entries
+ iups
+ nri bitlen 10
+ % No NULL-NRI entries
+msc 0
+ nri add 23
+ nri add 100 200
+ nri add 256 511
+ nri add 1024
+msc 2
+ nri add 200 300
+ nri add 1024 1025
+msc 1
+ nri add 42
+ nri add 200 300
+ nri add 512 767
+ nri add 1024 1025
+sgsn 0
+ % no NRI mappings
+
+OsmoHNBGW(config)# ### msc and sgsn have separate scopes of NRI, i.e. overlaps are no problem
+OsmoHNBGW(config)# sgsn 0
+OsmoHNBGW(config-sgsn)# nri add 0 1023
+OsmoHNBGW(config-sgsn)# show nri
+sgsn 0
+ nri add 0 1023
+OsmoHNBGW(config-sgsn)# exit
+
+OsmoHNBGW(config)# ### NULL-NRI config
+OsmoHNBGW(config)# hnbgw
+OsmoHNBGW(config-hnbgw)# iucs
+
+OsmoHNBGW(config-hnbgw-iucs)# list
+...
+ nri bitlen <1-15>
+ nri null add <0-32767> [<0-32767>]
+ nri null del <0-32767> [<0-32767>]
+...
+
+OsmoHNBGW(config-hnbgw-iucs)# nri ?
+ bitlen Set number of bits that an NRI has, to extract from TMSI identities (always starting just after the TMSI's most significant octet).
+ null Define NULL-NRI values that cause re-assignment of an MS to a different CN peer, for CN pooling.
+
+OsmoHNBGW(config-hnbgw-iucs)# nri bitlen ?
+ <1-15> bit count (default: 10)
+
+OsmoHNBGW(config-hnbgw-iucs)# nri bitlen 11
+OsmoHNBGW(config-hnbgw-iucs)# show running-config
+...
+hnbgw
+...
+ iucs
+...
+ nri bitlen 11
+...
+
+OsmoHNBGW(config-hnbgw-iucs)# nri null ?
+ add Add NULL-NRI value (or range)
+ del Remove NRI value or range from the NRI mapping for this CN link
+
+OsmoHNBGW(config-hnbgw-iucs)# nri null add ?
+ <0-32767> First value of the NRI value range, should not surpass the configured 'nri bitlen'.
+OsmoHNBGW(config-hnbgw-iucs)# nri null add 0 ?
+ [<0-32767>] Last value of the NRI value range, should not surpass the configured 'nri bitlen' and be larger than the first value; if omitted, apply only the first value.
+
+OsmoHNBGW(config-hnbgw-iucs)# nri null del ?
+ <0-32767> First value of the NRI value range, should not surpass the configured 'nri bitlen'.
+OsmoHNBGW(config-hnbgw-iucs)# nri null del 0 ?
+ [<0-32767>] Last value of the NRI value range, should not surpass the configured 'nri bitlen' and be larger than the first value; if omitted, apply only the first value.
+
+OsmoHNBGW(config-hnbgw-iucs)# exit
+
+OsmoHNBGW(config-hnbgw)# iups
+
+OsmoHNBGW(config-hnbgw-iups)# list
+...
+ nri bitlen <1-15>
+ nri null add <0-32767> [<0-32767>]
+ nri null del <0-32767> [<0-32767>]
+...
+
+OsmoHNBGW(config-hnbgw-iups)# nri ?
+ bitlen Set number of bits that an NRI has, to extract from TMSI identities (always starting just after the TMSI's most significant octet).
+ null Define NULL-NRI values that cause re-assignment of an MS to a different CN peer, for CN pooling.
+
+OsmoHNBGW(config-hnbgw-iups)# nri bitlen ?
+ <1-15> bit count (default: 10)
+
+OsmoHNBGW(config-hnbgw-iups)# nri bitlen 9
+OsmoHNBGW(config-hnbgw-iups)# show running-config
+...
+hnbgw
+...
+ iups
+...
+ nri bitlen 9
+...
+
+OsmoHNBGW(config-hnbgw-iups)# nri null ?
+ add Add NULL-NRI value (or range)
+ del Remove NRI value or range from the NRI mapping for this CN link
+
+OsmoHNBGW(config-hnbgw-iups)# nri null add ?
+ <0-32767> First value of the NRI value range, should not surpass the configured 'nri bitlen'.
+OsmoHNBGW(config-hnbgw-iups)# nri null add 0 ?
+ [<0-32767>] Last value of the NRI value range, should not surpass the configured 'nri bitlen' and be larger than the first value; if omitted, apply only the first value.
+
+OsmoHNBGW(config-hnbgw-iups)# nri null del ?
+ <0-32767> First value of the NRI value range, should not surpass the configured 'nri bitlen'.
+OsmoHNBGW(config-hnbgw-iups)# nri null del 0 ?
+ [<0-32767>] Last value of the NRI value range, should not surpass the configured 'nri bitlen' and be larger than the first value; if omitted, apply only the first value.
+
+OsmoHNBGW(config-hnbgw-iups)# exit
+
+OsmoHNBGW(config-hnbgw)# exit
+
+OsmoHNBGW(config)# msc 0
+OsmoHNBGW(config-msc)# nri del 0 10000
+OsmoHNBGW(config-msc)# exit
+OsmoHNBGW(config)# msc 1
+OsmoHNBGW(config-msc)# nri del 0 10000
+OsmoHNBGW(config-msc)# exit
+OsmoHNBGW(config)# msc 2
+OsmoHNBGW(config-msc)# nri del 0 10000
+OsmoHNBGW(config-msc)# exit
+OsmoHNBGW(config)# do show nri
+hnbgw
+ iucs
+ nri bitlen 11
+ % No NULL-NRI entries
+ iups
+ nri bitlen 9
+ % No NULL-NRI entries
+msc 0
+ % no NRI mappings
+msc 2
+ % no NRI mappings
+msc 1
+ % no NRI mappings
+sgsn 0
+ nri add 0 1023
+
+OsmoHNBGW(config)# msc 0
+OsmoHNBGW(config-msc)# nri add 0 1000
+OsmoHNBGW(config-msc)# show nri
+msc 0
+ nri add 0 1000
+OsmoHNBGW(config-msc)# nri del 23
+OsmoHNBGW(config-msc)# nri del 200 300
+OsmoHNBGW(config-msc)# nri del 1000 2000
+OsmoHNBGW(config-msc)# show nri
+msc 0
+ nri add 0 22
+ nri add 24 199
+ nri add 301 999
+OsmoHNBGW(config-msc)# nri add 23
+OsmoHNBGW(config-msc)# show nri
+msc 0
+ nri add 0 199
+ nri add 301 999
+OsmoHNBGW(config-msc)# nri add 200 300
+OsmoHNBGW(config-msc)# show nri
+msc 0
+ nri add 0 999
+OsmoHNBGW(config-msc)# nri add 1000
+OsmoHNBGW(config-msc)# show nri
+msc 0
+ nri add 0 1000
+
+OsmoHNBGW(config-msc)# show running-config
+... ! no allow-attach
+OsmoHNBGW(config-msc)# no allow-attach
+OsmoHNBGW(config-msc)# show running-config
+...
+msc 0
+...
+ nri add 0 1000
+ no allow-attach
+... ! no allow-attach
+OsmoHNBGW(config-msc)# exit
+OsmoHNBGW(config)# sgsn 1
+OsmoHNBGW(config-sgsn)# no allow-attach
+OsmoHNBGW(config-sgsn)# show running-config
+...
+msc 0
+...
+ nri add 0 1000
+ no allow-attach
+... ! no allow-attach
+sgsn 1
+...
+ no allow-attach
+...
+
+OsmoHNBGW(config-sgsn)# allow-attach
+OsmoHNBGW(config-sgsn)# exit
+OsmoHNBGW(config)# msc 0
+OsmoHNBGW(config-msc)# allow-attach
+OsmoHNBGW(config-msc)# show running-config
+... ! no allow-attach
+OsmoHNBGW(config-msc)# exit
--
To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/33130
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-hnbgw
Gerrit-Branch: master
Gerrit-Change-Id: Ifb87e01e5971962e5cfe5e127871af4a67806de1
Gerrit-Change-Number: 33130
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-MessageType: newchange
neels has submitted this change. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/32987 )
(
1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
)Change subject: use new osmo_sccp_instance_next_conn_id()
......................................................................
use new osmo_sccp_instance_next_conn_id()
Change-Id: I0fc6e486ce5d68b06d0bc9869292f082ec7a67f0
---
M include/osmocom/hnbgw/hnbgw.h
M src/osmo-hnbgw/context_map.c
M src/osmo-hnbgw/hnbgw_cn.c
3 files changed, 11 insertions(+), 44 deletions(-)
Approvals:
laforge: Looks good to me, but someone else must approve
pespin: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/include/osmocom/hnbgw/hnbgw.h b/include/osmocom/hnbgw/hnbgw.h
index e67a86a..6570bdf 100644
--- a/include/osmocom/hnbgw/hnbgw.h
+++ b/include/osmocom/hnbgw/hnbgw.h
@@ -67,7 +67,6 @@
/* reference to the SCCP User SAP by which we communicate */
struct osmo_sccp_instance *sccp;
struct osmo_sccp_user *sccp_user;
- uint32_t next_conn_id;
/* linked list of hnbgw_context_map */
struct llist_head map_list;
diff --git a/src/osmo-hnbgw/context_map.c b/src/osmo-hnbgw/context_map.c
index f610087..f8d0ecf 100644
--- a/src/osmo-hnbgw/context_map.c
+++ b/src/osmo-hnbgw/context_map.c
@@ -52,47 +52,6 @@
return MAP_S_CONNECTING;
}
-/* is a given SCCP USER SAP Connection ID in use for a given CN link? */
-static int cn_id_in_use(struct hnbgw_cnlink *cn, uint32_t id)
-{
- struct hnbgw_context_map *map;
-
- llist_for_each_entry(map, &cn->map_list, cn_list) {
- if (map->scu_conn_id == id)
- return 1;
- }
- return 0;
-}
-
-/* try to allocate a new SCCP User SAP Connection ID */
-static int alloc_cn_conn_id(struct hnbgw_cnlink *cn, uint32_t *id_out)
-{
- uint32_t i;
- uint32_t id;
-
- /* SUA: RFC3868 sec 3.10.4:
- * The source reference number is a 4 octet long integer.
- * This is allocated by the source SUA instance.
- * M3UA/SCCP: ITU-T Q.713 sec 3.3:
- * The "source local reference" parameter field is a three-octet field containing a
- * reference number which is generated and used by the local node to identify the
- * connection section after the connection section is set up.
- * The coding "all ones" is reserved for future use.
- * Hence, let's simply use 24 bit ids to fit all link types (excluding 0x00ffffff).
- */
-
- for (i = 0; i < 0x00ffffff; i++) {
- id = cn->next_conn_id++;
- if (cn->next_conn_id == 0x00ffffff)
- cn->next_conn_id = 0;
- if (!cn_id_in_use(cn, id)) {
- *id_out = id;
- return 1;
- }
- }
- return -1;
-}
-
/* Map from a HNB + ContextID to the SCCP-side Connection ID */
struct hnbgw_context_map *
context_map_alloc_by_hnb(struct hnb_context *hnb, uint32_t rua_ctx_id,
@@ -118,7 +77,8 @@
}
}
- if (alloc_cn_conn_id(cn_if_new, &new_scu_conn_id) < 0) {
+ new_scu_conn_id = osmo_sccp_instance_next_conn_id(map->cn_link->sccp);
+ if (new_scu_conn_id < 0) {
LOGHNB(hnb, DMAIN, LOGL_ERROR, "Unable to allocate CN connection ID\n");
return NULL;
}
diff --git a/src/osmo-hnbgw/hnbgw_cn.c b/src/osmo-hnbgw/hnbgw_cn.c
index d9e35af..33ec0f6 100644
--- a/src/osmo-hnbgw/hnbgw_cn.c
+++ b/src/osmo-hnbgw/hnbgw_cn.c
@@ -495,7 +495,6 @@
cnlink = talloc_zero(g_hnbgw, struct hnbgw_cnlink);
INIT_LLIST_HEAD(&cnlink->map_list);
- cnlink->next_conn_id = 1000;
cnlink->sccp_user = osmo_sccp_user_bind_pc(g_hnbgw->sccp.client, "OsmoHNBGW", sccp_sap_up,
OSMO_SCCP_SSN_RANAP, g_hnbgw->sccp.local_addr.pc);
--
To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/32987
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-hnbgw
Gerrit-Branch: master
Gerrit-Change-Id: I0fc6e486ce5d68b06d0bc9869292f082ec7a67f0
Gerrit-Change-Number: 32987
Gerrit-PatchSet: 2
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged
neels has submitted this change. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/32915 )
Change subject: immediately SCCP RLSD on HNB re-register
......................................................................
immediately SCCP RLSD on HNB re-register
The RUA side may disconnect
a) gracefully (RUA Disconnect with RANAP IU Release Complete) or
b) by detecting that the HNB is gone / has restarted
For a), the SCCP side waits for a RLSD from the CN that follows the IU
Release Complete.
For b), we so far also wait for a RLSD from CN, which will never come,
and only after a timeout send an SCCP RLSD to the CN.
Instead, for b), immediately send an SCCP RLSD.
To distinguish between the graceful release (a) and the disruptive
release (b), add new state MAP_RUA_ST_DISRUPTED on the RUA side,
and add new event MAP_SCCP_EV_RAN_LINK_LOST for the SCCP side.
Any non-graceful disconnect of RUA enters ST_DISRUPTED.
disrupted_onenter() dispatches EV_RAN_LINK_LOST to SCCP,
and SCCP directly sends RLSD to the CN without timeout.
These changes are also shown in doc/charts/hnbgw_context_map.msc.
Change-Id: I4e78617ad39bb73fe92097c8a1a8069da6a7f6a1
---
M doc/charts/hnbgw_context_map.msc
M include/osmocom/hnbgw/context_map.h
M src/osmo-hnbgw/context_map_rua.c
M src/osmo-hnbgw/context_map_sccp.c
4 files changed, 95 insertions(+), 15 deletions(-)
Approvals:
pespin: Looks good to me, but someone else must approve
Jenkins Builder: Verified
laforge: Looks good to me, but someone else must approve
neels: Looks good to me, approved
diff --git a/doc/charts/hnbgw_context_map.msc b/doc/charts/hnbgw_context_map.msc
index 7a4da55..d287d89 100644
--- a/doc/charts/hnbgw_context_map.msc
+++ b/doc/charts/hnbgw_context_map.msc
@@ -65,7 +65,7 @@
sccp abox sccp [label="MAP_SCCP_ST_DISCONNECTED"];
rua <= sccp [label="MAP_RUA_EV_CN_DISC"];
hnb <= rua [label="RUA Disconnect"];
- rua abox rua [label="MAP_RUA_ST_DISCONNECTED"];
+ rua abox rua [label="MAP_RUA_ST_DISRUPTED"];
rua rbox sccp [label="map_check_released()"];
rua rbox sccp [label="hnbgw_context_map_free()"];
@@ -81,10 +81,10 @@
--- [label="Ungraceful release from HNB"];
hnb -x rua [label="link loss"];
rua rbox rua [label="MAP_RUA_EV_HNB_LINK_LOST"];
- rua => sccp [label="MAP_SCCP_EV_RAN_DISC"];
+ rua abox rua [label="MAP_RUA_ST_DISRUPTED"];
+ rua => sccp [label="MAP_SCCP_EV_RAN_LINK_LOST"];
sccp => cn [label="SCCP Released"];
sccp abox sccp [label="MAP_SCCP_ST_DISCONNECTED"];
- rua abox rua [label="MAP_RUA_ST_DISCONNECTED"];
rua rbox sccp [label="map_check_released()"];
rua rbox sccp [label="hnbgw_context_map_free()"];
@@ -98,10 +98,8 @@
rua rbox rua [label="MAP_RUA_EV_HNB_LINK_LOST"];
hnb <= rua [label="RUA Disconnect"];
hnb note rua [label="TODO: does it make sense to send\nRUA Disconnect per context when HNB is/was gone?\nOr has the HNB implicitly discarded these?"];
- rua abox rua [label="MAP_RUA_ST_DISCONNECTED"];
- rua => sccp [label="MAP_SCCP_EV_RAN_DISC\nfrom map_rua_disconnected_onenter()"];
- sccp abox sccp [label="MAP_SCCP_ST_WAIT_RLSD"];
- rua => sccp [label="MAP_SCCP_EV_RAN_DISC\nto skip waiting for SCCP Released from CN"];
+ rua abox rua [label="MAP_RUA_ST_DISRUPTED"];
+ rua => sccp [label="MAP_SCCP_EV_RAN_LINK_LOST\nfrom map_rua_disrupted_onenter()"];
sccp => cn [label="SCCP Released"];
sccp abox sccp [label="MAP_SCCP_ST_DISCONNECTED"];
rua rbox sccp [label="map_check_released()"];
diff --git a/include/osmocom/hnbgw/context_map.h b/include/osmocom/hnbgw/context_map.h
index a2e76c3..9320ce0 100644
--- a/include/osmocom/hnbgw/context_map.h
+++ b/include/osmocom/hnbgw/context_map.h
@@ -51,6 +51,8 @@
* CN should have received an Iu-ReleaseComplete with or before this, give CN a chance to send an SCCP RLSD;
* after a timeout we will send a non-standard RLSD to the CN instead. */
MAP_SCCP_EV_RAN_DISC,
+ /* The RAN released ungracefully. We will directly disconnect the SCCP connection, too. */
+ MAP_SCCP_EV_RAN_LINK_LOST,
/* Receiving an SCCP RLSD from CN, or libosmo-sigtran tells us about SCCP connection timeout. All done. */
MAP_SCCP_EV_RX_RELEASED,
};
diff --git a/src/osmo-hnbgw/context_map_rua.c b/src/osmo-hnbgw/context_map_rua.c
index f50f711..9e8f028 100644
--- a/src/osmo-hnbgw/context_map_rua.c
+++ b/src/osmo-hnbgw/context_map_rua.c
@@ -41,6 +41,7 @@
MAP_RUA_ST_INIT,
MAP_RUA_ST_CONNECTED,
MAP_RUA_ST_DISCONNECTED,
+ MAP_RUA_ST_DISRUPTED,
};
static const struct value_string map_rua_fsm_event_names[] = {
@@ -58,6 +59,7 @@
static const struct osmo_tdef_state_timeout map_rua_fsm_timeouts[32] = {
[MAP_RUA_ST_INIT] = { .T = -31 },
[MAP_RUA_ST_DISCONNECTED] = { .T = -31 },
+ [MAP_RUA_ST_DISRUPTED] = { .T = -31 },
};
/* Transition to a state, using the T timer defined in map_rua_fsm_timeouts.
@@ -93,6 +95,7 @@
return MAP_S_ACTIVE;
default:
case MAP_RUA_ST_DISCONNECTED:
+ case MAP_RUA_ST_DISRUPTED:
return MAP_S_DISCONNECTING;
}
}
@@ -103,6 +106,7 @@
return false;
switch (map->rua_fi->state) {
case MAP_RUA_ST_DISCONNECTED:
+ case MAP_RUA_ST_DISRUPTED:
return false;
default:
return true;
@@ -114,10 +118,11 @@
/* Return 1 to terminate FSM instance, 0 to keep running */
switch (fi->state) {
default:
- map_rua_fsm_state_chg(MAP_RUA_ST_DISCONNECTED);
+ map_rua_fsm_state_chg(MAP_RUA_ST_DISRUPTED);
return 0;
case MAP_RUA_ST_DISCONNECTED:
+ case MAP_RUA_ST_DISRUPTED:
return 1;
}
}
@@ -210,8 +215,6 @@
return;
case MAP_RUA_EV_RX_DISCONNECT:
- case MAP_RUA_EV_CN_DISC:
- case MAP_RUA_EV_HNB_LINK_LOST:
/* Unlikely that SCCP is active, but let the SCCP FSM decide about that. */
handle_rx_rua(fi, ranap_msg);
/* There is a reason to shut down this RUA connection. Super unlikely, we haven't even processed the
@@ -220,6 +223,11 @@
map_rua_fsm_state_chg(MAP_RUA_ST_DISCONNECTED);
break;
+ case MAP_RUA_EV_CN_DISC:
+ case MAP_RUA_EV_HNB_LINK_LOST:
+ map_rua_fsm_state_chg(MAP_RUA_ST_DISRUPTED);
+ break;
+
default:
OSMO_ASSERT(false);
}
@@ -276,14 +284,14 @@
case MAP_RUA_EV_HNB_LINK_LOST:
/* The HNB is gone. Cannot gracefully cleanup the RUA connection, just be gone. */
- map_rua_fsm_state_chg(MAP_RUA_ST_DISCONNECTED);
+ map_rua_fsm_state_chg(MAP_RUA_ST_DISRUPTED);
return;
case MAP_RUA_EV_CN_DISC:
/* There is a disruptive reason to shut down this RUA connection, HNB is still there */
OSMO_ASSERT(data == NULL);
map_rua_tx_disconnect(fi);
- map_rua_fsm_state_chg(MAP_RUA_ST_DISCONNECTED);
+ map_rua_fsm_state_chg(MAP_RUA_ST_DISRUPTED);
return;
default:
@@ -291,23 +299,35 @@
}
}
-static void map_rua_disconnected_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
+static void map_rua_free_if_done(struct hnbgw_context_map *map, uint32_t sccp_event)
{
- struct hnbgw_context_map *map = fi->priv;
/* From RUA's POV, we can now free the hnbgw_context_map.
* If SCCP is still active, tell it to disconnect -- in that case the SCCP side will call context_map_free().
* If SCCP is no longer active, free this map. */
if (map_sccp_is_active(map))
- map_sccp_dispatch(map, MAP_SCCP_EV_RAN_DISC, NULL);
+ map_sccp_dispatch(map, sccp_event, NULL);
else
context_map_free(map);
}
+static void map_rua_disconnected_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
+{
+ struct hnbgw_context_map *map = fi->priv;
+ map_rua_free_if_done(map, MAP_SCCP_EV_RAN_DISC);
+}
+
static void map_rua_disconnected_action(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
struct msgb *ranap_msg = data;
if (msg_has_l2_data(ranap_msg))
LOGPFSML(fi, LOGL_ERROR, "RUA not connected, cannot dispatch RANAP message\n");
+ /* Ignore all events. */
+}
+
+static void map_rua_disrupted_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
+{
+ struct hnbgw_context_map *map = fi->priv;
+ map_rua_free_if_done(map, MAP_SCCP_EV_RAN_LINK_LOST);
}
void map_rua_fsm_cleanup(struct osmo_fsm_inst *fi, enum osmo_fsm_term_cause cause)
@@ -331,6 +351,7 @@
| S(MAP_RUA_ST_INIT)
| S(MAP_RUA_ST_CONNECTED)
| S(MAP_RUA_ST_DISCONNECTED)
+ | S(MAP_RUA_ST_DISRUPTED)
,
.action = map_rua_init_action,
},
@@ -345,6 +366,7 @@
,
.out_state_mask = 0
| S(MAP_RUA_ST_DISCONNECTED)
+ | S(MAP_RUA_ST_DISRUPTED)
,
.action = map_rua_connected_action,
},
@@ -357,6 +379,16 @@
.onenter = map_rua_disconnected_onenter,
.action = map_rua_disconnected_action,
},
+ [MAP_RUA_ST_DISRUPTED] = {
+ .name = "disrupted",
+ .in_event_mask = 0
+ | S(MAP_RUA_EV_CN_DISC)
+ | S(MAP_RUA_EV_HNB_LINK_LOST)
+ ,
+ .onenter = map_rua_disrupted_onenter,
+ /* same as MAP_RUA_ST_DISCONNECTED: */
+ .action = map_rua_disconnected_action,
+ },
};
static struct osmo_fsm map_rua_fsm = {
diff --git a/src/osmo-hnbgw/context_map_sccp.c b/src/osmo-hnbgw/context_map_sccp.c
index 132d03e..3de8215 100644
--- a/src/osmo-hnbgw/context_map_sccp.c
+++ b/src/osmo-hnbgw/context_map_sccp.c
@@ -52,6 +52,7 @@
OSMO_VALUE_STRING(MAP_SCCP_EV_RX_DATA_INDICATION),
OSMO_VALUE_STRING(MAP_SCCP_EV_TX_DATA_REQUEST),
OSMO_VALUE_STRING(MAP_SCCP_EV_RAN_DISC),
+ OSMO_VALUE_STRING(MAP_SCCP_EV_RAN_LINK_LOST),
OSMO_VALUE_STRING(MAP_SCCP_EV_RX_RELEASED),
{}
};
@@ -262,6 +263,7 @@
map_sccp_fsm_state_chg(MAP_SCCP_ST_WAIT_CC);
return;
+ case MAP_SCCP_EV_RAN_LINK_LOST:
case MAP_SCCP_EV_RAN_DISC:
/* No CR has been sent yet, just go to disconnected state. */
if (msg_has_l2_data(ranap_msg))
@@ -297,6 +299,7 @@
LOGPFSML(fi, LOGL_ERROR, "Connection not yet confirmed, cannot forward RANAP to CN\n");
return;
+ case MAP_SCCP_EV_RAN_LINK_LOST:
case MAP_SCCP_EV_RAN_DISC:
/* RUA connection was terminated. First wait for the CC before releasing the SCCP conn. */
if (msg_has_l2_data(ranap_msg))
@@ -351,6 +354,16 @@
tx_sccp_df1(fi, ranap_msg);
return;
+ case MAP_SCCP_EV_RAN_LINK_LOST:
+ /* RUA has disconnected ungracefully, so there is no Iu Release that told the CN to disconnect.
+ * Disconnect on the SCCP layer, ungracefully. */
+ /* There won't be any ranap_msg, but if a caller wants to dispatch a msg, forward it before
+ * disconnecting. */
+ tx_sccp_df1(fi, ranap_msg);
+ tx_sccp_rlsd(fi);
+ map_sccp_fsm_state_chg(MAP_SCCP_ST_DISCONNECTED);
+ return;
+
case MAP_SCCP_EV_RX_RELEASED:
/* The CN sends an N-Disconnect (SCCP Released) out of the usual sequence. Not what we expected, but
* handle it. */
@@ -480,6 +493,7 @@
.in_event_mask = 0
| S(MAP_SCCP_EV_TX_DATA_REQUEST)
| S(MAP_SCCP_EV_RAN_DISC)
+ | S(MAP_SCCP_EV_RAN_LINK_LOST)
| S(MAP_SCCP_EV_RX_RELEASED)
,
.out_state_mask = 0
@@ -495,6 +509,7 @@
| S(MAP_SCCP_EV_RX_CONNECTION_CONFIRM)
| S(MAP_SCCP_EV_TX_DATA_REQUEST)
| S(MAP_SCCP_EV_RAN_DISC)
+ | S(MAP_SCCP_EV_RAN_LINK_LOST)
| S(MAP_SCCP_EV_RX_RELEASED)
,
.out_state_mask = 0
@@ -509,6 +524,7 @@
| S(MAP_SCCP_EV_RX_DATA_INDICATION)
| S(MAP_SCCP_EV_TX_DATA_REQUEST)
| S(MAP_SCCP_EV_RAN_DISC)
+ | S(MAP_SCCP_EV_RAN_LINK_LOST)
| S(MAP_SCCP_EV_RX_RELEASED)
| S(MAP_SCCP_EV_RX_CONNECTION_CONFIRM)
,
@@ -526,6 +542,7 @@
| S(MAP_SCCP_EV_RX_DATA_INDICATION)
| S(MAP_SCCP_EV_TX_DATA_REQUEST)
| S(MAP_SCCP_EV_RAN_DISC)
+ | S(MAP_SCCP_EV_RAN_LINK_LOST)
| S(MAP_SCCP_EV_RX_CONNECTION_CONFIRM)
,
.out_state_mask = 0
@@ -539,6 +556,7 @@
.in_event_mask = 0
| S(MAP_SCCP_EV_TX_DATA_REQUEST)
| S(MAP_SCCP_EV_RAN_DISC)
+ | S(MAP_SCCP_EV_RAN_LINK_LOST)
,
.onenter = map_sccp_disconnected_onenter,
.action = map_sccp_disconnected_action,
--
To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/32915
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-hnbgw
Gerrit-Branch: master
Gerrit-Change-Id: I4e78617ad39bb73fe92097c8a1a8069da6a7f6a1
Gerrit-Change-Number: 32915
Gerrit-PatchSet: 4
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged
Attention is currently required from: pespin, msuraev.
neels has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/32323 )
Change subject: cnpool: allow separate cs7 for IuPS and IuCS
......................................................................
Patch Set 9:
(1 comment)
File include/osmocom/hnbgw/hnbgw.h:
https://gerrit.osmocom.org/c/osmo-hnbgw/+/32323/comment/6cdf28d1_c7d76de4
PS8, Line 133: if (!cnlink->hnbgw_sccp_user)
> In places where it's established to be safe i can just use cnlink->hnbgw_sccp_usser->ss7->sccp direc […]
(in patch Ifc5242547260154eb5aecd3a9d9c2aac8419e8db it will be more obvious that there can be a hnbgw_context_map without a cnlink yet...)
--
To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/32323
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-hnbgw
Gerrit-Branch: master
Gerrit-Change-Id: Iea1824f1c586723d989c80a909bae16bd2866e08
Gerrit-Change-Number: 32323
Gerrit-PatchSet: 9
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-CC: msuraev <msuraev(a)sysmocom.de>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: msuraev <msuraev(a)sysmocom.de>
Gerrit-Comment-Date: Thu, 01 Jun 2023 00:10:35 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: neels <nhofmeyr(a)sysmocom.de>
Comment-In-Reply-To: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: comment