pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bsc/+/40562?usp=email )
Change subject: bsc: Make sure MSC PC is added to sccp-addressbook ...................................................................... bsc: Make sure MSC PC is added to sccp-addressbook This way they can used by libosmo-sigtran to figure out interesting remote PCs it should track availability for. Related: OS#5917 Related: SYS#7501 Depends: libosmo-sigtran.git Change-Id I9d2452d9cc8e443050927a047b7ebacd2b2f37e1 Change-Id: I57dca92eb5f482e9017d9b19cd7f8feebd9e2721 --- M TODO-RELEASE M src/osmo-bsc/bsc_vty.c M src/osmo-bsc/osmo_bsc_sigtran.c 3 files changed, 70 insertions(+), 42 deletions(-) Approvals: Jenkins Builder: Verified osmith: Looks good to me, but someone else must approve laforge: Looks good to me, but someone else must approve pespin: Looks good to me, approved diff --git a/TODO-RELEASE b/TODO-RELEASE index c6495da..0eae0e8 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -8,3 +8,4 @@ # If any interfaces have been removed or changed since the last public release: c:r:0. #library what description / commit summary line libosmo-mgcp-client bump_dep Depend on I0d58e6d84418f50670c8ab7cf8490af3bc2f5c26 +libosmo-sigtran >2.1.0 osmo_sccp_addr_{create,update}() diff --git a/src/osmo-bsc/bsc_vty.c b/src/osmo-bsc/bsc_vty.c index 98a7792..52ad6b3 100644 --- a/src/osmo-bsc/bsc_vty.c +++ b/src/osmo-bsc/bsc_vty.c @@ -2946,7 +2946,8 @@ /* Make sure only standard SSN numbers are used. If no ssn number is * configured, silently apply the default SSN */ -static void enforce_standard_ssn(struct vty *vty, struct osmo_sccp_addr *addr) +static void enforce_standard_ssn(struct vty *vty, struct osmo_ss7_instance *ss7, + const char *addr_name, struct osmo_sccp_addr *addr) { if (addr->presence & OSMO_SCCP_ADDR_T_SSN) { if (addr->ssn != OSMO_SCCP_SSN_BSSAP) @@ -2957,6 +2958,7 @@ addr->presence |= OSMO_SCCP_ADDR_T_SSN; addr->ssn = OSMO_SCCP_SSN_BSSAP; + osmo_sccp_addr_update(ss7, addr_name, addr); } DEFUN(cfg_msc_cs7_bsc_addr, @@ -2988,8 +2990,8 @@ msc->a.cs7_instance = ss7_id; msc->a.cs7_instance_valid = true; - enforce_standard_ssn(vty, &msc->a.bsc_addr); msc->a.bsc_addr_name = talloc_strdup(msc, bsc_addr_name); + enforce_standard_ssn(vty, ss7, bsc_addr_name, &msc->a.bsc_addr); return CMD_SUCCESS; } @@ -3022,8 +3024,8 @@ msc->a.cs7_instance = ss7_id; msc->a.cs7_instance_valid = true; - enforce_standard_ssn(vty, &msc->a.msc_addr); msc->a.msc_addr_name = talloc_strdup(msc, msc_addr_name); + enforce_standard_ssn(vty, ss7, msc_addr_name, &msc->a.msc_addr); return CMD_SUCCESS; } diff --git a/src/osmo-bsc/osmo_bsc_sigtran.c b/src/osmo-bsc/osmo_bsc_sigtran.c index f51aa0a..8abeeb6 100644 --- a/src/osmo-bsc/osmo_bsc_sigtran.c +++ b/src/osmo-bsc/osmo_bsc_sigtran.c @@ -552,6 +552,9 @@ /* Default point-code to be used as remote address (MSC) */ #define MSC_DEFAULT_PC "0.23.1" +/* Default point-code to be used as remote address (MSC) */ +#define MSC_DEFAULT_ADDR_NAME "addr-dyn-msc-default" + static int asp_rx_unknown(struct osmo_ss7_asp *asp, int ppid_mux, struct msgb *msg); /* Initialize osmo sigtran backhaul */ @@ -560,55 +563,79 @@ struct bsc_msc_data *msc; uint32_t default_pc; struct llist_head *ll_it; - int create_instance_0_for_msc_nr = -1; + int rc; osmo_ss7_register_rx_unknown_cb(&asp_rx_unknown); OSMO_ASSERT(mscs); msc_list = mscs; - /* Guard against multiple MSCs with identical config */ + /* Apply default address on each MSC and validate which ss7 instance it runs on. */ llist_for_each_entry(msc, msc_list, entry) { - struct bsc_msc_data *msc2; + struct osmo_ss7_instance *s7i; /* An MSC with invalid cs7 instance defaults to cs7 instance 0 */ - uint32_t msc_inst = (msc->a.cs7_instance_valid ? msc->a.cs7_instance : 0); + if (!msc->a.cs7_instance_valid) { + s7i = osmo_ss7_instance_find(0); + if (!s7i) { + LOGP(DMSC, LOGL_NOTICE, "To auto-configure msc %d, creating cs7 instance 0 implicitly\n", + msc->nr); + s7i = osmo_ss7_instance_find_or_create(tall_bsc_ctx, 0); + OSMO_ASSERT(s7i); + } + msc->a.cs7_instance = osmo_ss7_instance_get_id(s7i); + msc->a.cs7_instance_valid = true; + } else { + s7i = osmo_ss7_instance_find(msc->a.cs7_instance); + } - if (!msc->a.cs7_instance_valid) - create_instance_0_for_msc_nr = msc->nr; - - /* If unset, use default SCCP address for the MSC */ - if (!msc->a.msc_addr.presence) - osmo_sccp_make_addr_pc_ssn(&msc->a.msc_addr, - osmo_ss7_pointcode_parse(NULL, MSC_DEFAULT_PC), - OSMO_SCCP_SSN_BSSAP); - - /* (more optimally, we'd only iterate the remaining other mscs after this msc, but this happens only - * during startup, so nevermind that complexity and rather check each pair twice. That also ensures to - * compare all MSCs that have no explicit msc_addr set, see osmo_sccp_make_addr_pc_ssn() above.) */ - llist_for_each_entry(msc2, msc_list, entry) { - uint32_t msc2_inst; - - if (msc2 == msc) - continue; - - msc2_inst = (msc2->a.cs7_instance_valid ? msc2->a.cs7_instance : 0); - if (msc_inst != msc2_inst) - continue; - - if (osmo_sccp_addr_cmp(&msc->a.msc_addr, &msc2->a.msc_addr, OSMO_SCCP_ADDR_T_PC) == 0) { - LOGP(DMSC, LOGL_ERROR, "'msc %d' and 'msc %d' cannot use the same remote PC" - " %s on the same cs7 instance %u\n", - msc->nr, msc2->nr, osmo_sccp_addr_dump(&msc->a.msc_addr), msc_inst); - return -EINVAL; + /* User didn't configure an 'msc-addr' in VTY for this msc, add + * default SCCP address for the MSC to the address book */ + if (!msc->a.msc_addr_name) { + msc->a.msc_addr_name = talloc_strdup(msc, MSC_DEFAULT_ADDR_NAME); + LOGP(DMSC, LOGL_NOTICE, "To auto-configure msc %d, adding address '%s' to cs7 instance 0 address-book implicitly\n", + msc->nr, msc->a.msc_addr_name); + } + if (!msc->a.msc_addr.presence) { + struct osmo_ss7_instance *ss7; + ss7 = osmo_sccp_addr_by_name(&msc->a.msc_addr, msc->a.msc_addr_name); + if (!ss7) { + osmo_sccp_make_addr_pc_ssn(&msc->a.msc_addr, + osmo_ss7_pointcode_parse(s7i, MSC_DEFAULT_PC), + OSMO_SCCP_SSN_BSSAP); + rc = osmo_sccp_addr_create(s7i, msc->a.msc_addr_name, &msc->a.msc_addr); + if (rc < 0) + return -EINVAL; + } else { + OSMO_ASSERT(s7i == ss7); + osmo_sccp_make_addr_pc_ssn(&msc->a.msc_addr, + osmo_ss7_pointcode_parse(s7i, MSC_DEFAULT_PC), + OSMO_SCCP_SSN_BSSAP); + rc = osmo_sccp_addr_update(s7i, msc->a.msc_addr_name, &msc->a.msc_addr); + if (rc < 0) + return -EINVAL; } } } - if (create_instance_0_for_msc_nr >= 0 && !osmo_ss7_instance_find(0)) { - LOGP(DMSC, LOGL_NOTICE, "To auto-configure msc %d, creating cs7 instance 0 implicitly\n", - create_instance_0_for_msc_nr); - OSMO_ASSERT(osmo_ss7_instance_find_or_create(tall_bsc_ctx, 0)); + /* Guard against multiple MSCs with identical config */ + /* (more optimally, we'd only iterate the remaining other mscs after this msc, but this happens only + * during startup, so nevermind that complexity and rather check each pair twice. That also ensures to + * compare all MSCs that have no explicit msc_addr set, see osmo_sccp_make_addr_pc_ssn() above.) */ + llist_for_each_entry(msc, msc_list, entry) { + struct bsc_msc_data *msc2; + llist_for_each_entry(msc2, msc_list, entry) { + if (msc2 == msc) + continue; + if (msc->a.cs7_instance != msc2->a.cs7_instance) + continue; + if (osmo_sccp_addr_cmp(&msc->a.msc_addr, &msc2->a.msc_addr, OSMO_SCCP_ADDR_T_PC) == 0) { + LOGP(DMSC, LOGL_ERROR, "'msc %d' and 'msc %d' cannot use the same remote PC" + " %s on the same cs7 instance %u\n", + msc->nr, msc2->nr, osmo_sccp_addr_dump(&msc->a.msc_addr), msc->a.cs7_instance); + return -EINVAL; + } + } } /* Set up exactly one SCCP user and one ASP+AS per cs7 instance. @@ -627,8 +654,7 @@ llist_for_each_entry(msc, msc_list, entry) { /* An MSC with invalid cs7 instance id defaults to cs7 instance 0 */ - if ((inst_id != msc->a.cs7_instance) - && !(inst_id == 0 && !msc->a.cs7_instance_valid)) + if (inst_id != msc->a.cs7_instance) continue; /* This msc runs on this cs7 inst. Check the asp_proto. */ @@ -676,8 +702,7 @@ char msc_name[32]; /* Skip MSCs that don't run on this cs7 instance */ - if ((inst_id != msc->a.cs7_instance) - && !(inst_id == 0 && !msc->a.cs7_instance_valid)) + if (inst_id != msc->a.cs7_instance) continue; snprintf(msc_name, sizeof(msc_name), "msc-%d", msc->nr); -- To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/40562?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: osmo-bsc Gerrit-Branch: master Gerrit-Change-Id: I57dca92eb5f482e9017d9b19cd7f8feebd9e2721 Gerrit-Change-Number: 40562 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pes...@sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillm...@sysmocom.de> Gerrit-Reviewer: laforge <lafo...@osmocom.org> Gerrit-Reviewer: osmith <osm...@sysmocom.de> Gerrit-Reviewer: pespin <pes...@sysmocom.de>