pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/42114?usp=email )
(
1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
)Change subject: xua_as_fsm: Remove TODO no longer valid
......................................................................
xua_as_fsm: Remove TODO no longer valid
Routing Context is filled in in fill_notify_route_ctx().
Take the chance to move the logging a bit up in the function, to have
all npar filling together.
Change-Id: I57af18dacc0470d36ddd4705a9530bd44b31f9c0
---
M src/xua_as_fsm.c
1 file changed, 4 insertions(+), 4 deletions(-)
Approvals:
daniel: Looks good to me, but someone else must approve
laforge: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/src/xua_as_fsm.c b/src/xua_as_fsm.c
index bdcd0d5..422a2b4 100644
--- a/src/xua_as_fsm.c
+++ b/src/xua_as_fsm.c
@@ -128,6 +128,9 @@
if (!asp->fi || asp->fi->state == XUA_ASP_S_DOWN)
continue;
+ LOGPASP(asp, DLSS7, LOGL_INFO, "Tx NOTIFY Type %s:%s (%s)\n",
+ type_name, info_name, info_str);
+
/* Optional: ASP Identifier (if sent in ASP-UP) */
if (asp->remote_asp_id_present) {
npar->presence |= NOTIFY_PAR_P_ASP_ID;
@@ -135,11 +138,8 @@
} else
npar->presence &= ~NOTIFY_PAR_P_ASP_ID;
- /* TODO: Optional Routing Context */
-
- LOGPASP(asp, DLSS7, LOGL_INFO, "Tx NOTIFY Type %s:%s (%s)\n",
- type_name, info_name, info_str);
fill_notify_route_ctx(asp, npar);
+
msg = encode_notify(npar);
osmo_ss7_asp_send(asp, msg);
sent++;
--
To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/42114?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: libosmo-sigtran
Gerrit-Branch: master
Gerrit-Change-Id: I57af18dacc0470d36ddd4705a9530bd44b31f9c0
Gerrit-Change-Number: 42114
Gerrit-PatchSet: 4
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/42115?usp=email )
(
2 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
)Change subject: Allow configuring local ASP Identifier
......................................................................
Allow configuring local ASP Identifier
If configured, it will be transmitted during ASP UP and ASP UP ACK.
This may be needed if facing an SG/IPSP peer who requires ASP Identifier
to be set.
Related: OS#6953
Change-Id: Ib94d542f940e13d5c007bc3319e7dde65cf81f12
---
M src/ss7_asp.h
M src/ss7_asp_vty.c
M src/xua_asp_fsm.c
M tests/vty/osmo_stp_test.vty
M tests/vty/ss7_asp_test.vty
5 files changed, 55 insertions(+), 29 deletions(-)
Approvals:
laforge: Looks good to me, but someone else must approve
Jenkins Builder: Verified
osmith: Looks good to me, but someone else must approve
pespin: Looks good to me, approved
diff --git a/src/ss7_asp.h b/src/ss7_asp.h
index 0d047cb..75be6cc 100644
--- a/src/ss7_asp.h
+++ b/src/ss7_asp.h
@@ -73,12 +73,8 @@
/*! pre-formatted human readable local/remote socket name */
char *sock_name;
- /* ASP Identifier for ASP-UP + NTFY, as received by the peer.
- * FIXME: This should actually be stored in a AS-ASP relation, since it
- * can be different per AS, see RFC4666 3.5.1
- * "The optional ASP Identifier parameter contains a unique value that
- * is locally significant among the ASPs that support an AS".
- */
+ /* Peer's ASP Identifier, as received during ASPUP (SG/IPSP) and ASPUP ACK (IPSP),
+ * and transmitted during NOTIFY. */
uint32_t remote_asp_id;
bool remote_asp_id_present;
@@ -128,6 +124,13 @@
* "[no] shutdown" explicitly in cfg files. */
bool explicit_shutdown_state_by_vty_since_node_enter;
+ /* Local ASP Identifier transmitted during ASPUP (ASP/IPSP) and ASPUP ACK (IPSP),
+ * and received during NOTIFY.
+ * "The optional ASP Identifier parameter contains a unique value
+ * that is locally significant among the ASPs that support an AS". */
+ uint32_t local_asp_id;
+ bool local_asp_id_present;
+
struct osmo_ss7_asp_peer local;
struct osmo_ss7_asp_peer remote;
uint8_t qos_class;
diff --git a/src/ss7_asp_vty.c b/src/ss7_asp_vty.c
index 241863a..6b03275 100644
--- a/src/ss7_asp_vty.c
+++ b/src/ss7_asp_vty.c
@@ -28,6 +28,7 @@
#include <errno.h>
#include <stdint.h>
#include <string.h>
+#include <inttypes.h>
#include <netdb.h>
#include <arpa/inet.h>
@@ -453,6 +454,35 @@
return CMD_SUCCESS;
}
+DEFUN_ATTR(asp_identifier, asp_identifier_cmd,
+ "asp-identifier <0-4294967295>",
+ "Specify ASP Identifier for this ASP\n"
+ "ASP Identifier\n",
+ CMD_ATTR_NODE_EXIT)
+{
+ struct osmo_ss7_asp *asp = vty->index;
+ int64_t id64 = 0;
+ int rc = osmo_str_to_int64(&id64, argv[0], 10, 0, UINT32_MAX);
+ if (rc < 0)
+ return CMD_WARNING;
+
+ asp->cfg.local_asp_id_present = true;
+ asp->cfg.local_asp_id = (uint32_t)id64;
+ return CMD_SUCCESS;
+}
+
+DEFUN_ATTR(asp_no_identifier, asp_no_identifier_cmd,
+ "no asp-identifier",
+ NO_STR "Specify ASP Identifier for this ASP\n",
+ CMD_ATTR_NODE_EXIT)
+{
+ struct osmo_ss7_asp *asp = vty->index;
+
+ asp->cfg.local_asp_id_present = false;
+ asp->cfg.local_asp_id = 0;
+ return CMD_SUCCESS;
+}
+
DEFUN_ATTR(asp_transport_role, asp_transport_role_cmd,
"transport-role (client|server)",
"Specify the transport layer role for this ASP\n"
@@ -1322,6 +1352,8 @@
vty_out(vty, "%s", VTY_NEWLINE);
if (asp->cfg.description)
vty_out(vty, " description %s%s", asp->cfg.description, VTY_NEWLINE);
+ if (asp->cfg.local_asp_id_present)
+ vty_out(vty, " asp-identifier %" PRIu32 "%s", asp->cfg.local_asp_id, VTY_NEWLINE);
for (i = 0; i < asp->cfg.local.host_cnt; i++) {
if (asp->cfg.local.host[i])
vty_out(vty, " local-ip %s%s%s", asp->cfg.local.host[i],
@@ -1443,6 +1475,8 @@
install_lib_element(L_CS7_NODE, &cs7_asp_trans_proto_cmd);
install_lib_element(L_CS7_NODE, &no_cs7_asp_cmd);
install_lib_element(L_CS7_ASP_NODE, &cfg_description_cmd);
+ install_lib_element(L_CS7_ASP_NODE, &asp_identifier_cmd);
+ install_lib_element(L_CS7_ASP_NODE, &asp_no_identifier_cmd);
install_lib_element(L_CS7_ASP_NODE, &asp_remote_ip_cmd);
install_lib_element(L_CS7_ASP_NODE, &asp_no_remote_ip_cmd);
install_lib_element(L_CS7_ASP_NODE, &asp_local_ip_cmd);
diff --git a/src/xua_asp_fsm.c b/src/xua_asp_fsm.c
index 4204e31..cdbb0da 100644
--- a/src/xua_asp_fsm.c
+++ b/src/xua_asp_fsm.c
@@ -226,33 +226,16 @@
/* RFC 3868 Ch. 3.5.1 */
xua->hdr = XUA_HDR(SUA_MSGC_ASPSM, SUA_ASPSM_UP);
/* Optional: ASP ID */
-#if 0
- /* TODO: RFC 4666 3.8.1:
- * 'The "ASP Identifier Required" error is sent by an SGP in
- * response to an ASP Up message that does not contain an ASP
- * Identifier parameter when the SGP requires one. The ASP SHOULD
- * resend the ASP Up message with an ASP Identifier.' */
- if (ss7_asp_peer_requires_asp_id(asp)) { /* Maybe configure in VTY "asp" node? */
- asp_id = /* get a unique id of asp within as, eg. the index in as->asps[] */;
- xua_msg_add_u32(xua, SUA_IEI_ASP_ID, asp_id);
- }
-#endif
+ if (asp->cfg.local_asp_id_present)
+ xua_msg_add_u32(xua, SUA_IEI_ASP_ID, asp->cfg.local_asp_id);
/* Optional: Info String */
break;
case XUA_ASP_E_ASPSM_ASPUP_ACK:
/* RFC3868 Ch. 3.5.2 */
xua->hdr = XUA_HDR(SUA_MSGC_ASPSM, SUA_ASPSM_UP_ACK);
/* Optional: ASP ID */
-#if 0
- /* TODO: RFC 4666 3.5.2:
- * "The optional ASP Identifier parameter is specifically useful for IPSP
- * communication. In that case, the IPSP answering the ASP Up message
- * MAY include its own ASP Identifier value." */
- if (ss7_asp_peer_requires_asp_id(asp)) { /* Maybe configure in VTY "asp" node? */
- asp_id = /* get a unique id of asp within as, eg. the index in as->asps[] */;
- xua_msg_add_u32(xua, SUA_IEI_ASP_ID, asp_id);
- }
-#endif
+ if (asp->cfg.local_asp_id_present)
+ xua_msg_add_u32(xua, SUA_IEI_ASP_ID, asp->cfg.local_asp_id);
/* Optional: Info String */
break;
case XUA_ASP_E_ASPSM_ASPDN:
diff --git a/tests/vty/osmo_stp_test.vty b/tests/vty/osmo_stp_test.vty
index 72eb0de..6e98bb4 100644
--- a/tests/vty/osmo_stp_test.vty
+++ b/tests/vty/osmo_stp_test.vty
@@ -279,6 +279,8 @@
OsmoSTP(config-cs7-asp)# list
...
description .TEXT
+ asp-identifier <0-4294967295>
+ no asp-identifier
remote-ip (A.B.C.D|X:X::X:X) [primary]
no remote-ip (A.B.C.D|X:X::X:X)
local-ip (A.B.C.D|X:X::X:X) [primary]
@@ -308,8 +310,9 @@
OsmoSTP(config-cs7-asp)# ?
...
description Save human-readable description of the object
- remote-ip Specify Remote IP Address of ASP
+ asp-identifier Specify ASP Identifier for this ASP
no Negate a command or set its defaults
+ remote-ip Specify Remote IP Address of ASP
local-ip Specify Local IP Address from which to contact ASP
qos-class Specify QoS Class of ASP
role Specify the xUA role for this ASP
diff --git a/tests/vty/ss7_asp_test.vty b/tests/vty/ss7_asp_test.vty
index 1ff4e36..ee6f9c2 100644
--- a/tests/vty/ss7_asp_test.vty
+++ b/tests/vty/ss7_asp_test.vty
@@ -275,6 +275,8 @@
ss7_asp_vty_test(config-cs7-asp)# list
...
description .TEXT
+ asp-identifier <0-4294967295>
+ no asp-identifier
remote-ip (A.B.C.D|X:X::X:X) [primary]
no remote-ip (A.B.C.D|X:X::X:X)
local-ip (A.B.C.D|X:X::X:X) [primary]
@@ -304,8 +306,9 @@
ss7_asp_vty_test(config-cs7-asp)# ?
...
description Save human-readable description of the object
- remote-ip Specify Remote IP Address of ASP
+ asp-identifier Specify ASP Identifier for this ASP
no Negate a command or set its defaults
+ remote-ip Specify Remote IP Address of ASP
local-ip Specify Local IP Address from which to contact ASP
qos-class Specify QoS Class of ASP
role Specify the xUA role for this ASP
--
To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/42115?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: libosmo-sigtran
Gerrit-Branch: master
Gerrit-Change-Id: Ib94d542f940e13d5c007bc3319e7dde65cf81f12
Gerrit-Change-Number: 42115
Gerrit-PatchSet: 4
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/42116?usp=email )
(
1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
)Change subject: xua_asp_fsm: Remove obvious comments
......................................................................
xua_asp_fsm: Remove obvious comments
Those can already be interpretred directly by the ENSURE_* macros.
No need to clog the file with more lines describing stuff.
Change-Id: Idec06646c48fbce4cbe200e88f987dfb3e9d5a39
---
M src/xua_asp_fsm.c
1 file changed, 0 insertions(+), 18 deletions(-)
Approvals:
Jenkins Builder: Verified
daniel: Looks good to me, approved
diff --git a/src/xua_asp_fsm.c b/src/xua_asp_fsm.c
index cdbb0da..34419a4 100644
--- a/src/xua_asp_fsm.c
+++ b/src/xua_asp_fsm.c
@@ -531,13 +531,11 @@
switch (event) {
case XUA_ASP_E_M_ASP_UP_REQ:
- /* only if role ASP */
ENSURE_ASP_OR_IPSP(fi, event);
/* Send M3UA_MSGT_ASPSM_ASPUP and start t_ack */
peer_send_and_start_t_ack(fi, XUA_ASP_E_ASPSM_ASPUP);
break;
case XUA_ASP_E_ASPSM_ASPUP_ACK:
- /* only if role ASP */
ENSURE_ASP_OR_IPSP(fi, event);
/* Optional ASP Identifier */
if ((asp_id_ie = xua_msg_find_tag(data, SUA_IEI_ASP_ID))) {
@@ -549,7 +547,6 @@
send_xlm_prim_simple(fi, OSMO_XLM_PRIM_M_ASP_UP, PRIM_OP_CONFIRM);
break;
case XUA_ASP_E_ASPSM_ASPUP:
- /* only if role SG */
ENSURE_SG_OR_IPSP(fi, event);
/* Optional ASP Identifier: Store for NTFY */
if ((asp_id_ie = xua_msg_find_tag(data, SUA_IEI_ASP_ID))) {
@@ -564,7 +561,6 @@
PRIM_OP_INDICATION);
break;
case XUA_ASP_E_ASPSM_ASPDN:
- /* only if role SG */
ENSURE_SG_OR_IPSP(fi, event);
/* The SGP MUST send an ASP Down Ack message in response
* to a received ASP Down message from the ASP even if
@@ -634,7 +630,6 @@
send_xlm_prim_simple(fi, OSMO_XLM_PRIM_M_ASP_UP, PRIM_OP_CONFIRM);
break;
case XUA_ASP_E_ASPTM_ASPAC_ACK:
- /* only in role ASP */
ENSURE_ASP_OR_IPSP(fi, event);
/* transition state and inform layer manager */
osmo_fsm_inst_state_chg(fi, XUA_ASP_S_ACTIVE, 0, 0);
@@ -642,7 +637,6 @@
PRIM_OP_CONFIRM);
break;
case XUA_ASP_E_ASPSM_ASPDN_ACK:
- /* only in role ASP */
ENSURE_ASP_OR_IPSP(fi, event);
/* transition state and inform layer manager */
osmo_fsm_inst_state_chg(fi, XUA_ASP_S_DOWN, 0, 0);
@@ -651,7 +645,6 @@
break;
case XUA_ASP_E_ASPTM_ASPAC:
xua_in = data;
- /* only in role SG */
ENSURE_SG_OR_IPSP(fi, event);
if (xua_msg_find_tag(xua_in, M3UA_IEI_TRAF_MODE_TYP)) {
traf_mode = xua_msg_get_u32(xua_in, M3UA_IEI_TRAF_MODE_TYP);
@@ -702,7 +695,6 @@
PRIM_OP_INDICATION);
break;
case XUA_ASP_E_ASPSM_ASPDN:
- /* only in role SG */
ENSURE_SG_OR_IPSP(fi, event);
/* send ACK */
peer_send(fi, XUA_ASP_E_ASPSM_ASPDN_ACK, NULL);
@@ -712,7 +704,6 @@
PRIM_OP_INDICATION);
break;
case XUA_ASP_E_ASPSM_ASPUP:
- /* only if role SG */
ENSURE_SG_OR_IPSP(fi, event);
/* If an ASP Up message is received and internally the
* remote ASP is already in the ASP-INACTIVE state, an
@@ -721,7 +712,6 @@
peer_send(fi, XUA_ASP_E_ASPSM_ASPUP_ACK, NULL);
break;
case XUA_ASP_E_ASPTM_ASPIA:
- /* only in role SG */
ENSURE_SG_OR_IPSP(fi, event);
peer_send(fi, XUA_ASP_E_ASPTM_ASPIA_ACK, NULL);
break;
@@ -759,7 +749,6 @@
send_xlm_prim_simple(fi, OSMO_XLM_PRIM_M_ASP_ACTIVE, PRIM_OP_CONFIRM);
break;
case XUA_ASP_E_ASPSM_ASPDN_ACK:
- /* only in role ASP */
ENSURE_ASP_OR_IPSP(fi, event);
osmo_fsm_inst_state_chg(fi, XUA_ASP_S_DOWN, 0, 0);
/* inform layer manager */
@@ -767,7 +756,6 @@
PRIM_OP_CONFIRM);
break;
case XUA_ASP_E_ASPTM_ASPIA_ACK:
- /* only in role ASP */
ENSURE_ASP_OR_IPSP(fi, event);
osmo_fsm_inst_state_chg(fi, XUA_ASP_S_INACTIVE, 0, 0);
/* inform layer manager */
@@ -775,19 +763,16 @@
PRIM_OP_CONFIRM);
break;
case XUA_ASP_E_M_ASP_DOWN_REQ:
- /* only in role ASP */
ENSURE_ASP_OR_IPSP(fi, event);
/* send M3UA_MSGT_ASPSM_ASPDN and star t_ack */
peer_send_and_start_t_ack(fi, XUA_ASP_E_ASPSM_ASPDN);
break;
case XUA_ASP_E_M_ASP_INACTIVE_REQ:
- /* only in role ASP */
ENSURE_ASP_OR_IPSP(fi, event);
/* send M3UA_MSGT_ASPTM_ASPIA and star t_ack */
peer_send_and_start_t_ack(fi, XUA_ASP_E_ASPTM_ASPIA);
break;
case XUA_ASP_E_ASPTM_ASPIA:
- /* only in role SG */
ENSURE_SG_OR_IPSP(fi, event);
/* send ACK */
peer_send(fi, XUA_ASP_E_ASPTM_ASPIA_ACK, NULL);
@@ -797,7 +782,6 @@
PRIM_OP_INDICATION);
break;
case XUA_ASP_E_ASPSM_ASPDN:
- /* only in role SG */
ENSURE_SG_OR_IPSP(fi, event);
/* send ACK */
peer_send(fi, XUA_ASP_E_ASPSM_ASPDN_ACK, NULL);
@@ -807,7 +791,6 @@
PRIM_OP_INDICATION);
break;
case XUA_ASP_E_ASPSM_ASPUP:
- /* only if role SG */
ENSURE_SG_OR_IPSP(fi, event);
/* an ASP Up Ack message is returned, as well as
* an Error message ("Unexpected Message), and the
@@ -821,7 +804,6 @@
break;
case XUA_ASP_E_ASPTM_ASPAC:
xua_in = data;
- /* only in role SG */
ENSURE_SG_OR_IPSP(fi, event);
/* send ACK */
peer_send(fi, XUA_ASP_E_ASPTM_ASPAC_ACK, xua_in);
--
To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/42116?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: libosmo-sigtran
Gerrit-Branch: master
Gerrit-Change-Id: Idec06646c48fbce4cbe200e88f987dfb3e9d5a39
Gerrit-Change-Number: 42116
Gerrit-PatchSet: 4
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/42108?usp=email )
(
2 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
)Change subject: ss7_as: Optimize ASP Tx selection in Override traffic mode
......................................................................
ss7_as: Optimize ASP Tx selection in Override traffic mode
Cache the last selected ASP, and expect it to still be the active ASP
most of the time until it changes.
Change-Id: I3d480d23591f4bd216293be60b22389b182fd8f3
---
M src/ss7_as.c
1 file changed, 10 insertions(+), 2 deletions(-)
Approvals:
fixeria: Looks good to me, but someone else must approve
Jenkins Builder: Verified
daniel: Looks good to me, approved
diff --git a/src/ss7_as.c b/src/ss7_as.c
index 4090d4a..8a5c1a1 100644
--- a/src/ss7_as.c
+++ b/src/ss7_as.c
@@ -404,8 +404,16 @@
{
struct ss7_as_asp_assoc *assoc;
- llist_for_each_entry(assoc, &as->assoc_asp_list, as_entry) {
- if (osmo_ss7_asp_active(assoc->asp))
+ /* Hot path: Override traffic mode has only max 1 active ASP at a time.
+ * Unless there's a change in state, the last ASP used to transmit is most
+ * probably the active one: */
+ if (as->last_asp_idx_sent && osmo_ss7_asp_active(as->last_asp_idx_sent->asp))
+ return as->last_asp_idx_sent->asp;
+
+ /* Slow path: Active ASP changed, look it up: */
+ for (unsigned int i = 0; i < as->num_assoc_asps; i++) {
+ assoc = ss7_as_asp_assoc_llist_round_robin(as, &as->last_asp_idx_sent);
+ if (assoc && osmo_ss7_asp_active(assoc->asp))
return assoc->asp;
}
return NULL;
--
To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/42108?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: libosmo-sigtran
Gerrit-Branch: master
Gerrit-Change-Id: I3d480d23591f4bd216293be60b22389b182fd8f3
Gerrit-Change-Number: 42108
Gerrit-PatchSet: 4
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/42112?usp=email )
(
3 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
)Change subject: ss7_as: Optimize ss7_as_asp_assoc_find()
......................................................................
ss7_as: Optimize ss7_as_asp_assoc_find()
Look for counterpart on the object with the shortest list, ie. convert
from O(N) to O(min(N,M)).
This way eg. if we have 100 ASPs on 1 AS, lookup time becomes O(1).
Same if we have eg. 1 ASP serving 100 AS.
Change-Id: I139aede15af6b6a77d19e6fcf6b6abe8ed6599a6
---
M src/ss7_as.c
1 file changed, 14 insertions(+), 2 deletions(-)
Approvals:
Jenkins Builder: Verified
pespin: Looks good to me, approved
osmith: Looks good to me, but someone else must approve
laforge: Looks good to me, but someone else must approve
diff --git a/src/ss7_as.c b/src/ss7_as.c
index e22fc6c..1cc212f 100644
--- a/src/ss7_as.c
+++ b/src/ss7_as.c
@@ -243,8 +243,20 @@
const struct osmo_ss7_asp *asp)
{
struct ss7_as_asp_assoc *assoc;
- llist_for_each_entry(assoc, &as->assoc_asp_list, as_entry) {
- if (assoc->asp == asp)
+ OSMO_ASSERT(as);
+ OSMO_ASSERT(asp);
+
+ /* Optimization: Look for counterpart on the object with the shortest list: */
+ if (as->num_assoc_asps <= asp->num_assoc_as) {
+ llist_for_each_entry(assoc, &as->assoc_asp_list, as_entry) {
+ if (assoc->asp == asp)
+ return assoc;
+ }
+ return NULL;
+ }
+
+ llist_for_each_entry(assoc, &asp->assoc_as_list, asp_entry) {
+ if (assoc->as == as)
return assoc;
}
return NULL;
--
To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/42112?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: libosmo-sigtran
Gerrit-Branch: master
Gerrit-Change-Id: I139aede15af6b6a77d19e6fcf6b6abe8ed6599a6
Gerrit-Change-Number: 42112
Gerrit-PatchSet: 5
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>