lists.osmocom.org
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

gerrit-log

Thread Start a new thread
Download
Threads by month
  • ----- 2026 -----
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2025 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
gerrit-log@lists.osmocom.org

June 2023

  • 1 participants
  • 2480 discussions
[L] Change in osmo-hnbgw[master]: cnpool: extract Mobile Identity from RANAP payload
by neels 05 Jun '23

05 Jun '23
Attention is currently required from: pespin. Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/33133 to look at the new patch set (#3). Change subject: cnpool: extract Mobile Identity from RANAP payload ...................................................................... cnpool: extract Mobile Identity from RANAP payload For InitialUE messages, decode the RANAP and NAS PDU to obtain the Mobile Identity. Store it in map->l3. A following patch will use this mobile identity to decide on which CN links to pick from the CN pools for this subscriber. Add the new information to LOG_MAP() as ubiquitous logging context. Related: SYS#6412 Change-Id: I373d665c9684b607207f68094188eab63209db51 --- M include/osmocom/hnbgw/context_map.h M include/osmocom/hnbgw/hnbgw.h M src/osmo-hnbgw/Makefile.am A src/osmo-hnbgw/hnbgw_l3.c M src/osmo-hnbgw/hnbgw_rua.c 5 files changed, 353 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hnbgw refs/changes/33/33133/3 -- To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/33133 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hnbgw Gerrit-Branch: master Gerrit-Change-Id: I373d665c9684b607207f68094188eab63209db51 Gerrit-Change-Number: 33133 Gerrit-PatchSet: 3 Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-CC: pespin <pespin(a)sysmocom.de> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: newpatchset
1 0
0 0
[L] Change in osmo-hnbgw[master]: cnpool: extract Mobile Identity from RANAP payload
by neels 05 Jun '23

05 Jun '23
Attention is currently required from: pespin. neels has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/33133 ) Change subject: cnpool: extract Mobile Identity from RANAP payload ...................................................................... Patch Set 2: (1 comment) File src/osmo-hnbgw/hnbgw_l3.c: https://gerrit.osmocom.org/c/osmo-hnbgw/+/33133/comment/7bf9f6b8_8b310925 PS2, Line 104: /* Old routing area identification 10.5.5.15. */ > You can use gsm48_parse_ra() here, see gprs_gmm_rx_att_ack() in libosmo-gprs. […] ack, thx. btw, i notice gsm48_parse_ra() should probably call osmo_plmn_from_bcd() instead of duplicating. it does because it's been there for a long long time -- To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/33133 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hnbgw Gerrit-Branch: master Gerrit-Change-Id: I373d665c9684b607207f68094188eab63209db51 Gerrit-Change-Number: 33133 Gerrit-PatchSet: 2 Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-CC: pespin <pespin(a)sysmocom.de> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Mon, 05 Jun 2023 12:57:25 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: comment
1 0
0 0
[S] Change in osmo-bts[master]: paging: do not confirm PAGING COMMAND messages
by fixeria 05 Jun '23

05 Jun '23
Attention is currently required from: dexter. fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/32734 ) Change subject: paging: do not confirm PAGING COMMAND messages ...................................................................... Patch Set 6: (1 comment) Patchset: PS6: IMO, it does not worth to introduce such a layering violation (i.e. parsing GSM RR messages in the PCUIF protocol logic). If osmo-pcu is fine with dropping confirmations for paging, I think it's fine to leave osmo-bts as it is. If some day osmo-pcu needs the confirmations for paging messages, it would simply stop discarding and will make use of them. -- To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/32734 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Change-Id: I8b8264d28b1b1deb08774cdba58dd4c6dafe115d Gerrit-Change-Number: 32734 Gerrit-PatchSet: 6 Gerrit-Owner: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: dexter <pmaier(a)sysmocom.de> Gerrit-Comment-Date: Mon, 05 Jun 2023 12:56:44 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Gerrit-MessageType: comment
1 0
0 0
[S] Change in osmo-bts[master]: paging: do not confirm PAGING COMMAND messages
by fixeria 05 Jun '23

05 Jun '23
Attention is currently required from: dexter. fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/32734 ) Change subject: paging: do not confirm PAGING COMMAND messages ...................................................................... Patch Set 6: (1 comment) File src/common/pcu_sock.c: https://gerrit.osmocom.org/c/osmo-bts/+/32734/comment/d618df6f_25faaf16 PS6, Line 671: struct gsm48_imm_ass *gsm48_imm_ass; cosmetic: make both variables scoped: ``` case PCU_IF_SAPI_PCH: { struct gsm48_imm_ass *gsm48_imm_ass; bool confirm = false; // ... break; } ``` -- To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/32734 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Change-Id: I8b8264d28b1b1deb08774cdba58dd4c6dafe115d Gerrit-Change-Number: 32734 Gerrit-PatchSet: 6 Gerrit-Owner: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: dexter <pmaier(a)sysmocom.de> Gerrit-Comment-Date: Mon, 05 Jun 2023 12:52:19 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Gerrit-MessageType: comment
1 0
0 0
[M] Change in osmo-hnbgw[master]: cnpool: examples and config tests: use 'msc 0'/'sgsn 0' syntax
by neels 05 Jun '23

05 Jun '23
neels has submitted this change. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/33129 ) ( 1 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: cnpool: examples and config tests: use 'msc 0'/'sgsn 0' syntax ...................................................................... cnpool: examples and config tests: use 'msc 0'/'sgsn 0' syntax After recent introduction of multiple 'msc' and 'sgsn' nodes in the VTY config, switch cfg files to the new syntax: - in doc/examples - for 'make config-tests' - have one test in old config syntax to test backwards compat: 'legacy', an exact copy of 'one_cs7_with_addrs'. Related: SYS#6412 Change-Id: If999b71a8a8237699f6ccfcaa31d1885e66c0518 --- M doc/examples/osmo-hnbgw/osmo-hnbgw-cs7.cfg A tests/config/legacy.cfg A tests/config/legacy.vty M tests/config/one_cs7_with_addrs.cfg M tests/config/one_cs7_with_iucs_addr.cfg M tests/config/one_cs7_with_iups_addr.cfg M tests/config/two_cs7_with_addrs.cfg 7 files changed, 92 insertions(+), 20 deletions(-) Approvals: laforge: Looks good to me, but someone else must approve pespin: Looks good to me, approved Jenkins Builder: Verified diff --git a/doc/examples/osmo-hnbgw/osmo-hnbgw-cs7.cfg b/doc/examples/osmo-hnbgw/osmo-hnbgw-cs7.cfg index 5e78947..daf0668 100644 --- a/doc/examples/osmo-hnbgw/osmo-hnbgw-cs7.cfg +++ b/doc/examples/osmo-hnbgw/osmo-hnbgw-cs7.cfg @@ -11,10 +11,10 @@ iuh local-ip 0.0.0.0 hnbap-allow-tmsi 1 - iucs - remote-addr my-msc - iups - remote-addr my-sgsn +msc 0 + remote-addr my-msc +sgsn 0 + remote-addr my-sgsn log stderr logging filter all 1 diff --git a/tests/config/legacy.cfg b/tests/config/legacy.cfg new file mode 100644 index 0000000..0369bd4 --- /dev/null +++ b/tests/config/legacy.cfg @@ -0,0 +1,12 @@ +# explicitly point at cs7 instance 0 via two address book entries for CS and PS. Leave ASP and AS to auto-configuration. +cs7 instance 0 + point-code 1.1.1 + sccp-address my-msc + point-code 1.2.3 + sccp-address my-sgsn + point-code 1.4.2 +hnbgw + iucs + remote-addr my-msc + iups + remote-addr my-sgsn diff --git a/tests/config/legacy.vty b/tests/config/legacy.vty new file mode 100644 index 0000000..4df44a5 --- /dev/null +++ b/tests/config/legacy.vty @@ -0,0 +1,47 @@ +OsmoHNBGW> enable + +OsmoHNBGW# ### ASP and AS were auto-configured +OsmoHNBGW# show cs7 config +cs7 instance 0 + point-code 1.1.1 + asp asp-clnt-msc-0 2905 0 m3ua + local-ip localhost + remote-ip localhost + sctp-role client + as as-clnt-msc-0 m3ua + asp asp-clnt-msc-0 + routing-key 0 1.1.1 + sccp-address my-msc + routing-indicator PC + point-code 1.2.3 + sccp-address my-sgsn + routing-indicator PC + point-code 1.4.2 + +OsmoHNBGW# ### IuCS and IuPS were explicitly pointed to specific remote point-codes, using cs7 instance 0 addresses +OsmoHNBGW# show cnlink +IuCS: OsmoHNBGW:RI=SSN_PC,PC=1.1.1,SSN=RANAP <-> my-msc=RI=SSN_PC,PC=1.2.3,SSN=RANAP + SS7 route: pc=0=0.0.0 mask=0x0=0.0.0 via AS as-clnt-msc-0 proto=m3ua ASP asp-clnt-msc-0 +IuPS: OsmoHNBGW:RI=SSN_PC,PC=1.1.1,SSN=RANAP <-> my-sgsn=RI=SSN_PC,PC=1.4.2,SSN=RANAP + SS7 route: pc=0=0.0.0 mask=0x0=0.0.0 via AS as-clnt-msc-0 proto=m3ua ASP asp-clnt-msc-0 + +OsmoHNBGW# show running-config +... +cs7 instance 0 + point-code 1.1.1 + sccp-address my-msc + routing-indicator PC + point-code 1.2.3 + sccp-address my-sgsn + routing-indicator PC + point-code 1.4.2 +hnbgw + rnc-id 23 + log-prefix hnb-id + iuh +... +msc 0 + remote-addr my-msc +sgsn 0 + remote-addr my-sgsn +... diff --git a/tests/config/one_cs7_with_addrs.cfg b/tests/config/one_cs7_with_addrs.cfg index 0369bd4..5075bfd 100644 --- a/tests/config/one_cs7_with_addrs.cfg +++ b/tests/config/one_cs7_with_addrs.cfg @@ -5,8 +5,7 @@ point-code 1.2.3 sccp-address my-sgsn point-code 1.4.2 -hnbgw - iucs - remote-addr my-msc - iups - remote-addr my-sgsn +msc 0 + remote-addr my-msc +sgsn 0 + remote-addr my-sgsn diff --git a/tests/config/one_cs7_with_iucs_addr.cfg b/tests/config/one_cs7_with_iucs_addr.cfg index 9e0207e..406243f 100644 --- a/tests/config/one_cs7_with_iucs_addr.cfg +++ b/tests/config/one_cs7_with_iucs_addr.cfg @@ -3,6 +3,5 @@ point-code 1.1.1 sccp-address my-msc point-code 1.2.3 -hnbgw - iucs - remote-addr my-msc +msc 0 + remote-addr my-msc diff --git a/tests/config/one_cs7_with_iups_addr.cfg b/tests/config/one_cs7_with_iups_addr.cfg index 96e7afa..8684870 100644 --- a/tests/config/one_cs7_with_iups_addr.cfg +++ b/tests/config/one_cs7_with_iups_addr.cfg @@ -3,6 +3,5 @@ point-code 1.1.1 sccp-address my-sgsn point-code 1.4.2 -hnbgw - iups - remote-addr my-sgsn +sgsn 0 + remote-addr my-sgsn diff --git a/tests/config/two_cs7_with_addrs.cfg b/tests/config/two_cs7_with_addrs.cfg index 57f13e3..2249e8f 100644 --- a/tests/config/two_cs7_with_addrs.cfg +++ b/tests/config/two_cs7_with_addrs.cfg @@ -10,8 +10,7 @@ sccp-address my-sgsn point-code 2.4.2 -hnbgw - iucs - remote-addr my-msc - iups - remote-addr my-sgsn +msc 0 + remote-addr my-msc +sgsn 0 + remote-addr my-sgsn -- To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/33129 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hnbgw Gerrit-Branch: master Gerrit-Change-Id: If999b71a8a8237699f6ccfcaa31d1885e66c0518 Gerrit-Change-Number: 33129 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
1 0
0 0
[L] Change in osmo-hnbgw[master]: cnpool: make NRI mappings VTY configurable
by neels 05 Jun '23

05 Jun '23
neels has submitted this change. ( 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, 784 insertions(+), 19 deletions(-) Approvals: Jenkins Builder: Verified pespin: Looks good to me, but someone else must approve laforge: Looks good to me, approved 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 d4d1bad..7c60611 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,215 @@ 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 +792,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 +817,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; } @@ -564,7 +856,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); } } @@ -596,7 +888,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) @@ -617,9 +916,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); @@ -646,6 +951,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); @@ -657,5 +964,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: 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
1 0
0 0
[L] Change in osmo-hnbgw[master]: cnpool: add multiple 'msc' and 'sgsn' cfg (use only the first)
by neels 05 Jun '23

05 Jun '23
neels has submitted this change. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/32324 ) Change subject: cnpool: add multiple 'msc' and 'sgsn' cfg (use only the first) ...................................................................... cnpool: add multiple 'msc' and 'sgsn' cfg (use only the first) Allow configuring multiple MSCs and SGSNs. Show this in new transcript test cnpool.vty and in sccp.dot chart. Still use only the first CN link; actual CN link selection from the pool follows in I66fba27cfbe6e2b27ee3443718846ecfbbd8a974. Config examples and VTY tests cfg files will be adjusted to the new cfg syntax in patch If999b71a8a8237699f6ccfcaa31d1885e66c0518. Only the VTY write() changes are visible here, to pass all transcript tests. Related: SYS#6412 Change-Id: I5479eded786ec26062d49403a8be12967f113cdb --- M doc/charts/sccp.dot M include/osmocom/hnbgw/hnbgw.h M include/osmocom/hnbgw/hnbgw_cn.h M include/osmocom/hnbgw/vty.h M src/osmo-hnbgw/context_map_sccp.c M src/osmo-hnbgw/hnbgw.c M src/osmo-hnbgw/hnbgw_cn.c M src/osmo-hnbgw/hnbgw_vty.c M src/osmo-hnbgw/osmo_hnbgw_main.c A tests/cnpool.vty M tests/config/one_cs7_with_addrs.vty M tests/config/one_cs7_with_iucs_addr.vty M tests/config/one_cs7_with_iups_addr.vty M tests/config/two_cs7_with_addrs.vty 14 files changed, 670 insertions(+), 160 deletions(-) Approvals: Jenkins Builder: Verified pespin: Looks good to me, but someone else must approve laforge: Looks good to me, approved diff --git a/doc/charts/sccp.dot b/doc/charts/sccp.dot index ed11ab9..53d6ca4 100644 --- a/doc/charts/sccp.dot +++ b/doc/charts/sccp.dot @@ -9,13 +9,15 @@ ss0 -> ss0ab msc0a [label="2.2.2"] - ss0ab -> msc0a + sgsn0a [label="3.3.3"] + msc1a [label="5.5.5"] + ss0ab -> msc0a,sgsn0a,msc1a } - sccp0 [label="hnbgw_sccp_user for '0'\n .osmo_ss7_instance 0\n .osmo_sccp_user SSN: RANAP\n PC: ss7 primary = 1.1.1"]; + sccp0 [label="hnbgw_sccp_user for '0'\n .osmo_sccp_instance\n .osmo_ss7_user SSN: RANAP"]; ss0 -> sccp0 [dir=back] - msc0 [label="hnbgw_cnlink for IuCS\n .remote_addr -> 2.2.2"] + msc0 [label="hnbgw_cnlink 'msc0'\n .domain = IuCS\n .sccp_addr -> 2.2.2"] sccp0 -> msc0 [dir=back] msc0a -> msc0 [dir=back] @@ -23,26 +25,39 @@ cs1 [label="UE CS conn\n hnbgw_context_map"] msc0 -> cs0,cs1 + sgsn0 [label="hnbgw_cnlink 'sgsn0'\n .domain = IuPS\n .sccp_addr -> 3.3.3"] + sccp0 -> sgsn0 [dir=back] + sgsn0a -> sgsn0 [dir=back] + + ps0 [label="UE PS conn\n hnbgw_context_map"] + sgsn0 -> ps0 + subgraph cluster_ss1 { label="" ss1 [label="cs7 instance 1\n local pc: 4.4.4"] ss1ab [label="address book"] ss1 -> ss1ab - sgsn0a [label="3.3.3"] - ss1ab -> sgsn0a + sgsn1a [label="6.6.6"] + ss1ab -> sgsn1a } - sccp1 [label="hnbgw_sccp_user for '1'\n .osmo_ss7_instance 1\n .osmo_sccp_user SSN: RANAP\n PC: ss7 primary = 4.4.4"]; + sccp1 [label="hnbgw_sccp_user for '1'\n .osmo_sccp_instance\n .osmo_ss7_user SSN: RANAP"]; ss1 -> sccp1 [dir=back] - sgsn0 [label="hnbgw_cnlink for IuPS\n .remote_addr -> 3.3.3"] - sccp1 -> sgsn0 [dir=back] - sgsn0a -> sgsn0 [dir=back] + msc1 [label="hnbgw_cnlink 'msc1'\n .domain = IuCS\n .sccp_addr -> 5.5.5"] + sccp0 -> msc1 [dir=back] + msc1a -> msc1 [dir=back] - ps0 [label="UE PS conn\n hnbgw_context_map"] - ps1 [label="UE PS conn\n hnbgw_context_map"] - sgsn0 -> ps0,ps1 + cs2 [label="UE CS conn\n hnbgw_context_map"] + msc1 -> cs2 + + sgsn1 [label="hnbgw_cnlink 'sgsn1'\n .domain = IuPS\n .sccp_addr -> 6.6.6"] + sccp1 -> sgsn1 [dir=back] + sgsn1a -> sgsn1 [dir=back] + + ps2 [label="UE PS conn\n hnbgw_context_map"] + sgsn1 -> ps2 subgraph cluster_sccp_inst { label="global sccp.users (llist)" @@ -50,9 +65,14 @@ sccp1 } - subgraph cluster_hnbgw { - label="global hnbgw" + subgraph cluster_cnpool_iucs { + label="global cnpool_iucs" msc0 + msc1 + } + subgraph cluster_cnpool_iups { + label="global cnpool_iups" sgsn0 + sgsn1 } } diff --git a/include/osmocom/hnbgw/hnbgw.h b/include/osmocom/hnbgw/hnbgw.h index 7e6bda7..14552fb 100644 --- a/include/osmocom/hnbgw/hnbgw.h +++ b/include/osmocom/hnbgw/hnbgw.h @@ -71,6 +71,8 @@ uint32_t cid; /*!< Cell ID */ }; +struct hnbgw_context_map; + /* osmo-hnbgw keeps a single hnbgw_sccp_user per osmo_sccp_instance, for the local point-code and SSN == RANAP. * This relates the (opaque) osmo_sccp_user to osmo-hnbgw's per-ss7 state. */ struct hnbgw_sccp_user { @@ -97,19 +99,62 @@ #define LOG_HSI(HNBGW_SCCP_INST, SUBSYS, LEVEL, FMT, ARGS...) \ LOGP(SUBSYS, LEVEL, "(%s) " FMT, (HNBGW_SCCP_INST) ? (HNBGW_SCCP_INST)->name : "null", ##ARGS) -/* A CN peer, like MSC or SGSN. */ +/* 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. + */ +}; + +/* User provided configuration for struct hnbgw_cnlink. */ +struct hnbgw_cnlink_cfg { + /* cs7 address book entry to indicate both the remote point-code of the peer, as well as which cs7 instance to + * use. */ + char *remote_addr_name; + + /* FUTURE: This will be added here shortly: + * - per peer NRI config: NRI ranges assigned to this peer. + */ +}; + +/* Collection of CN peers to distribute UE connections across. MSCs for DOMAIN_CS, SGSNs for DOMAIN_PS. */ +struct hnbgw_cnpool { + RANAP_CN_DomainIndicator_t domain; + + /* CN pool string used in VTY config and logging, "iucs" or "iups". */ + const char *pool_name; + /* CN peer string used in VTY config and logging, "msc" or "sgsn". */ + const char *peer_name; + /* What we use as the remote MSC/SGSN point-code if the user does not configure any address. */ + uint32_t default_remote_pc; + + struct hnbgw_cnpool_cfg vty; + struct hnbgw_cnpool_cfg use; + + /* List of struct hnbgw_cnlink */ + struct llist_head cnlinks; + + /* FUTURE: This will be added here shortly: + * - round robin state for new conns + */ +}; + +/* A CN peer, like 'msc 0' or 'sgsn 23' */ struct hnbgw_cnlink { + struct llist_head entry; + + /* backpointer to CS or PS CN pool. */ + struct hnbgw_cnpool *pool; + + int nr; + + struct hnbgw_cnlink_cfg vty; + struct hnbgw_cnlink_cfg use; + /* To print in logging/VTY */ char *name; - /* IuCS or IuPS? */ - RANAP_CN_DomainIndicator_t domain; - - /* cs7 address book entry to indicate both the remote point-code of the peer, as well as which cs7 instance to - * use. */ - const char *remote_addr_name; - - /* Copy of the address pointed at by remote_addr_name. */ + /* Copy of the address book entry use.remote_addr_name. */ struct osmo_sccp_addr remote_addr; /* The SCCP instance for the cs7 instance indicated by remote_addr_name. (Multiple hnbgw_cnlinks may use the @@ -123,14 +168,16 @@ #define LOG_CNLINK(CNLINK, SUBSYS, LEVEL, FMT, ARGS...) \ LOGP(SUBSYS, LEVEL, "(%s) " FMT, (CNLINK) ? (CNLINK)->name : "null", ##ARGS) +struct hnbgw_cnlink *cnlink_get_nr(struct hnbgw_cnpool *cnpool, int nr, bool create_if_missing); + static inline bool cnlink_is_cs(const struct hnbgw_cnlink *cnlink) { - return cnlink && cnlink->domain == DOMAIN_CS; + return cnlink && cnlink->pool->domain == DOMAIN_CS; } static inline bool cnlink_is_ps(const struct hnbgw_cnlink *cnlink) { - return cnlink && cnlink->domain == DOMAIN_PS; + return cnlink && cnlink->pool->domain == DOMAIN_PS; } static inline struct osmo_sccp_instance *cnlink_sccp(const struct hnbgw_cnlink *cnlink) @@ -186,8 +233,6 @@ /*! The UDP port where we receive multiplexed CS user * plane traffic from HNBs */ uint16_t iuh_cs_mux_port; - const char *iucs_remote_addr_name; - const char *iups_remote_addr_name; uint16_t rnc_id; bool hnbap_allow_tmsi; /*! print hnb-id (true) or MCC-MNC-LAC-RAC-SAC (false) in logs */ @@ -213,9 +258,11 @@ struct { /* List of hnbgw_sccp_user */ struct llist_head users; - /* FUTURE: cnlink_iucs, cnlink_iups will be replaced with llist cnpool. */ - struct hnbgw_cnlink *cnlink_iucs; - struct hnbgw_cnlink *cnlink_iups; + + /* Pool of core network peers: MSCs for IuCS */ + struct hnbgw_cnpool cnpool_iucs; + /* Pool of core network peers: SGSNs for IuPS */ + struct hnbgw_cnpool cnpool_iups; } sccp; /* MGW pool, also includes the single MGCP client as fallback if no * pool is configured. */ diff --git a/include/osmocom/hnbgw/hnbgw_cn.h b/include/osmocom/hnbgw/hnbgw_cn.h index a684c98..79d3c27 100644 --- a/include/osmocom/hnbgw/hnbgw_cn.h +++ b/include/osmocom/hnbgw/hnbgw_cn.h @@ -2,12 +2,14 @@ #include <osmocom/hnbgw/hnbgw.h> -struct hnbgw_cnlink *hnbgw_cnlink_alloc(const char *remote_addr_name, RANAP_CN_DomainIndicator_t domain); - -const struct osmo_sccp_addr *hnbgw_cn_get_remote_addr(bool is_ps); - struct hnbgw_cnlink *hnbgw_cnlink_find_by_addr(const struct hnbgw_sccp_user *hsu, const struct osmo_sccp_addr *remote_addr); -struct hnbgw_cnlink *hnbgw_cnlink_select(bool is_ps); +struct hnbgw_cnlink *hnbgw_cnlink_select(struct hnbgw_context_map *map); + +void hnbgw_cnpool_start(struct hnbgw_cnpool *cnpool); +void hnbgw_cnpool_apply_cfg(struct hnbgw_cnpool *cnpool); +void hnbgw_cnpool_cnlinks_start_or_restart(struct hnbgw_cnpool *cnpool); +int hnbgw_cnlink_start_or_restart(struct hnbgw_cnlink *cnlink); char *cnlink_sccp_addr_to_str(struct hnbgw_cnlink *cnlink, const struct osmo_sccp_addr *addr); + diff --git a/include/osmocom/hnbgw/vty.h b/include/osmocom/hnbgw/vty.h index cf4a1eb..da0c469 100644 --- a/include/osmocom/hnbgw/vty.h +++ b/include/osmocom/hnbgw/vty.h @@ -10,5 +10,7 @@ MGCP_NODE, MGW_NODE, PFCP_NODE, + MSC_NODE, + SGSN_NODE, }; diff --git a/src/osmo-hnbgw/context_map_sccp.c b/src/osmo-hnbgw/context_map_sccp.c index cc65b6e..0e3d2b0 100644 --- a/src/osmo-hnbgw/context_map_sccp.c +++ b/src/osmo-hnbgw/context_map_sccp.c @@ -137,7 +137,7 @@ prim = (struct osmo_scu_prim *)msgb_push(ranap_msg, sizeof(*prim)); osmo_prim_init(&prim->oph, SCCP_SAP_USER, OSMO_SCU_PRIM_N_CONNECT, PRIM_OP_REQUEST, ranap_msg); - prim->u.connect.called_addr = *hnbgw_cn_get_remote_addr(map->is_ps); + prim->u.connect.called_addr = map->cnlink->remote_addr; prim->u.connect.calling_addr = map->cnlink->hnbgw_sccp_user->local_addr; prim->u.connect.sccp_class = 2; prim->u.connect.conn_id = map->scu_conn_id; diff --git a/src/osmo-hnbgw/hnbgw.c b/src/osmo-hnbgw/hnbgw.c index b07dbc7..205c683 100644 --- a/src/osmo-hnbgw/hnbgw.c +++ b/src/osmo-hnbgw/hnbgw.c @@ -60,6 +60,32 @@ #if ENABLE_PFCP g_hnbgw->config.pfcp.remote_port = OSMO_PFCP_PORT; #endif + + g_hnbgw->sccp.cnpool_iucs = (struct hnbgw_cnpool){ + .domain = DOMAIN_CS, + .pool_name = "iucs", + .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. + */ + }, + }; + INIT_LLIST_HEAD(&g_hnbgw->sccp.cnpool_iucs.cnlinks); + + g_hnbgw->sccp.cnpool_iups = (struct hnbgw_cnpool){ + .domain = DOMAIN_PS, + .pool_name = "iups", + .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. + */ + }, + }; + INIT_LLIST_HEAD(&g_hnbgw->sccp.cnpool_iups.cnlinks); } static struct hnb_context *hnb_context_by_id(uint32_t cid) diff --git a/src/osmo-hnbgw/hnbgw_cn.c b/src/osmo-hnbgw/hnbgw_cn.c index 0175498..d829718 100644 --- a/src/osmo-hnbgw/hnbgw_cn.c +++ b/src/osmo-hnbgw/hnbgw_cn.c @@ -60,7 +60,7 @@ cnlink_is_cs(cnlink) ? "IuCS" : "IuPS", osmo_sccp_inst_addr_name(cnlink->hnbgw_sccp_user->sccp, &cnlink->remote_addr)); - msg = ranap_new_msg_reset(cnlink->domain, &cause); + msg = ranap_new_msg_reset(cnlink->pool->domain, &cause); return osmo_sccp_tx_unitdata_msg(cnlink->hnbgw_sccp_user->sccp_user, &cnlink->local_addr, @@ -84,7 +84,7 @@ cnlink_sccp_addr_to_str(cnlink, &cnlink->hnbgw_sccp_user->local_addr), cnlink_sccp_addr_to_str(cnlink, &cnlink->remote_addr)); - msg = ranap_new_msg_reset_ack(cnlink->domain, NULL); + msg = ranap_new_msg_reset_ack(cnlink->pool->domain, NULL); return osmo_sccp_tx_unitdata_msg(cnlink->hnbgw_sccp_user->sccp_user, &cnlink->hnbgw_sccp_user->local_addr, @@ -422,35 +422,83 @@ { if (!addr_name) { osmo_sccp_make_addr_pc_ssn(dest, default_pc, OSMO_SCCP_SSN_RANAP); - LOGP(DMAIN, LOGL_INFO, "%s remote addr not configured, using default: %s\n", label, - osmo_sccp_addr_name(*ss7, dest)); + if (label) + LOGP(DMAIN, LOGL_INFO, "%s remote addr not configured, using default: %s\n", label, + osmo_sccp_addr_name(*ss7, dest)); return 0; } *ss7 = osmo_sccp_addr_by_name(dest, addr_name); if (!*ss7) { - LOGP(DMAIN, LOGL_ERROR, "%s remote addr: no such SCCP address book entry: '%s'\n", - label, addr_name); + if (label) + LOGP(DMAIN, LOGL_ERROR, "%s remote addr: no such SCCP address book entry: '%s'\n", + label, addr_name); return -1; } osmo_sccp_addr_set_ssn(dest, OSMO_SCCP_SSN_RANAP); if (!addr_has_pc_and_ssn(dest)) { - LOGP(DMAIN, LOGL_ERROR, "Invalid/incomplete %s remote-addr: %s\n", - label, osmo_sccp_addr_name(*ss7, dest)); + if (label) + LOGP(DMAIN, LOGL_ERROR, "Invalid/incomplete %s remote-addr: %s\n", + label, osmo_sccp_addr_name(*ss7, dest)); return -1; } - LOGP(DRANAP, LOGL_NOTICE, "Remote %s SCCP addr: %s\n", - label, osmo_sccp_addr_name(*ss7, dest)); + if (label) + LOGP(DRANAP, LOGL_NOTICE, "Remote %s SCCP addr: %s\n", + label, osmo_sccp_addr_name(*ss7, dest)); return 0; } +void hnbgw_cnpool_apply_cfg(struct hnbgw_cnpool *cnpool) +{ + cnpool->use = cnpool->vty; +} + +static void hnbgw_cnlink_cfg_copy(struct hnbgw_cnlink *cnlink) +{ + osmo_talloc_replace_string(cnlink, &cnlink->use.remote_addr_name, cnlink->vty.remote_addr_name); +} + +static bool hnbgw_cnlink_sccp_cfg_changed(struct hnbgw_cnlink *cnlink) +{ + bool changed = false; + + if (cnlink->vty.remote_addr_name && cnlink->use.remote_addr_name) { + struct osmo_ss7_instance *ss7; + struct osmo_sccp_addr remote_addr = {}; + + /* Instead of comparing whether the address book entry names are different, actually resolve the + * resulting SCCP address, and only restart the cnlink if the resulting address changed. */ + resolve_addr_name(&remote_addr, &ss7, cnlink->vty.remote_addr_name, NULL, DEFAULT_PC_HNBGW); + if (osmo_sccp_addr_cmp(&remote_addr, &cnlink->remote_addr, OSMO_SCCP_ADDR_T_PC | OSMO_SCCP_ADDR_T_SSN)) + changed = true; + } else if (cnlink->vty.remote_addr_name != cnlink->use.remote_addr_name) { + /* One of them is NULL, the other is not. */ + changed = true; + } + + /* if more cnlink configuration is added in the future, it needs to be compared here. */ + + return changed; +} + +static void hnbgw_cnlink_drop_sccp(struct hnbgw_cnlink *cnlink) +{ + struct hnbgw_context_map *map, *map2; + + llist_for_each_entry_safe(map, map2, &cnlink->map_list, hnbgw_cnlink_entry) { + map_sccp_dispatch(map, MAP_SCCP_EV_USER_ABORT, NULL); + } + + cnlink->hnbgw_sccp_user = NULL; +} + /* If not present yet, set up all of osmo_ss7_instance, osmo_sccp_instance and hnbgw_sccp_user for the given cnlink. * The cs7 instance nr to use is determined by cnlink->remote_addr_name, or cs7 instance 0 if that is not present. * Set cnlink->hnbgw_sccp_user to the new SCCP instance. Return 0 on success, negative on error. */ -int cnlink_ensure_sccp(struct hnbgw_cnlink *cnlink) +int hnbgw_cnlink_start_or_restart(struct hnbgw_cnlink *cnlink) { struct osmo_ss7_instance *ss7 = NULL; struct osmo_sccp_instance *sccp; @@ -460,39 +508,36 @@ /* If a hnbgw_sccp_user has already been set up, use that. */ if (cnlink->hnbgw_sccp_user) { - LOG_CNLINK(cnlink, DCN, LOGL_DEBUG, "SCCP instance already set up, using %s\n", - cnlink->hnbgw_sccp_user->name); - return 0; + if (hnbgw_cnlink_sccp_cfg_changed(cnlink)) { + LOG_CNLINK(cnlink, DCN, LOGL_NOTICE, "config changed, restarting SCCP\n"); + hnbgw_cnlink_drop_sccp(cnlink); + } else { + LOG_CNLINK(cnlink, DCN, LOGL_DEBUG, "SCCP instance already set up, using %s\n", + cnlink->hnbgw_sccp_user->name); + return 0; + } + } else { + LOG_CNLINK(cnlink, DCN, LOGL_DEBUG, "no SCCP instance selected yet\n"); } - LOG_CNLINK(cnlink, DCN, LOGL_DEBUG, "no SCCP instance selected yet\n"); + + /* Copy the current configuration: cnlink->use = cnlink->vty */ + hnbgw_cnlink_cfg_copy(cnlink); /* Figure out which cs7 instance to use. If cnlink->remote_addr_name is set, it points to an address book entry * in a specific cs7 instance. If it is not set, leave ss7 == NULL to use cs7 instance 0. */ - if (cnlink->remote_addr_name) { - LOG_CNLINK(cnlink, DCN, LOGL_DEBUG, "resolving 'remote-addr %s'\n", cnlink->remote_addr_name); - if (resolve_addr_name(&cnlink->remote_addr, &ss7, cnlink->remote_addr_name, cnlink->name, + if (cnlink->use.remote_addr_name) { + if (resolve_addr_name(&cnlink->remote_addr, &ss7, cnlink->use.remote_addr_name, cnlink->name, DEFAULT_PC_HNBGW)) { LOG_CNLINK(cnlink, DCN, LOGL_ERROR, "cannot initialize SCCP: there is no SCCP address named '%s'\n", - cnlink->remote_addr_name); + cnlink->use.remote_addr_name); return -ENOENT; } LOG_CNLINK(cnlink, DCN, LOGL_DEBUG, "remote-addr is '%s', using cs7 instance %u\n", - cnlink->remote_addr_name, ss7->cfg.id); + cnlink->use.remote_addr_name, ss7->cfg.id); } else { /* If no address is configured, use the default remote CN address, according to legacy behavior. */ - uint32_t remote_pc; - switch (cnlink->domain) { - case DOMAIN_CS: - remote_pc = DEFAULT_PC_MSC; - break; - case DOMAIN_PS: - remote_pc = DEFAULT_PC_SGSN; - break; - default: - return -EINVAL; - } - osmo_sccp_make_addr_pc_ssn(&cnlink->remote_addr, remote_pc, OSMO_SCCP_SSN_RANAP); + osmo_sccp_make_addr_pc_ssn(&cnlink->remote_addr, cnlink->pool->default_remote_pc, OSMO_SCCP_SSN_RANAP); } /* If no 'cs7 instance' has been selected by the address, see if there already is a cs7 0 we can use by default. @@ -563,47 +608,54 @@ return 0; } -struct hnbgw_cnlink *hnbgw_cnlink_alloc(const char *remote_addr_name, RANAP_CN_DomainIndicator_t domain) +void hnbgw_cnpool_cnlinks_start_or_restart(struct hnbgw_cnpool *cnpool) { struct hnbgw_cnlink *cnlink; + hnbgw_cnpool_apply_cfg(cnpool); + llist_for_each_entry(cnlink, &cnpool->cnlinks, entry) { + hnbgw_cnlink_start_or_restart(cnlink); + } +} +void hnbgw_cnpool_start(struct hnbgw_cnpool *cnpool) +{ + /* Legacy compat: when there is no 'msc N' at all in the config file, set up 'msc 0' with default values (or + * 'sgsn' depending on cnpool). */ + if (llist_empty(&cnpool->cnlinks)) + cnlink_get_nr(cnpool, 0, true); + hnbgw_cnpool_cnlinks_start_or_restart(cnpool); +} + +static struct hnbgw_cnlink *cnlink_alloc(struct hnbgw_cnpool *cnpool, int nr) +{ + struct hnbgw_cnlink *cnlink; cnlink = talloc_zero(g_hnbgw, struct hnbgw_cnlink); *cnlink = (struct hnbgw_cnlink){ - .name = (domain == DOMAIN_CS ? "msc-0" : "sgsn-0"), - .domain = domain, - .remote_addr_name = talloc_strdup(cnlink, remote_addr_name), + .name = talloc_asprintf(cnlink, "%s-%d", cnpool->peer_name, nr), + .pool = cnpool, + .nr = nr, + .vty = { + /* VTY config defaults for the new cnlink */ + }, }; - INIT_LLIST_HEAD(&cnlink->map_list); - if (cnlink_ensure_sccp(cnlink)) { - /* error logging already in cnlink_ensure_sccp() */ - talloc_free(cnlink); - return NULL; - } - - switch (domain) { - case DOMAIN_CS: - OSMO_ASSERT(!g_hnbgw->sccp.cnlink_iucs); - g_hnbgw->sccp.cnlink_iucs = cnlink; - break; - case DOMAIN_PS: - OSMO_ASSERT(!g_hnbgw->sccp.cnlink_iups); - g_hnbgw->sccp.cnlink_iups = cnlink; - break; - default: - OSMO_ASSERT(false); - } - + llist_add_tail(&cnlink->entry, &cnpool->cnlinks); return cnlink; } -const struct osmo_sccp_addr *hnbgw_cn_get_remote_addr(bool is_ps) +struct hnbgw_cnlink *cnlink_get_nr(struct hnbgw_cnpool *cnpool, int nr, bool create_if_missing) { - struct hnbgw_cnlink *cnlink = is_ps ? g_hnbgw->sccp.cnlink_iups : g_hnbgw->sccp.cnlink_iucs; - if (!cnlink) + struct hnbgw_cnlink *cnlink; + llist_for_each_entry(cnlink, &cnpool->cnlinks, entry) { + if (cnlink->nr == nr) + return cnlink; + } + + if (!create_if_missing) return NULL; - return &cnlink->remote_addr; + + return cnlink_alloc(cnpool, nr); } static bool cnlink_matches(const struct hnbgw_cnlink *cnlink, const struct hnbgw_sccp_user *hsu, const struct osmo_sccp_addr *remote_addr) @@ -614,24 +666,37 @@ return false; return true; } + struct hnbgw_cnlink *hnbgw_cnlink_find_by_addr(const struct hnbgw_sccp_user *hsu, const struct osmo_sccp_addr *remote_addr) { - /* FUTURE: loop over llist g_hnb_gw->sccp.cnpool */ - if (cnlink_matches(g_hnbgw->sccp.cnlink_iucs, hsu, remote_addr)) - return g_hnbgw->sccp.cnlink_iucs; - if (cnlink_matches(g_hnbgw->sccp.cnlink_iups, hsu, remote_addr)) - return g_hnbgw->sccp.cnlink_iups; + struct hnbgw_cnlink *cnlink; + llist_for_each_entry(cnlink, &g_hnbgw->sccp.cnpool_iucs.cnlinks, entry) { + if (cnlink_matches(cnlink, hsu, remote_addr)) + return cnlink; + } + llist_for_each_entry(cnlink, &g_hnbgw->sccp.cnpool_iups.cnlinks, entry) { + if (cnlink_matches(cnlink, hsu, remote_addr)) + return cnlink; + } return NULL; } -struct hnbgw_cnlink *hnbgw_cnlink_select(bool is_ps) +struct hnbgw_cnlink *hnbgw_cnlink_select(struct hnbgw_context_map *map) { + struct hnbgw_cnpool *cnpool = map->is_ps ? &g_hnbgw->sccp.cnpool_iups : &g_hnbgw->sccp.cnpool_iucs; + struct hnbgw_cnlink *cnlink; /* FUTURE: soon we will pick one of many configurable CN peers from a pool. There will be more input arguments * (MI, or TMSI, or NRI decoded from RANAP) and this function will do round robin for new subscribers. */ - if (is_ps) - return g_hnbgw->sccp.cnlink_iups; - return g_hnbgw->sccp.cnlink_iucs; + llist_for_each_entry(cnlink, &cnpool->cnlinks, entry) { + if (!cnlink->hnbgw_sccp_user || !cnlink->hnbgw_sccp_user->sccp_user) + continue; + LOG_MAP(map, DCN, LOGL_INFO, "Selected %s / %s\n", + cnlink->name, + cnlink->hnbgw_sccp_user->name); + return cnlink; + } + return NULL; } char *cnlink_sccp_addr_to_str(struct hnbgw_cnlink *cnlink, const struct osmo_sccp_addr *addr) diff --git a/src/osmo-hnbgw/hnbgw_vty.c b/src/osmo-hnbgw/hnbgw_vty.c index c1ff268..d4d1bad 100644 --- a/src/osmo-hnbgw/hnbgw_vty.c +++ b/src/osmo-hnbgw/hnbgw_vty.c @@ -74,6 +74,7 @@ "iucs", "Configure IuCS options") { vty->node = IUCS_NODE; + vty->index = &g_hnbgw->sccp.cnpool_iucs; return CMD_SUCCESS; } @@ -87,6 +88,7 @@ "iups", "Configure IuPS options") { vty->node = IUPS_NODE; + vty->index = &g_hnbgw->sccp.cnpool_iups; return CMD_SUCCESS; } @@ -138,8 +140,8 @@ vty_out(vty, "%s <->", osmo_sccp_user_name(cnlink->hnbgw_sccp_user->sccp_user)); vty_out(vty, " %s%s%s%s", - cnlink->remote_addr_name ? : "", - cnlink->remote_addr_name ? "=" : "", + cnlink->use.remote_addr_name ? : "", + cnlink->use.remote_addr_name ? "=" : "", cnlink_sccp_addr_to_str(cnlink, &cnlink->remote_addr), VTY_NEWLINE); @@ -150,10 +152,13 @@ DEFUN(show_cnlink, show_cnlink_cmd, "show cnlink", SHOW_STR "Display information on core network link\n") { + struct hnbgw_cnlink *cnlink; vty_out(vty, "IuCS: "); - _show_cnlink(vty, g_hnbgw->sccp.cnlink_iucs); + llist_for_each_entry(cnlink, &g_hnbgw->sccp.cnpool_iucs.cnlinks, entry) + _show_cnlink(vty, cnlink); vty_out(vty, "IuPS: "); - _show_cnlink(vty, g_hnbgw->sccp.cnlink_iups); + llist_for_each_entry(cnlink, &g_hnbgw->sccp.cnpool_iups.cnlinks, entry) + _show_cnlink(vty, cnlink); return CMD_SUCCESS; } @@ -341,23 +346,130 @@ return CMD_WARNING; } -DEFUN(cfg_hnbgw_iucs_remote_addr, - cfg_hnbgw_iucs_remote_addr_cmd, - "remote-addr NAME", - "SCCP address to send IuCS to (MSC)\n" - "SCCP address book entry name (see 'cs7-instance')\n") +/* 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, + cfg_hnbgw_cnpool_remote_addr_cmd, + "remote-addr NAME", + "Deprecated command: same as '{msc,sgsn} 0' / 'remote-addr NAME'\n-\n") { - g_hnbgw->config.iucs_remote_addr_name = talloc_strdup(g_hnbgw, argv[0]); + const char *logmsg; + struct hnbgw_cnpool *cnpool = vty->index; + struct hnbgw_cnlink *cnlink = cnlink_get_nr(cnpool, 0, true); + OSMO_ASSERT(cnlink); + cnlink->vty.remote_addr_name = talloc_strdup(cnlink, argv[0]); + + logmsg = talloc_asprintf(OTC_SELECT, + "Deprecated: instead of hnbgw/%s/remote-addr," + " use '%s 0'/remote-addr", + cnpool->pool_name, + cnpool->peer_name); + vty_out(vty, "%% %s%s", logmsg, VTY_NEWLINE); + LOGP(DLGLOBAL, LOGL_ERROR, "config: %s\n", logmsg); return CMD_SUCCESS; } -DEFUN(cfg_hnbgw_iups_remote_addr, - cfg_hnbgw_iups_remote_addr_cmd, - "remote-addr NAME", - "SCCP address to send IuPS to (SGSN)\n" - "SCCP address book entry name (see 'cs7-instance')\n") +#define CNLINK_NR_RANGE "<0-1000>" + +static struct cmd_node msc_node = { + MSC_NODE, + "%s(config-msc)# ", + 1, +}; + +static struct cmd_node sgsn_node = { + SGSN_NODE, + "%s(config-sgsn)# ", + 1, +}; + +/* Commands that are common for 'msc 0' and 'sgsn 0' */ + +static int cnlink_nr(struct vty *vty, struct hnbgw_cnpool *cnpool, int argc, const char **argv) { - g_hnbgw->config.iups_remote_addr_name = talloc_strdup(g_hnbgw, argv[0]); + int nr = atoi(argv[0]); + struct hnbgw_cnlink *cnlink = cnlink_get_nr(cnpool, nr, true); + OSMO_ASSERT(cnlink); + switch (cnpool->domain) { + case DOMAIN_CS: + vty->node = MSC_NODE; + break; + case DOMAIN_PS: + vty->node = SGSN_NODE; + break; + default: + OSMO_ASSERT(false); + } + vty->index = cnlink; + return CMD_SUCCESS; +} + +/* 'msc 0' */ +DEFUN(cfg_msc_nr, cfg_msc_nr_cmd, + "msc " CNLINK_NR_RANGE, + "Configure an IuCS link to an MSC\n" + "MSC nr\n") +{ + return cnlink_nr(vty, &g_hnbgw->sccp.cnpool_iucs, argc, argv); +} + +/* 'sgsn 0' */ +DEFUN(cfg_sgsn_nr, cfg_sgsn_nr_cmd, + "sgsn " CNLINK_NR_RANGE, + "Configure an IuPS link to an SGSN\n" + "SGSN nr\n") +{ + return cnlink_nr(vty, &g_hnbgw->sccp.cnpool_iups, argc, argv); +} + +/* 'msc 0' / 'remote-addr my-msc' and + * 'sgsn 0' / 'remote-addr my-sgsn' + */ +DEFUN(cfg_cnlink_remote_addr, + cfg_cnlink_remote_addr_cmd, + "remote-addr NAME", + "SCCP address to send RANAP/SCCP to\n" + "SCCP address book entry name (see 'cs7 instance' / 'sccp-address')\n") +{ + struct hnbgw_cnlink *cnlink = vty->index; + cnlink->vty.remote_addr_name = talloc_strdup(cnlink, argv[0]); + 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." +#define IMPLICIT_ON_STARTUP_STR \ + " This is run implicitly on program startup, only useful to apply changes made later via telnet VTY." + +DEFUN(cfg_cnlink_apply_sccp, cfg_cnlink_apply_sccp_cmd, + "apply sccp", + APPLY_STR + "For telnet VTY: apply SCCP and NRI config changes made to this CN link in the running osmo-hnbgw process." + SCCP_RESTART_STR IMPLICIT_ON_STARTUP_STR "\n") +{ + struct hnbgw_cnlink *cnlink = vty->index; + hnbgw_cnlink_start_or_restart(cnlink); + return CMD_SUCCESS; +} + +DEFUN(cfg_config_apply_sccp, cfg_config_apply_sccp_cmd, + "apply sccp", + APPLY_STR + "For telnet VTY: apply all SCCP and NRI config changes made to any CN pools and CN links in the running" + " osmo-hnbgw process." + SCCP_RESTART_STR IMPLICIT_ON_STARTUP_STR "\n") +{ + struct hnbgw_cnpool *cnpool; + + cnpool = &g_hnbgw->sccp.cnpool_iucs; + hnbgw_cnpool_apply_cfg(cnpool); + hnbgw_cnpool_cnlinks_start_or_restart(cnpool); + + cnpool = &g_hnbgw->sccp.cnpool_iups; + hnbgw_cnpool_apply_cfg(cnpool); + hnbgw_cnpool_cnlinks_start_or_restart(cnpool); + return CMD_SUCCESS; } @@ -440,27 +552,31 @@ return CMD_SUCCESS; } -static int config_write_hnbgw_iucs(struct vty *vty) +/* hnbgw + * msc 0 } this part + * sgsn 0 } + */ +static void _config_write_cnlink(struct vty *vty, struct hnbgw_cnpool *cnpool) { - if (!g_hnbgw->config.iucs_remote_addr_name) - return CMD_SUCCESS; + struct hnbgw_cnlink *cnlink; - vty_out(vty, " iucs%s", VTY_NEWLINE); - vty_out(vty, " remote-addr %s%s", g_hnbgw->config.iucs_remote_addr_name, - VTY_NEWLINE); + llist_for_each_entry(cnlink, &cnpool->cnlinks, entry) { + 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 */ + } +} +static int config_write_msc(struct vty *vty) +{ + _config_write_cnlink(vty, &g_hnbgw->sccp.cnpool_iucs); return CMD_SUCCESS; } -static int config_write_hnbgw_iups(struct vty *vty) +static int config_write_sgsn(struct vty *vty) { - if (!g_hnbgw->config.iups_remote_addr_name) - return CMD_SUCCESS; - - vty_out(vty, " iups%s", VTY_NEWLINE); - vty_out(vty, " remote-addr %s%s", g_hnbgw->config.iups_remote_addr_name, - VTY_NEWLINE); - + _config_write_cnlink(vty, &g_hnbgw->sccp.cnpool_iups); return CMD_SUCCESS; } @@ -477,6 +593,12 @@ } #endif +static void install_cnlink_elements(int node) +{ + install_element(node, &cfg_cnlink_remote_addr_cmd); + install_element(node, &cfg_cnlink_apply_sccp_cmd); +} + void hnbgw_vty_init(void) { install_element(CONFIG_NODE, &cfg_hnbgw_cmd); @@ -494,14 +616,14 @@ install_element(IUH_NODE, &cfg_hnbgw_iuh_hnbap_allow_tmsi_cmd); install_element(HNBGW_NODE, &cfg_hnbgw_iucs_cmd); - install_node(&iucs_node, config_write_hnbgw_iucs); - - install_element(IUCS_NODE, &cfg_hnbgw_iucs_remote_addr_cmd); + install_node(&iucs_node, NULL); install_element(HNBGW_NODE, &cfg_hnbgw_iups_cmd); - install_node(&iups_node, config_write_hnbgw_iups); + install_node(&iups_node, NULL); - install_element(IUPS_NODE, &cfg_hnbgw_iups_remote_addr_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); + install_element(IUPS_NODE, &cfg_hnbgw_cnpool_remote_addr_cmd); install_element_ve(&show_cnlink_cmd); install_element_ve(&show_hnb_cmd); @@ -524,5 +646,16 @@ install_element(PFCP_NODE, &cfg_pfcp_remote_addr_cmd); #endif + install_element(CONFIG_NODE, &cfg_msc_nr_cmd); + install_node(&msc_node, config_write_msc); + install_cnlink_elements(MSC_NODE); + + install_element(CONFIG_NODE, &cfg_sgsn_nr_cmd); + install_node(&sgsn_node, config_write_sgsn); + install_cnlink_elements(SGSN_NODE); + + /* 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); } diff --git a/src/osmo-hnbgw/osmo_hnbgw_main.c b/src/osmo-hnbgw/osmo_hnbgw_main.c index 4994b1f..30f3de9 100644 --- a/src/osmo-hnbgw/osmo_hnbgw_main.c +++ b/src/osmo-hnbgw/osmo_hnbgw_main.c @@ -259,14 +259,6 @@ ranap_set_log_area(DRANAP); - if (!hnbgw_cnlink_alloc(g_hnbgw->config.iucs_remote_addr_name, DOMAIN_CS) - || !hnbgw_cnlink_alloc(g_hnbgw->config.iups_remote_addr_name, DOMAIN_PS)) { - LOGP(DMAIN, LOGL_ERROR, "Failed to initialize SCCP link to CN\n"); - exit(1); - } - OSMO_ASSERT(g_hnbgw->sccp.cnlink_iucs); - OSMO_ASSERT(g_hnbgw->sccp.cnlink_iups); - LOGP(DHNBAP, LOGL_NOTICE, "Using RNC-Id %u\n", g_hnbgw->config.rnc_id); OSMO_ASSERT(g_hnbgw->config.iuh_local_ip); @@ -300,6 +292,9 @@ hnbgw_pfcp_init(); #endif + hnbgw_cnpool_start(&g_hnbgw->sccp.cnpool_iucs); + hnbgw_cnpool_start(&g_hnbgw->sccp.cnpool_iups); + if (hnbgw_cmdline_config.daemonize) { rc = osmo_daemonize(); if (rc < 0) { diff --git a/tests/cnpool.vty b/tests/cnpool.vty new file mode 100644 index 0000000..6b57122 --- /dev/null +++ b/tests/cnpool.vty @@ -0,0 +1,194 @@ +OsmoHNBGW> enable +OsmoHNBGW# configure terminal + +OsmoHNBGW(config)# ### cnpool doc strings +OsmoHNBGW(config)# hnbgw +OsmoHNBGW(config-hnbgw)# list +... + iucs + iups +... +OsmoHNBGW(config-hnbgw)# iucs? + iucs Configure IuCS options +OsmoHNBGW(config-hnbgw)# iups? + iups Configure IuPS options + +OsmoHNBGW(config-hnbgw)# exit + +OsmoHNBGW(config)# msc? + msc Configure an IuCS link to an MSC +OsmoHNBGW(config)# msc ? + <0-1000> MSC nr + +OsmoHNBGW(config)# sgsn? + sgsn Configure an IuPS link to an SGSN +OsmoHNBGW(config)# sgsn ? + <0-1000> SGSN nr + +OsmoHNBGW(config)# ### The config file has no 'msc' or 'sgsn', so defaults have been set up +OsmoHNBGW(config)# show running-config +... +msc 0 +sgsn 0 +... + +OsmoHNBGW(config)# msc 1 + +OsmoHNBGW(config-msc)# list +... + remote-addr NAME + apply sccp +... + +OsmoHNBGW(config-msc)# remote-addr? + remote-addr SCCP address to send RANAP/SCCP to +OsmoHNBGW(config-msc)# remote-addr ? + NAME SCCP address book entry name (see 'cs7 instance' / 'sccp-address') + +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)# exit + +OsmoHNBGW(config)# sgsn 1 + +OsmoHNBGW(config-sgsn)# list +... + remote-addr NAME + apply sccp +... + +OsmoHNBGW(config-sgsn)# remote-addr? + remote-addr SCCP address to send RANAP/SCCP to +OsmoHNBGW(config-sgsn)# remote-addr ? + NAME SCCP address book entry name (see 'cs7 instance' / 'sccp-address') + +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)# exit + +OsmoHNBGW(config)# ### Just by entering the nodes above, 'msc 1' and 'sgsn 1' now exist +OsmoHNBGW(config)# show running-config +... +msc 0 +msc 1 +sgsn 0 +sgsn 1 +... + +OsmoHNBGW(config)# ### Add {msc,sgsn}x{2,3} + +OsmoHNBGW(config)# msc 2 +OsmoHNBGW(config-msc)# remote-addr addr-msc2 +OsmoHNBGW(config-msc)# exit + +OsmoHNBGW(config)# msc 3 +OsmoHNBGW(config-msc)# remote-addr addr-msc3 +OsmoHNBGW(config-msc)# exit + +OsmoHNBGW(config)# sgsn 2 +OsmoHNBGW(config-sgsn)# remote-addr addr-sgsn2 +OsmoHNBGW(config-sgsn)# exit + +OsmoHNBGW(config)# sgsn 3 +OsmoHNBGW(config-sgsn)# remote-addr addr-sgsn3 +OsmoHNBGW(config-sgsn)# exit + +OsmoHNBGW(config)# show running-config +... +msc 0 +msc 1 +msc 2 + remote-addr addr-msc2 +msc 3 + remote-addr addr-msc3 +sgsn 0 +sgsn 1 +sgsn 2 + remote-addr addr-sgsn2 +sgsn 3 + remote-addr addr-sgsn3 +... + +OsmoHNBGW(config)# ### Re-entering existing nodes works (does not create new ones) +OsmoHNBGW(config)# msc 3 +OsmoHNBGW(config-msc)# remote-addr addr-msc4 +OsmoHNBGW(config-msc)# exit +OsmoHNBGW(config)# sgsn 2 +OsmoHNBGW(config-sgsn)# remote-addr addr-sgsn4 +OsmoHNBGW(config-sgsn)# exit + +OsmoHNBGW(config)# show running-config +... +msc 0 +msc 1 +msc 2 + remote-addr addr-msc2 +msc 3 + remote-addr addr-msc4 +sgsn 0 +sgsn 1 +sgsn 2 + remote-addr addr-sgsn4 +sgsn 3 + remote-addr addr-sgsn3 +... + +OsmoHNBGW(config)# ### Legacy configuration {'iups','iucs'} / 'remote-addr' redirects to {'msc 0','sgsn 0'}: + +OsmoHNBGW(config)# hnbgw +OsmoHNBGW(config-hnbgw)# iucs +OsmoHNBGW(config-hnbgw-iucs)# remote-addr? +% There is no matched command. +OsmoHNBGW(config-hnbgw-iucs)# remote-addr ? +% There is no matched command. +OsmoHNBGW(config-hnbgw-iucs)# remote-addr addr-msc0 +% Deprecated: instead of hnbgw/iucs/remote-addr, use 'msc 0'/remote-addr +OsmoHNBGW(config-hnbgw-iucs)# exit + +OsmoHNBGW(config-hnbgw)# iups +OsmoHNBGW(config-hnbgw-iups)# remote-addr? +% There is no matched command. +OsmoHNBGW(config-hnbgw-iups)# remote-addr ? +% There is no matched command. +OsmoHNBGW(config-hnbgw-iups)# remote-addr addr-sgsn0 +% Deprecated: instead of hnbgw/iups/remote-addr, use 'sgsn 0'/remote-addr +OsmoHNBGW(config-hnbgw-iups)# exit + +OsmoHNBGW(config-hnbgw)# show running-config +... +hnbgw +... +msc 0 + remote-addr addr-msc0 +msc 1 +msc 2 + remote-addr addr-msc2 +msc 3 + remote-addr addr-msc4 +sgsn 0 + remote-addr addr-sgsn0 +sgsn 1 +sgsn 2 + remote-addr addr-sgsn4 +sgsn 3 + remote-addr addr-sgsn3 +... + + +OsmoHNBGW(config-hnbgw)# ### placement of the new 'msc' and 'sgsn' nodes must be below 'pfcp' and 'mgw' nodes +OsmoHNBGW(config-hnbgw)# show running-config +... +hnbgw +... !msc + iuh +... !msc + mgw 0 +... +msc 0 +... diff --git a/tests/config/one_cs7_with_addrs.vty b/tests/config/one_cs7_with_addrs.vty index 2975ade..4df44a5 100644 --- a/tests/config/one_cs7_with_addrs.vty +++ b/tests/config/one_cs7_with_addrs.vty @@ -39,8 +39,9 @@ rnc-id 23 log-prefix hnb-id iuh - iucs - remote-addr my-msc - iups - remote-addr my-sgsn +... +msc 0 + remote-addr my-msc +sgsn 0 + remote-addr my-sgsn ... diff --git a/tests/config/one_cs7_with_iucs_addr.vty b/tests/config/one_cs7_with_iucs_addr.vty index 7fc4ed1..f9ee384 100644 --- a/tests/config/one_cs7_with_iucs_addr.vty +++ b/tests/config/one_cs7_with_iucs_addr.vty @@ -32,6 +32,8 @@ rnc-id 23 log-prefix hnb-id iuh - iucs - remote-addr my-msc ... +msc 0 + remote-addr my-msc +sgsn 0 +... !remote-addr diff --git a/tests/config/one_cs7_with_iups_addr.vty b/tests/config/one_cs7_with_iups_addr.vty index bd5f261..7d66615 100644 --- a/tests/config/one_cs7_with_iups_addr.vty +++ b/tests/config/one_cs7_with_iups_addr.vty @@ -32,6 +32,8 @@ rnc-id 23 log-prefix hnb-id iuh - iups - remote-addr my-sgsn +... +msc 0 +sgsn 0 + remote-addr my-sgsn ... diff --git a/tests/config/two_cs7_with_addrs.vty b/tests/config/two_cs7_with_addrs.vty index 59240d1..0fb4b76 100644 --- a/tests/config/two_cs7_with_addrs.vty +++ b/tests/config/two_cs7_with_addrs.vty @@ -50,8 +50,9 @@ rnc-id 23 log-prefix hnb-id iuh - iucs - remote-addr my-msc - iups - remote-addr my-sgsn +... +msc 0 + remote-addr my-msc +sgsn 0 + remote-addr my-sgsn ... -- To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/32324 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hnbgw Gerrit-Branch: master Gerrit-Change-Id: I5479eded786ec26062d49403a8be12967f113cdb Gerrit-Change-Number: 32324 Gerrit-PatchSet: 5 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
1 0
0 0
[S] Change in osmo-hnbgw[master]: tdefs; combine timer groups 'ps' and 'cmap' to 'hnbgw'
by neels 05 Jun '23

05 Jun '23
neels has submitted this change. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/33131 ) Change subject: tdefs; combine timer groups 'ps' and 'cmap' to 'hnbgw' ...................................................................... tdefs; combine timer groups 'ps' and 'cmap' to 'hnbgw' Makes no sense to have groups with one member each. Soon I will add a new timer that matches neither 'cmap' nor 'ps', and I would have to open a third group with a single member. Add a shim that redirects 'ps' to 'hnbgw'. The group 'cmap' has not yet been released, so just drop that one without a shim. Change-Id: Ica6063fae4588b51897e5574d975b3185fa9ae80 --- M include/osmocom/hnbgw/tdefs.h M src/osmo-hnbgw/context_map_rua.c M src/osmo-hnbgw/context_map_sccp.c M src/osmo-hnbgw/hnbgw_vty.c M src/osmo-hnbgw/ps_rab_ass_fsm.c M src/osmo-hnbgw/ps_rab_fsm.c M src/osmo-hnbgw/tdefs.c 7 files changed, 35 insertions(+), 14 deletions(-) Approvals: pespin: Looks good to me, but someone else must approve Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/include/osmocom/hnbgw/tdefs.h b/include/osmocom/hnbgw/tdefs.h index 6fee79b..6a27e36 100644 --- a/include/osmocom/hnbgw/tdefs.h +++ b/include/osmocom/hnbgw/tdefs.h @@ -3,6 +3,5 @@ #include <osmocom/core/tdef.h> extern struct osmo_tdef mgw_fsm_T_defs[]; -extern struct osmo_tdef ps_T_defs[]; -extern struct osmo_tdef cmap_T_defs[]; +extern struct osmo_tdef hnbgw_T_defs[]; extern struct osmo_tdef_group hnbgw_tdef_group[]; diff --git a/src/osmo-hnbgw/context_map_rua.c b/src/osmo-hnbgw/context_map_rua.c index 9e8f028..9cb45b0 100644 --- a/src/osmo-hnbgw/context_map_rua.c +++ b/src/osmo-hnbgw/context_map_rua.c @@ -67,7 +67,7 @@ #define map_rua_fsm_state_chg(state) \ OSMO_ASSERT(osmo_tdef_fsm_inst_state_chg(fi, state, \ map_rua_fsm_timeouts, \ - cmap_T_defs, \ + hnbgw_T_defs, \ 5) == 0) void map_rua_fsm_alloc(struct hnbgw_context_map *map) diff --git a/src/osmo-hnbgw/context_map_sccp.c b/src/osmo-hnbgw/context_map_sccp.c index 0e3d2b0..3bdec8c 100644 --- a/src/osmo-hnbgw/context_map_sccp.c +++ b/src/osmo-hnbgw/context_map_sccp.c @@ -73,7 +73,7 @@ #define map_sccp_fsm_state_chg(state) \ OSMO_ASSERT(osmo_tdef_fsm_inst_state_chg(fi, state, \ map_sccp_fsm_timeouts, \ - cmap_T_defs, \ + hnbgw_T_defs, \ 5) == 0) void map_sccp_fsm_alloc(struct hnbgw_context_map *map) diff --git a/src/osmo-hnbgw/hnbgw_vty.c b/src/osmo-hnbgw/hnbgw_vty.c index 7c60611..462a4fc 100644 --- a/src/osmo-hnbgw/hnbgw_vty.c +++ b/src/osmo-hnbgw/hnbgw_vty.c @@ -792,6 +792,15 @@ #endif /* ENABLE_PFCP */ +DEFUN_DEPRECATED(cfg_hnbgw_timer_ps, cfg_hnbgw_timer_ps_cmd, + "timer ps " OSMO_TDEF_VTY_ARG_SET, + "Configure or show timers\n" + "Deprecated: 'ps' timers are now in 'hnbgw'\n" + OSMO_TDEF_VTY_DOC_SET) +{ + return osmo_tdef_vty_set_cmd(vty, hnbgw_T_defs, argv); +} + /* hnbgw * iucs } this part * foo } @@ -952,6 +961,7 @@ #endif osmo_tdef_vty_groups_init(HNBGW_NODE, hnbgw_tdef_group); + install_element(HNBGW_NODE, &cfg_hnbgw_timer_ps_cmd); install_element(CONFIG_NODE, &cfg_msc_nr_cmd); install_node(&msc_node, config_write_msc); diff --git a/src/osmo-hnbgw/ps_rab_ass_fsm.c b/src/osmo-hnbgw/ps_rab_ass_fsm.c index aa1fe74..4dff7c6 100644 --- a/src/osmo-hnbgw/ps_rab_ass_fsm.c +++ b/src/osmo-hnbgw/ps_rab_ass_fsm.c @@ -119,7 +119,7 @@ }; #define ps_rab_ass_fsm_state_chg(state) \ - osmo_tdef_fsm_inst_state_chg(fi, state, ps_rab_ass_fsm_timeouts, ps_T_defs, -1) + osmo_tdef_fsm_inst_state_chg(fi, state, ps_rab_ass_fsm_timeouts, hnbgw_T_defs, -1) static struct osmo_fsm ps_rab_ass_fsm; diff --git a/src/osmo-hnbgw/ps_rab_fsm.c b/src/osmo-hnbgw/ps_rab_fsm.c index bcf097d..df98826 100644 --- a/src/osmo-hnbgw/ps_rab_fsm.c +++ b/src/osmo-hnbgw/ps_rab_fsm.c @@ -72,7 +72,7 @@ #define ps_rab_fsm_state_chg(state) \ - osmo_tdef_fsm_inst_state_chg(fi, state, ps_rab_fsm_timeouts, ps_T_defs, -1) + osmo_tdef_fsm_inst_state_chg(fi, state, ps_rab_fsm_timeouts, hnbgw_T_defs, -1) #define PS_RAB_USE_ACTIVE "active" diff --git a/src/osmo-hnbgw/tdefs.c b/src/osmo-hnbgw/tdefs.c index 7af292d..645cdbf 100644 --- a/src/osmo-hnbgw/tdefs.c +++ b/src/osmo-hnbgw/tdefs.c @@ -31,20 +31,15 @@ { } }; -struct osmo_tdef ps_T_defs[] = { - {.T = -1002, .default_val = 10, .desc = "Timeout for the HNB to respond to PS RAB Assignment Request" }, - { } -}; - -struct osmo_tdef cmap_T_defs[] = { +struct osmo_tdef hnbgw_T_defs[] = { {.T = -31, .default_val = 5, .desc = "Timeout for discarding a partially released context map (RUA <-> SCCP)" }, + {.T = -1002, .default_val = 10, .desc = "Timeout for the HNB to respond to PS RAB Assignment Request" }, { } }; struct osmo_tdef_group hnbgw_tdef_group[] = { {.name = "mgw", .tdefs = mgw_fsm_T_defs, .desc = "MGW (Media Gateway) interface" }, - {.name = "ps", .tdefs = ps_T_defs, .desc = "timers for Packet Switched domain" }, - {.name = "cmap", .tdefs = cmap_T_defs, .desc = "timers for context maps (RUA <-> SCCP)" }, + {.name = "hnbgw", .tdefs = hnbgw_T_defs, .desc = "Timers" }, #if ENABLE_PFCP {.name = "pfcp", .tdefs = osmo_pfcp_tdefs, .desc = "PFCP timers" }, #endif -- To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/33131 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hnbgw Gerrit-Branch: master Gerrit-Change-Id: Ica6063fae4588b51897e5574d975b3185fa9ae80 Gerrit-Change-Number: 33131 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
1 0
0 0
[M] Change in osmo-hnbgw[master]: add hnbgw_decode_ranap_co()
by neels 05 Jun '23

05 Jun '23
neels has submitted this change. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/33132 ) Change subject: add hnbgw_decode_ranap_co() ...................................................................... add hnbgw_decode_ranap_co() An upcoming patch will re-use this pattern of decoding RANAP and attaching a talloc destructor to the result for the third time. The caller will be in hnbgw_rua.c, so make this a "public" function. Change-Id: I3695babfb083ed1f5fff700dcb7646fa95496a52 --- M include/osmocom/hnbgw/hnbgw_rua.h M src/osmo-hnbgw/context_map_rua.c 2 files changed, 40 insertions(+), 11 deletions(-) Approvals: pespin: Looks good to me, but someone else must approve Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/include/osmocom/hnbgw/hnbgw_rua.h b/include/osmocom/hnbgw/hnbgw_rua.h index 1526f11..0bf2de8 100644 --- a/include/osmocom/hnbgw/hnbgw_rua.h +++ b/include/osmocom/hnbgw/hnbgw_rua.h @@ -2,6 +2,7 @@ #include <osmocom/hnbgw/hnbgw.h> #include <osmocom/rua/RUA_Cause.h> +#include <osmocom/ranap/ranap_ies_defs.h> int hnbgw_rua_rx(struct hnb_context *hnb, struct msgb *msg); @@ -10,3 +11,5 @@ const uint8_t *data, unsigned int len); int rua_tx_disc(struct hnb_context *hnb, int is_ps, uint32_t context_id, const RUA_Cause_t *cause, const uint8_t *data, unsigned int len); + +ranap_message *hnbgw_decode_ranap_co(struct msgb *ranap_msg); diff --git a/src/osmo-hnbgw/context_map_rua.c b/src/osmo-hnbgw/context_map_rua.c index 9cb45b0..09c275d 100644 --- a/src/osmo-hnbgw/context_map_rua.c +++ b/src/osmo-hnbgw/context_map_rua.c @@ -133,22 +133,38 @@ return 0; } +/* Decode RANAP message with convenient memory freeing: just talloc_free() the returned pointer.. + * Allocate a ranap_message from OTC_SELECT, decode RANAP msgb into it, attach a talloc destructor that calls + * ranap_cn_rx_co_free() upon talloc_free(), and return the decoded ranap_message. */ +ranap_message *hnbgw_decode_ranap_co(struct msgb *ranap_msg) +{ + int rc; + ranap_message *message; + + if (!msg_has_l2_data(ranap_msg)) + return NULL; + message = talloc_zero(OTC_SELECT, ranap_message); + rc = ranap_cn_rx_co_decode2(message, msgb_l2(ranap_msg), msgb_l2len(ranap_msg)); + if (rc != 0) { + talloc_free(message); + return NULL; + } + talloc_set_destructor(message, destruct_ranap_cn_rx_co_ies); + return message; +} + /* Dispatch RANAP message to SCCP, if any. */ static int handle_rx_rua(struct osmo_fsm_inst *fi, struct msgb *ranap_msg) { struct hnbgw_context_map *map = fi->priv; - int rc; if (!msg_has_l2_data(ranap_msg)) return 0; /* See if it is a RAB Assignment Response message from RUA to SCCP, where we need to change the user plane * information, for RTP mapping via MGW, or GTP mapping via UPF. */ if (!map->is_ps) { - ranap_message *message = talloc_zero(OTC_SELECT, ranap_message); - rc = ranap_cn_rx_co_decode2(message, msgb_l2(ranap_msg), msgb_l2len(ranap_msg)); - if (rc == 0) { - talloc_set_destructor(message, destruct_ranap_cn_rx_co_ies); - + ranap_message *message = hnbgw_decode_ranap_co(ranap_msg); + if (message) { LOGPFSML(fi, LOGL_DEBUG, "rx from RUA: RANAP %s\n", get_value_string(ranap_procedure_code_vals, message->procedureCode)); @@ -161,11 +177,8 @@ #if ENABLE_PFCP } else if (hnb_gw_is_gtp_mapping_enabled()) { /* map->is_ps == true and PFCP is enabled in osmo-hnbgw.cfg */ - ranap_message *message = talloc_zero(OTC_SELECT, ranap_message); - rc = ranap_cn_rx_co_decode2(message, msgb_l2(ranap_msg), msgb_l2len(ranap_msg)); - if (rc == 0) { - talloc_set_destructor(message, destruct_ranap_cn_rx_co_ies); - + ranap_message *message = hnbgw_decode_ranap_co(ranap_msg); + if (message) { LOGPFSML(fi, LOGL_DEBUG, "rx from RUA: RANAP %s\n", get_value_string(ranap_procedure_code_vals, message->procedureCode)); -- To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/33132 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hnbgw Gerrit-Branch: master Gerrit-Change-Id: I3695babfb083ed1f5fff700dcb7646fa95496a52 Gerrit-Change-Number: 33132 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
1 0
0 0
[S] Change in osmo-hnbgw[master]: cnpool prep: add SCCP_EV_USER_ABORT
by neels 05 Jun '23

05 Jun '23
neels has submitted this change. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/33128 ) Change subject: cnpool prep: add SCCP_EV_USER_ABORT ...................................................................... cnpool prep: add SCCP_EV_USER_ABORT To ease patch review, I decided to submit this separately from the caller, which follows in subsequent patch I5479eded786ec26062d49403a8be12967f113cdb The new event will be dispatched when there are SCCP config changes pending, and the human user types 'apply sccp' on the telnet VTY. The aim is to disconnect all connections so we can create a new SCCP User. Related: SYS#6412 Change-Id: Idff8e09b5328c904b175e4d4df7d4044a34f4a20 --- M include/osmocom/hnbgw/context_map.h M src/osmo-hnbgw/context_map_sccp.c 2 files changed, 38 insertions(+), 0 deletions(-) Approvals: pespin: Looks good to me, approved Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/include/osmocom/hnbgw/context_map.h b/include/osmocom/hnbgw/context_map.h index 55d96ea..bcc3238 100644 --- a/include/osmocom/hnbgw/context_map.h +++ b/include/osmocom/hnbgw/context_map.h @@ -55,6 +55,9 @@ 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, + /* The human admin asks to drop the current SCCP connection, by telnet VTY 'apply sccp' in presence of SCCP + * config changes. */ + MAP_SCCP_EV_USER_ABORT, }; /* For context_map_get_state(), to combine the RUA and SCCP states, for VTY reporting only. */ diff --git a/src/osmo-hnbgw/context_map_sccp.c b/src/osmo-hnbgw/context_map_sccp.c index 00b24f2..cc65b6e 100644 --- a/src/osmo-hnbgw/context_map_sccp.c +++ b/src/osmo-hnbgw/context_map_sccp.c @@ -54,6 +54,7 @@ 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), + OSMO_VALUE_STRING(MAP_SCCP_EV_USER_ABORT), {} }; @@ -281,6 +282,7 @@ case MAP_SCCP_EV_RAN_LINK_LOST: case MAP_SCCP_EV_RAN_DISC: + case MAP_SCCP_EV_USER_ABORT: /* No CR has been sent yet, just go to disconnected state. */ if (msg_has_l2_data(ranap_msg)) LOG_MAP(map, DLSCCP, LOGL_ERROR, "SCCP not connected, cannot dispatch RANAP message\n"); @@ -317,6 +319,7 @@ case MAP_SCCP_EV_RAN_LINK_LOST: case MAP_SCCP_EV_RAN_DISC: + case MAP_SCCP_EV_USER_ABORT: /* RUA connection was terminated. First wait for the CC before releasing the SCCP conn. */ if (msg_has_l2_data(ranap_msg)) LOGPFSML(fi, LOGL_ERROR, "Connection not yet confirmed, cannot forward RANAP to CN\n"); @@ -373,6 +376,9 @@ 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. */ + case MAP_SCCP_EV_USER_ABORT: + /* The user is asking for disconnection, so there is no Iu Release in progress. Disconnect now. */ + /* 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); @@ -440,6 +446,12 @@ handle_rx_sccp(fi, ranap_msg); return; + case MAP_SCCP_EV_USER_ABORT: + /* Stop waiting for RLSD, send RLSD now. */ + tx_sccp_rlsd(fi); + map_sccp_fsm_state_chg(MAP_SCCP_ST_DISCONNECTED); + return; + default: OSMO_ASSERT(false); } @@ -511,6 +523,7 @@ | S(MAP_SCCP_EV_RAN_DISC) | S(MAP_SCCP_EV_RAN_LINK_LOST) | S(MAP_SCCP_EV_RX_RELEASED) + | S(MAP_SCCP_EV_USER_ABORT) , .out_state_mask = 0 | S(MAP_SCCP_ST_INIT) @@ -527,6 +540,7 @@ | S(MAP_SCCP_EV_RAN_DISC) | S(MAP_SCCP_EV_RAN_LINK_LOST) | S(MAP_SCCP_EV_RX_RELEASED) + | S(MAP_SCCP_EV_USER_ABORT) , .out_state_mask = 0 | S(MAP_SCCP_ST_CONNECTED) @@ -543,6 +557,7 @@ | S(MAP_SCCP_EV_RAN_LINK_LOST) | S(MAP_SCCP_EV_RX_RELEASED) | S(MAP_SCCP_EV_RX_CONNECTION_CONFIRM) + | S(MAP_SCCP_EV_USER_ABORT) , .out_state_mask = 0 | S(MAP_SCCP_ST_WAIT_RLSD) @@ -560,6 +575,7 @@ | S(MAP_SCCP_EV_RAN_DISC) | S(MAP_SCCP_EV_RAN_LINK_LOST) | S(MAP_SCCP_EV_RX_CONNECTION_CONFIRM) + | S(MAP_SCCP_EV_USER_ABORT) , .out_state_mask = 0 | S(MAP_SCCP_ST_DISCONNECTED) @@ -573,6 +589,7 @@ | S(MAP_SCCP_EV_TX_DATA_REQUEST) | S(MAP_SCCP_EV_RAN_DISC) | S(MAP_SCCP_EV_RAN_LINK_LOST) + | S(MAP_SCCP_EV_USER_ABORT) , .onenter = map_sccp_disconnected_onenter, .action = map_sccp_disconnected_action, -- To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/33128 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hnbgw Gerrit-Branch: master Gerrit-Change-Id: Idff8e09b5328c904b175e4d4df7d4044a34f4a20 Gerrit-Change-Number: 33128 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
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • ...
  • 248
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.