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>
pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/42111?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: asp: Introduce asp->assoc_as_list
......................................................................
asp: Introduce asp->assoc_as_list
This way we can iterate easily/quickly the AS served by a given ASP.
This in turn allows simplifying some code since we cache the amount of
AS served by the ASP at any time, so we save some counting.
Related: SYS#6953
Change-Id: I1ca90748286374109dbb4277cbc7b2337ce2072a
---
M src/ipa.c
M src/sccp_instance.c
M src/ss7_as.c
M src/ss7_as.h
M src/ss7_asp.c
M src/ss7_asp.h
M src/ss7_asp_vty.c
M src/tcap_as_loadshare.c
M src/xua_asp_fsm.c
M src/xua_default_lm_fsm.c
M src/xua_internal.h
M src/xua_shared.c
M tests/vty/osmo_stp_test.vty
M tests/vty/ss7_asp_test.vty
14 files changed, 77 insertions(+), 124 deletions(-)
Approvals:
pespin: Looks good to me, approved
laforge: Looks good to me, but someone else must approve
Jenkins Builder: Verified
osmith: Looks good to me, but someone else must approve
diff --git a/src/ipa.c b/src/ipa.c
index 6cf7104..29dc5c0 100644
--- a/src/ipa.c
+++ b/src/ipa.c
@@ -169,22 +169,6 @@
return rc;
}
-struct osmo_ss7_as *ipa_find_as_for_asp(struct osmo_ss7_asp *asp)
-{
- struct osmo_ss7_as *as;
-
- /* in the IPA case, we assume there is a 1:1 mapping between the
- * ASP and the AS. An AS without ASP means there is no
- * connection, and an ASP without AS means that we don't (yet?)
- * know the identity of the peer */
-
- llist_for_each_entry(as, &asp->inst->as_list, list) {
- if (osmo_ss7_as_has_asp(as, asp))
- return as;
- }
- return NULL;
-}
-
/* Patch a SCCP message and add point codes to Called/Calling Party (if missing) */
static struct msgb *patch_sccp_with_pc(const struct osmo_ss7_asp *asp, const struct msgb *sccp_msg_in,
uint32_t opc, uint32_t dpc)
@@ -254,7 +238,7 @@
enum ipaccess_proto ipa_proto = osmo_ipa_msgb_cb_proto(msg);
struct m3ua_data_hdr data_hdr;
struct xua_msg *xua = NULL;
- struct osmo_ss7_as *as = ipa_find_as_for_asp(asp);
+ struct osmo_ss7_as *as = ss7_asp_get_first_as(asp);
uint32_t opc, dpc;
if (!as) {
diff --git a/src/sccp_instance.c b/src/sccp_instance.c
index 6388b4b..d6937d6 100644
--- a/src/sccp_instance.c
+++ b/src/sccp_instance.c
@@ -562,18 +562,6 @@
* Convenience function for CLIENT
***********************************************************************/
- /* Returns whether AS is already associated to any AS.
- * Helper function for osmo_sccp_simple_client_on_ss7_id(). */
-static bool asp_serves_some_as(const struct osmo_ss7_asp *asp)
-{
- struct osmo_ss7_as *as_i;
- llist_for_each_entry(as_i, &asp->inst->as_list, list) {
- if (osmo_ss7_as_has_asp(as_i, asp))
- return true;
- }
- return false;
-}
-
/*! \brief request an sccp client instance
* \param[in] ctx talloc context
* \param[in] ss7_id of the SS7/CS7 instance
@@ -695,7 +683,7 @@
llist_for_each_entry(asp_i, &ss7->asp_list, list) {
if (asp_i->cfg.proto != prot)
continue;
- if (asp_serves_some_as(asp_i)) {
+ if (asp_i->num_assoc_as > 0) {
/* This ASP is already on another AS.
* If it was on this AS, we'd have found it above. */
continue;
diff --git a/src/ss7_as.c b/src/ss7_as.c
index 8a5c1a1..e22fc6c 100644
--- a/src/ss7_as.c
+++ b/src/ss7_as.c
@@ -65,7 +65,9 @@
assoc->as = as;
assoc->asp = asp;
llist_add_tail(&assoc->as_entry, &as->assoc_asp_list);
+ llist_add_tail(&assoc->asp_entry, &asp->assoc_as_list);
as->num_assoc_asps++;
+ asp->num_assoc_as++;
return assoc;
}
@@ -74,6 +76,8 @@
{
llist_del(&assoc->as_entry);
assoc->as->num_assoc_asps--;
+ llist_del(&assoc->asp_entry);
+ assoc->asp->num_assoc_as--;
talloc_free(assoc);
}
diff --git a/src/ss7_as.h b/src/ss7_as.h
index db219e0..2e7f484 100644
--- a/src/ss7_as.h
+++ b/src/ss7_as.h
@@ -86,6 +86,8 @@
struct ss7_as_asp_assoc {
/* Entry in (struct osmo_ss7_as*)->assoc_asp_list */
struct llist_head as_entry;
+ /* Entry in (struct osmo_ss7_asp*)->assoc_as_list */
+ struct llist_head asp_entry;
struct osmo_ss7_as *as; /* backpointer */
struct osmo_ss7_asp *asp; /* backpointer */
};
diff --git a/src/ss7_asp.c b/src/ss7_asp.c
index 5e96519..9b8f164 100644
--- a/src/ss7_asp.c
+++ b/src/ss7_asp.c
@@ -742,6 +742,7 @@
}
rate_ctr_group_set_name(asp->ctrg, name);
asp->inst = inst;
+ INIT_LLIST_HEAD(&asp->assoc_as_list);
/* ASP in "no shutdown" state by default: */
asp->cfg.adm_state = OSMO_SS7_ASP_ADM_S_ENABLED;
ss7_asp_peer_init(&asp->cfg.remote);
@@ -769,7 +770,7 @@
void osmo_ss7_asp_destroy(struct osmo_ss7_asp *asp)
{
- struct osmo_ss7_as *as, *as2;
+ struct ss7_as_asp_assoc *assoc, *assoc2;
OSMO_ASSERT(ss7_initialized);
LOGPASP(asp, DLSS7, LOGL_INFO, "Destroying ASP\n");
@@ -784,8 +785,8 @@
/* Unlink from all ASs we are part of.
* Some RKM-dynamically allocated ASs may be freed as a result from this: */
- llist_for_each_entry_safe(as, as2, &asp->inst->as_list, list)
- ss7_as_del_asp(as, asp);
+ llist_for_each_entry_safe(assoc, assoc2, &asp->assoc_as_list, asp_entry)
+ ss7_as_del_asp(assoc->as, asp);
/* unlink from ss7_instance */
asp->inst = NULL;
@@ -1552,13 +1553,12 @@
const struct osmo_ss7_as *excl_as, bool network_byte_order)
{
unsigned int count = 0;
- struct osmo_ss7_as *as;
+ struct ss7_as_asp_assoc *assoc;
- llist_for_each_entry(as, &asp->inst->as_list, list) {
+ llist_for_each_entry(assoc, &asp->assoc_as_list, asp_entry) {
+ struct osmo_ss7_as *as = assoc->as;
if (as == excl_as)
continue;
- if (!osmo_ss7_as_has_asp(as, asp))
- continue;
if (as->cfg.routing_key.context == 0)
continue;
if (count >= rctx_size)
@@ -1586,6 +1586,17 @@
return _ss7_asp_get_all_rctx(asp, rctx, rctx_size, excl_as, false);
}
+/* Get first AS in the ASP, or NULL if no AS associated.
+ * This is useful for instance in IPA code, where we assume only up to 1 AS is configured per ASP. */
+struct osmo_ss7_as *ss7_asp_get_first_as(const struct osmo_ss7_asp *asp)
+{
+ struct ss7_as_asp_assoc *assoc;
+ assoc = llist_first_entry_or_null(&asp->assoc_as_list, struct ss7_as_asp_assoc, asp_entry);
+ if (!assoc)
+ return NULL;
+ return assoc->as;
+}
+
/* determine the osmo_ss7_as_traffic_mode to be used by this ASP; will
* iterate over all AS configured for this ASP. If they're compatible,
* a single traffic mode is returned as enum osmo_ss7_as_traffic_mode.
@@ -1593,12 +1604,11 @@
* configured, -1 is returned */
int ss7_asp_determine_traf_mode(const struct osmo_ss7_asp *asp)
{
- const struct osmo_ss7_as *as;
+ const struct ss7_as_asp_assoc *assoc;
int tmode = -1;
- llist_for_each_entry(as, &asp->inst->as_list, list) {
- if (!osmo_ss7_as_has_asp(as, asp))
- continue;
+ llist_for_each_entry(assoc, &asp->assoc_as_list, asp_entry) {
+ const struct osmo_ss7_as *as = assoc->as;
/* we only care about traffic modes explicitly set */
if (!as->cfg.mode_set_by_vty)
continue;
diff --git a/src/ss7_asp.h b/src/ss7_asp.h
index 80a0a8a..0d047cb 100644
--- a/src/ss7_asp.h
+++ b/src/ss7_asp.h
@@ -55,6 +55,9 @@
struct osmo_ss7_asp {
/*! entry in \ref osmo_ss7_instance.asp_list */
struct llist_head list;
+ struct llist_head assoc_as_list; /* list of struct ss7_as_asp_assoc */
+ unsigned int num_assoc_as; /* amount of ss7_as_asp_assoc/ss7_as in as_list */
+
struct osmo_ss7_instance *inst;
/*! ASP FSM */
@@ -187,6 +190,7 @@
const struct osmo_ss7_as *excl_as);
unsigned int ss7_asp_get_all_rctx_be(const struct osmo_ss7_asp *asp, uint32_t *rctx, unsigned int rctx_size,
const struct osmo_ss7_as *excl_as);
+struct osmo_ss7_as *ss7_asp_get_first_as(const struct osmo_ss7_asp *asp);
int ss7_asp_determine_traf_mode(const struct osmo_ss7_asp *asp);
diff --git a/src/ss7_asp_vty.c b/src/ss7_asp_vty.c
index 6731398..241863a 100644
--- a/src/ss7_asp_vty.c
+++ b/src/ss7_asp_vty.c
@@ -116,6 +116,24 @@
xua_tx_snm_daud(asp, rctx, num_rctx, &aff_pc, 1, "VTY");
}
+static char *as_list_for_asp(const struct osmo_ss7_asp *asp, char *buf, size_t buf_len)
+{
+ struct osmo_strbuf sb = { .buf = buf, .len = buf_len };
+ const struct ss7_as_asp_assoc *assoc;
+ unsigned int count = 0;
+
+ if (asp->num_assoc_as == 0) {
+ OSMO_STRBUF_PRINTF(sb, "?");
+ return buf;
+ }
+
+ llist_for_each_entry(assoc, &asp->assoc_as_list, asp_entry) {
+ OSMO_STRBUF_PRINTF(sb, "%s%s", count != 0 ? "," : "", assoc->as->cfg.name);
+ count++;
+ }
+ return buf;
+}
+
DEFUN_ATTR(cs7_asp_audit, cs7_asp_audit_cmd,
"cs7 instance <0-15> asp NAME audit point-code POINT_CODE",
CS7_STR "Instance related commands\n" "SS7 Instance Number\n"
@@ -232,7 +250,6 @@
struct osmo_ss7_instance *inst = vty->index;
const char *name = argv[0];
struct osmo_ss7_asp *asp;
- struct osmo_ss7_as *as;
asp = osmo_ss7_asp_find_by_name(inst, name);
if (!asp) {
@@ -240,13 +257,12 @@
return CMD_WARNING;
}
- llist_for_each_entry(as, &inst->as_list, list) {
- if (osmo_ss7_as_has_asp(as, asp)) {
- vty_out(vty, "%% ASP '%s' currently configured in AS '%s'. "
- "You must first remove the ASP from the AS configuration%s",
- name, as->cfg.name, VTY_NEWLINE);
- return CMD_WARNING;
- }
+ if (asp->num_assoc_as > 0) {
+ char as_buf[512];
+ vty_out(vty, "%% ASP '%s' currently configured in %u AS: '%s'. "
+ "You must first remove the ASP from the AS configuration%s",
+ name, asp->num_assoc_as, as_list_for_asp(asp, as_buf, sizeof(as_buf)), VTY_NEWLINE);
+ return CMD_WARNING;
}
osmo_ss7_asp_destroy(asp);
@@ -871,24 +887,6 @@
}
}
-static char *as_list_for_asp(const struct osmo_ss7_asp *asp, char *buf, size_t buf_len)
-{
- struct osmo_strbuf sb = { .buf = buf, .len = buf_len };
- const struct osmo_ss7_as *as;
- unsigned int count = 0;
- llist_for_each_entry(as, &asp->inst->as_list, list) {
- if (!osmo_ss7_as_has_asp(as, asp))
- continue;
- OSMO_STRBUF_PRINTF(sb, "%s%s", count != 0 ? "," : "", as->cfg.name);
- count++;
- break;
- }
-
- if (count == 0)
- OSMO_STRBUF_PRINTF(sb, "?");
- return buf;
-}
-
/* Similar to osmo_sock_multiaddr_get_name_buf(), but aimed at listening sockets (only local part): */
static char *get_sockname_buf(char *buf, size_t buf_len, int fd, int proto, bool local)
{
diff --git a/src/tcap_as_loadshare.c b/src/tcap_as_loadshare.c
index 356a982..9c969d3 100644
--- a/src/tcap_as_loadshare.c
+++ b/src/tcap_as_loadshare.c
@@ -716,7 +716,11 @@
goto out;
}
- as = ipa_find_as_for_asp(asp);
+ /* in the IPA case, we assume there is a 1:1 mapping between the
+ * ASP and the AS. An AS without ASP means there is no
+ * connection, and an ASP without AS means that we don't (yet?)
+ * know the identity of the peer */
+ as = ss7_asp_get_first_as(asp);
if (!as) {
LOGPASP(asp, DLTCAP, LOGL_ERROR, "Rx message for IPA ASP without AS?!\n");
rc = -ENOENT;
diff --git a/src/xua_asp_fsm.c b/src/xua_asp_fsm.c
index 32986fc..4204e31 100644
--- a/src/xua_asp_fsm.c
+++ b/src/xua_asp_fsm.c
@@ -394,14 +394,10 @@
{
struct xua_asp_fsm_priv *xafp = fi->priv;
struct osmo_ss7_asp *asp = xafp->asp;
- struct osmo_ss7_instance *inst = asp->inst;
- struct osmo_ss7_as *as;
+ struct ss7_as_asp_assoc *assoc;
- llist_for_each_entry(as, &inst->as_list, list) {
- if (!osmo_ss7_as_has_asp(as, asp))
- continue;
- osmo_fsm_inst_dispatch(as->fi, event, data);
- }
+ llist_for_each_entry(assoc, &asp->assoc_as_list, asp_entry)
+ osmo_fsm_inst_dispatch(assoc->as->fi, event, data);
}
/* check if expected message was received + stop t_ack */
@@ -483,17 +479,14 @@
static void common_asp_fsm_down_onenter(struct osmo_ss7_asp *asp)
{
- struct osmo_ss7_as *as, *as2;
- struct osmo_ss7_instance *inst = asp->inst;
+ struct ss7_as_asp_assoc *assoc, *assoc2;
/* First notify all AS associated to the ASP that it went down: */
dispatch_to_all_as(asp->fi, XUA_ASPAS_ASP_DOWN_IND, asp);
/* Implicit clean up tasks: */
- llist_for_each_entry_safe(as, as2, &inst->as_list, list) {
- if (!osmo_ss7_as_has_asp(as, asp))
- continue;
-
+ llist_for_each_entry_safe(assoc, assoc2, &asp->assoc_as_list, asp_entry) {
+ struct osmo_ss7_as *as = assoc->as;
#ifdef WITH_TCAP_LOADSHARING
tcap_as_del_asp(as, asp);
#endif
@@ -702,10 +695,9 @@
if (traf_mode) { /* if the peer has specified a traffic mode at all */
enum osmo_ss7_as_traffic_mode tmode = osmo_ss7_tmode_from_xua(traf_mode);
- llist_for_each_entry(as, &asp->inst->as_list, list) {
- if (!osmo_ss7_as_has_asp(as, asp))
- continue;
-
+ struct ss7_as_asp_assoc *assoc;
+ llist_for_each_entry(assoc, &asp->assoc_as_list, asp_entry) {
+ as = assoc->as;
if (!as->cfg.mode_set_by_peer && !as->cfg.mode_set_by_vty) {
as->cfg.mode = tmode;
LOGPAS(as, DLSS7, LOGL_INFO,
@@ -1531,7 +1523,7 @@
{
struct osmo_fsm_inst *fi;
struct ipa_asp_fsm_priv *iafp;
- struct osmo_ss7_as *as = ipa_find_as_for_asp(asp);
+ struct osmo_ss7_as *as = ss7_asp_get_first_as(asp);
const char *unit_name;
bool can_start = true;
diff --git a/src/xua_default_lm_fsm.c b/src/xua_default_lm_fsm.c
index 11dd32e..1c8df3e 100644
--- a/src/xua_default_lm_fsm.c
+++ b/src/xua_default_lm_fsm.c
@@ -155,21 +155,6 @@
#define ENSURE_SG_OR_IPSP(fi, event) \
ENSURE_ROLE_COND(fi, event, _role == OSMO_SS7_ASP_ROLE_SG || _role == OSMO_SS7_ASP_ROLE_IPSP)
-static struct osmo_ss7_as *find_first_as_in_asp(struct osmo_ss7_asp *asp)
-{
- struct osmo_ss7_as *as;
-
- llist_for_each_entry(as, &asp->inst->as_list, list) {
- struct ss7_as_asp_assoc *assoc;
- llist_for_each_entry(assoc, &as->assoc_asp_list, as_entry) {
- if (assoc->asp == asp)
- return as;
- }
- }
-
- return NULL;
-}
-
/* handle an incoming RKM registration response */
static int handle_reg_conf(struct osmo_fsm_inst *fi, uint32_t l_rk_id, uint32_t rctx)
{
@@ -358,7 +343,7 @@
lm_fsm_state_chg(fi, S_RKM_REG);
prim = xua_xlm_prim_alloc(OSMO_XLM_PRIM_M_RK_REG, PRIM_OP_REQUEST);
OSMO_ASSERT(prim);
- as = find_first_as_in_asp(lmp->asp);
+ as = ss7_asp_get_first_as(lmp->asp);
if (!as) {
LOGPFSML(fi, LOGL_ERROR, "Unable to find AS!\n");
ss7_asp_disconnect_stream(lmp->asp);
diff --git a/src/xua_internal.h b/src/xua_internal.h
index 81c8a1b..c8ae79f 100644
--- a/src/xua_internal.h
+++ b/src/xua_internal.h
@@ -147,7 +147,6 @@
struct msgb *ipa_to_msg(struct xua_msg *xua);
int ipa_tx_xua_as(struct osmo_ss7_as *as, struct xua_msg *xua);
int ipa_rx_msg(struct osmo_ss7_asp *asp, struct msgb *msg, uint8_t sls);
-struct osmo_ss7_as *ipa_find_as_for_asp(struct osmo_ss7_asp *asp);
int osmo_isup_party_parse(char *out_digits, const uint8_t *in,
unsigned int in_num_bytes, bool odd);
diff --git a/src/xua_shared.c b/src/xua_shared.c
index 022b8ed..0fa94c4 100644
--- a/src/xua_shared.c
+++ b/src/xua_shared.c
@@ -39,23 +39,6 @@
#include "ss7_internal.h"
#include "xua_internal.h"
-/* if given ASP only has one AS, return that AS */
-static struct osmo_ss7_as *find_single_as_for_asp(const struct osmo_ss7_asp *asp)
-{
- struct osmo_ss7_as *as, *as_found = NULL;
-
- llist_for_each_entry(as, &asp->inst->as_list, list) {
- if (!osmo_ss7_as_has_asp(as, asp))
- continue;
- /* check if we already had found another AS within this ASP -> not unique */
- if (as_found)
- return NULL;
- as_found = as;
- }
-
- return as_found;
-}
-
/* this is why we can use the M3UA constants below in a function shared between M3UA + SUA */
osmo_static_assert(M3UA_ERR_INVAL_ROUT_CTX == SUA_ERR_INVAL_ROUT_CTX, _err_rctx);
osmo_static_assert(M3UA_ERR_NO_CONFGD_AS_FOR_ASP == SUA_ERR_NO_CONFGD_AS_FOR_ASP, _err_as_for_asp);
@@ -94,13 +77,13 @@
}
} else {
/* no explicit routing context; this only works if there is only one AS in the ASP */
- *as = find_single_as_for_asp(asp);
- if (!*as) {
+ if (asp->num_assoc_as != 1) {
LOGPASP(asp, log_ss, LOGL_ERROR,
"%s(): ASP sent M3UA without Routing Context IE but unable to uniquely "
"identify the AS for this message\n", __func__);
return M3UA_ERR_INVAL_ROUT_CTX;
}
+ *as = ss7_asp_get_first_as(asp);
}
return 0;
diff --git a/tests/vty/osmo_stp_test.vty b/tests/vty/osmo_stp_test.vty
index 61cbd66..72eb0de 100644
--- a/tests/vty/osmo_stp_test.vty
+++ b/tests/vty/osmo_stp_test.vty
@@ -657,7 +657,7 @@
No ASP named 'unknown-asp' found
OsmoSTP(config-cs7)# no asp my-asp
-% ASP 'my-asp' currently configured in AS 'my-ass'. You must first remove the ASP from the AS configuration
+% ASP 'my-asp' currently configured in 1 AS: 'my-ass'. You must first remove the ASP from the AS configuration
OsmoSTP(config-cs7)# as my-ass m3ua
OsmoSTP(config-cs7-as)# no asp my-asp
OsmoSTP(config-cs7-as)# exit
diff --git a/tests/vty/ss7_asp_test.vty b/tests/vty/ss7_asp_test.vty
index 0cd0c39..1ff4e36 100644
--- a/tests/vty/ss7_asp_test.vty
+++ b/tests/vty/ss7_asp_test.vty
@@ -502,7 +502,7 @@
No ASP named 'unknown-asp' found
ss7_asp_vty_test(config-cs7)# no asp my-asp
-% ASP 'my-asp' currently configured in AS 'my-ass'. You must first remove the ASP from the AS configuration
+% ASP 'my-asp' currently configured in 1 AS: 'my-ass'. You must first remove the ASP from the AS configuration
ss7_asp_vty_test(config-cs7)# as my-ass m3ua
ss7_asp_vty_test(config-cs7-as)# no asp my-asp
ss7_asp_vty_test(config-cs7-as)# exit
--
To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/42111?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: I1ca90748286374109dbb4277cbc7b2337ce2072a
Gerrit-Change-Number: 42111
Gerrit-PatchSet: 5
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: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>