osmith has uploaded this change for review. (
https://gerrit.osmocom.org/c/osmo-bsc-nat/+/27463 )
Change subject: bsc_nat_sccp_inst: store ss7_inst
......................................................................
bsc_nat_sccp_inst: store ss7_inst
Get ss7_inst once and store it inside bsc_nat_sccp_inst to avoid
multiple calls to osmo_ss7_instance_find().
Related: SYS#5560
Change-Id: I9a8b69fb3df17c85a67958fbca88948573d39694
---
M include/osmocom/bsc_nat/bsc_nat.h
M src/osmo-bsc-nat/bsc_nat_fsm.c
2 files changed, 8 insertions(+), 8 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-bsc-nat refs/changes/63/27463/1
diff --git a/include/osmocom/bsc_nat/bsc_nat.h b/include/osmocom/bsc_nat/bsc_nat.h
index 37568e8..3c77c23 100644
--- a/include/osmocom/bsc_nat/bsc_nat.h
+++ b/include/osmocom/bsc_nat/bsc_nat.h
@@ -24,6 +24,8 @@
struct bsc_nat_sccp_inst {
uint32_t ss7_id;
+ struct osmo_ss7_instance *ss7_inst;
+
struct osmo_sccp_addr local_sccp_addr;
struct osmo_sccp_user *scu;
};
diff --git a/src/osmo-bsc-nat/bsc_nat_fsm.c b/src/osmo-bsc-nat/bsc_nat_fsm.c
index a35a704..b4e0516 100644
--- a/src/osmo-bsc-nat/bsc_nat_fsm.c
+++ b/src/osmo-bsc-nat/bsc_nat_fsm.c
@@ -100,17 +100,14 @@
struct osmo_sccp_addr *peer_addr_out)
{
struct bsc_nat_sccp_inst *dest = sccp_inst_dest(src);
- struct osmo_ss7_instance *dest_ss7 = osmo_ss7_instance_find(dest->ss7_id);
-
- OSMO_ASSERT(dest_ss7);
if (src == g_bsc_nat->ran) {
- if (osmo_sccp_addr_by_name_local(peer_addr_out, "msc", dest_ss7) < 0) {
+ if (osmo_sccp_addr_by_name_local(peer_addr_out, "msc", dest->ss7_inst)
< 0) {
LOG_SCCP(src, peer_addr_in, LOGL_ERROR, "Could not find MSC in address
book\n");
return -1;
}
} else {
- if (osmo_sccp_addr_by_name_local(peer_addr_out, "bsc", dest_ss7) < 0) {
+ if (osmo_sccp_addr_by_name_local(peer_addr_out, "bsc", dest->ss7_inst)
< 0) {
LOG_SCCP(src, peer_addr_in, LOGL_ERROR, "Could not find BSC in address
book\n");
return -2;
}
@@ -251,6 +248,8 @@
return -1;
}
+ sccp_inst->ss7_inst = osmo_ss7_instance_find(sccp_inst->ss7_id);
+
osmo_sccp_local_addr_by_instance(&sccp_inst->local_sccp_addr, sccp, ssn);
sccp_inst->scu = osmo_sccp_user_bind(sccp, name, sccp_sap_up, ssn);
@@ -270,9 +269,8 @@
sccp_inst->scu = NULL;
}
- struct osmo_ss7_instance *ss7_inst = osmo_ss7_instance_find(sccp_inst->ss7_id);
- if (ss7_inst)
- osmo_ss7_instance_destroy(ss7_inst);
+ if (sccp_inst->ss7_inst)
+ osmo_ss7_instance_destroy(sccp_inst->ss7_inst);
talloc_free(sccp_inst);
}
--
To view, visit
https://gerrit.osmocom.org/c/osmo-bsc-nat/+/27463
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bsc-nat
Gerrit-Branch: master
Gerrit-Change-Id: I9a8b69fb3df17c85a67958fbca88948573d39694
Gerrit-Change-Number: 27463
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
Gerrit-MessageType: newchange