pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/40197?usp=email )
Change subject: Implement ASP adm state shutdown
......................................................................
Implement ASP adm state shutdown
These commands are used to tweak administrative use of a given ASP,
tearing down the existing SCTP/TCP connection in the process of needed,
plus:
* In the case of SCTP client: avoid reconnecting until administratively
enabled again.
* In the case of SCTP server: Immediately close incoming connections for
that ASP until administratively enabled again.
Related: OS#6752
Change-Id: I7e4eedb65c4f2952f8b39ca4c539ca2f40e9946c
---
M include/osmocom/sigtran/osmo_ss7.h
M src/osmo_ss7_asp.c
M src/osmo_ss7_vty.c
M src/osmo_ss7_xua_srv.c
M src/ss7_asp.h
M tests/vty/osmo_stp_route_prio.vty
M tests/vty/osmo_stp_test.vty
7 files changed, 121 insertions(+), 9 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-sigtran refs/changes/97/40197/1
diff --git a/include/osmocom/sigtran/osmo_ss7.h b/include/osmocom/sigtran/osmo_ss7.h
index 0bde3d9..dc9aada 100644
--- a/include/osmocom/sigtran/osmo_ss7.h
+++ b/include/osmocom/sigtran/osmo_ss7.h
@@ -248,6 +248,7 @@
/*! in normal operation */
OSMO_SS7_ASP_ADM_S_ENABLED,
};
+extern const struct value_string osmo_ss7_asp_admin_state_names[];
enum osmo_ss7_asp_role {
OSMO_SS7_ASP_ROLE_ASP,
diff --git a/src/osmo_ss7_asp.c b/src/osmo_ss7_asp.c
index f2d511a..56767e9 100644
--- a/src/osmo_ss7_asp.c
+++ b/src/osmo_ss7_asp.c
@@ -124,6 +124,13 @@
{ 0, NULL }
};
+const struct value_string osmo_ss7_asp_admin_state_names[] = {
+ { OSMO_SS7_ASP_ADM_S_SHUTDOWN, "SHUTDOWN" },
+ { OSMO_SS7_ASP_ADM_S_BLOCKED, "BLOCKED" },
+ { OSMO_SS7_ASP_ADM_S_ENABLED, "ENABLED" },
+ { 0, NULL }
+};
+
const struct value_string osmo_ss7_asp_role_names[] = {
{ OSMO_SS7_ASP_ROLE_ASP, "ASP" },
{ OSMO_SS7_ASP_ROLE_SG, "SG" },
@@ -553,6 +560,8 @@
}
rate_ctr_group_set_name(asp->ctrg, name);
asp->inst = inst;
+ /* ASP in "no shutdown" state by default: */
+ asp->cfg.adm_state = OSMO_SS7_ASP_ADM_S_ENABLED;
ss7_asp_peer_init(&asp->cfg.remote);
asp->cfg.remote.port = remote_port;
ss7_asp_peer_init(&asp->cfg.local);
@@ -746,6 +755,12 @@
return rc;
OSMO_ASSERT(asp->fi);
+ if (asp->cfg.adm_state == OSMO_SS7_ASP_ADM_S_SHUTDOWN) {
+ LOGPASP(asp, DLSS7, LOGL_NOTICE, "Skipping start for ASP in administrative state %s\n",
+ get_value_string(osmo_ss7_asp_admin_state_names, OSMO_SS7_ASP_ADM_S_SHUTDOWN));
+ return 0;
+ }
+
/* Now start the new stream: */
if (asp->cfg.is_server) {
@@ -1014,8 +1029,11 @@
static int xua_cli_close_and_reconnect(struct osmo_stream_cli *cli)
{
+ struct osmo_ss7_asp *asp = osmo_stream_cli_get_data(cli);
+ LOGPASP(asp, DLSS7, LOGL_NOTICE, "Closing and reconnecting ASP\n");
xua_cli_close(cli);
- osmo_stream_cli_reconnect(cli);
+ if (asp->cfg.adm_state != OSMO_SS7_ASP_ADM_S_SHUTDOWN)
+ osmo_stream_cli_reconnect(cli);
return 0;
}
diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c
index bf3bec2..41872fe 100644
--- a/src/osmo_ss7_vty.c
+++ b/src/osmo_ss7_vty.c
@@ -1113,6 +1113,9 @@
asp->cfg.role = OSMO_SS7_ASP_ROLE_SG;
}
+ /* Reset value, will be checked at osmo_ss7_vty_go_parent() */
+ asp->cfg.explicit_shutdown_state_by_vty_since_node_enter = false;
+
vty->node = L_CS7_ASP_NODE;
vty->index = asp;
vty->index_sub = &asp->cfg.description;
@@ -1424,9 +1427,33 @@
"Terminates SCTP association; New associations will be rejected\n",
CMD_ATTR_NODE_EXIT)
{
- /* TODO */
- vty_out(vty, "Not supported yet%s", VTY_NEWLINE);
- return CMD_WARNING;
+ struct osmo_ss7_asp *asp = vty->index;
+
+ LOGPASP(asp, DLSS7, LOGL_NOTICE, "Applying Adm State change: %s -> %s\n",
+ get_value_string(osmo_ss7_asp_admin_state_names, asp->cfg.adm_state),
+ get_value_string(osmo_ss7_asp_admin_state_names, OSMO_SS7_ASP_ADM_S_SHUTDOWN));
+
+ asp->cfg.explicit_shutdown_state_by_vty_since_node_enter = true;
+ asp->cfg.adm_state = OSMO_SS7_ASP_ADM_S_SHUTDOWN;
+ ss7_asp_restart_after_reconfigure(asp);
+ return CMD_SUCCESS;
+}
+
+DEFUN_ATTR(asp_no_shutdown, asp_no_shutdown_cmd,
+ "no shutdown",
+ NO_STR "Terminates SCTP association; New associations will be rejected\n",
+ CMD_ATTR_NODE_EXIT)
+{
+ struct osmo_ss7_asp *asp = vty->index;
+
+ LOGPASP(asp, DLSS7, LOGL_NOTICE, "Applying Adm State change: %s -> %s\n",
+ get_value_string(osmo_ss7_asp_admin_state_names, asp->cfg.adm_state),
+ get_value_string(osmo_ss7_asp_admin_state_names, OSMO_SS7_ASP_ADM_S_ENABLED));
+
+ asp->cfg.explicit_shutdown_state_by_vty_since_node_enter = true;
+ asp->cfg.adm_state = OSMO_SS7_ASP_ADM_S_ENABLED;
+ ss7_asp_restart_after_reconfigure(asp);
+ return CMD_SUCCESS;
}
DEFUN_ATTR(asp_quirk, asp_quirk_cmd,
@@ -2015,6 +2042,19 @@
vty_out(vty, " quirk %s%s", get_value_string(asp_quirk_names, (1 << i)), VTY_NEWLINE);
}
write_asp_timers(vty, " ", asp);
+
+ switch (asp->cfg.adm_state) {
+ case OSMO_SS7_ASP_ADM_S_SHUTDOWN:
+ vty_out(vty, " shutdown%s", VTY_NEWLINE);
+ break;
+ case OSMO_SS7_ASP_ADM_S_BLOCKED:
+ vty_out(vty, " blocked%s", VTY_NEWLINE);
+ break;
+ case OSMO_SS7_ASP_ADM_S_ENABLED:
+ /* Default, no need to print: */
+ vty_out(vty, " no shutdown%s", VTY_NEWLINE);
+ break;
+ }
}
@@ -3282,7 +3322,26 @@
switch (vty->node) {
case L_CS7_ASP_NODE:
asp = vty->index;
- ss7_asp_restart_after_reconfigure(asp);
+ if (asp->cfg.explicit_shutdown_state_by_vty_since_node_enter) {
+ /* Interactive VTY, inform of new behavior upon use of new '[no] shutdown' commands: */
+ if (vty->type != VTY_FILE)
+ vty_out(vty, "%% NOTE: Skipping automatic restart of ASP since an explicit '[no] shutdown' command was entered%s", VTY_NEWLINE);
+ asp->cfg.explicit_shutdown_state_by_vty_since_node_enter = false;
+ } else if (vty->type == VTY_FILE) {
+ /* Make sure config reading is backward compatible by starting the ASP if no explicit 'no shutdown' is read: */
+ vty_out(vty,
+ "%% VTY node 'asp' without a '[no] shutdown' command at the end is deprecated, "
+ "please make sure you update your cfg file for future compatibility.%s",
+ VTY_NEWLINE);
+ ss7_asp_restart_after_reconfigure(asp);
+ } else {
+ /* Interactive VTY without '[no] shutdown' explicit cmd, remind the user that we are no
+ * longer automatically restarting the ASP when going out of the "asp" node: */
+ vty_out(vty,
+ "%% NOTE: Make sure to use '[no] shutdown' command in 'asp' node "
+ "in order to restart the ASP for new configs to be applied.%s",
+ VTY_NEWLINE);
+ }
vty->node = L_CS7_NODE;
vty->index = asp->inst;
break;
@@ -3431,12 +3490,13 @@
install_lib_element(L_CS7_ASP_NODE, &asp_sctp_role_cmd);
install_lib_element(L_CS7_ASP_NODE, &asp_sctp_param_init_cmd);
install_lib_element(L_CS7_ASP_NODE, &asp_no_sctp_param_init_cmd);
- install_lib_element(L_CS7_ASP_NODE, &asp_block_cmd);
- install_lib_element(L_CS7_ASP_NODE, &asp_shutdown_cmd);
install_lib_element(L_CS7_ASP_NODE, &asp_quirk_cmd);
install_lib_element(L_CS7_ASP_NODE, &asp_no_quirk_cmd);
gen_asp_timer_cmd_strs(&asp_timer_cmd);
install_lib_element(L_CS7_ASP_NODE, &asp_timer_cmd);
+ install_lib_element(L_CS7_ASP_NODE, &asp_block_cmd);
+ install_lib_element(L_CS7_ASP_NODE, &asp_shutdown_cmd);
+ install_lib_element(L_CS7_ASP_NODE, &asp_no_shutdown_cmd);
install_node(&as_node, NULL);
install_lib_element_ve(&show_cs7_as_cmd);
diff --git a/src/osmo_ss7_xua_srv.c b/src/osmo_ss7_xua_srv.c
index 5483aae..893797a 100644
--- a/src/osmo_ss7_xua_srv.c
+++ b/src/osmo_ss7_xua_srv.c
@@ -74,6 +74,16 @@
LOGP(DLSS7, LOGL_INFO, "%s: New %s connection accepted\n", sock_name, proto_name);
+ asp = ss7_asp_find_by_socket_addr(fd, oxs->cfg.trans_proto);
+ if (asp && asp->cfg.adm_state == OSMO_SS7_ASP_ADM_S_SHUTDOWN) {
+ LOGPASP(asp, DLSS7, LOGL_NOTICE,
+ "Reject incoming new connection from %s for ASP in adm state %s\n",
+ sock_name, get_value_string(osmo_ss7_asp_admin_state_names, asp->cfg.adm_state));
+ close(fd);
+ talloc_free(sock_name);
+ return 0;
+ }
+
srv = osmo_stream_srv_create2(oxs, link, fd, NULL);
if (!srv) {
LOGP(DLSS7, LOGL_ERROR, "%s: Unable to create stream server "
@@ -107,7 +117,6 @@
}
osmo_stream_srv_set_closed_cb(srv, ss7_asp_xua_srv_conn_closed_cb);
- asp = ss7_asp_find_by_socket_addr(fd, oxs->cfg.trans_proto);
if (asp) {
LOGP(DLSS7, LOGL_INFO, "%s: matched connection to ASP %s\n",
sock_name, asp->cfg.name);
diff --git a/src/ss7_asp.h b/src/ss7_asp.h
index 5dee90a..2e25f97 100644
--- a/src/ss7_asp.h
+++ b/src/ss7_asp.h
@@ -87,6 +87,12 @@
enum osmo_ss7_asp_role role;
bool role_set_by_vty;
bool trans_role_set_by_vty;
+ /* Used internally by "asp" node to figure out if "no shutdown"
+ * was done explicitly, in order to avoid automatic asp
+ * reconfiguring/restart at go_parent().
+ * Can be dropped in the future once we make sure everybody uses
+ * "[no] shutdown" explicitly in cfg files. */
+ bool explicit_shutdown_state_by_vty_since_node_enter;
struct osmo_ss7_asp_peer local;
struct osmo_ss7_asp_peer remote;
diff --git a/tests/vty/osmo_stp_route_prio.vty b/tests/vty/osmo_stp_route_prio.vty
index b993cbb..1a3b516 100644
--- a/tests/vty/osmo_stp_route_prio.vty
+++ b/tests/vty/osmo_stp_route_prio.vty
@@ -6,15 +6,21 @@
OsmoSTP(config-cs7)# asp asp1 2905 54321 m3ua
OsmoSTP(config-cs7-asp)# remote-ip 127.0.0.110
OsmoSTP(config-cs7-asp)# local-ip 27.0.0.1
+OsmoSTP(config-cs7-asp)# no shutdown
OsmoSTP(config-cs7-asp)# exit
+% NOTE: Skipping automatic restart of ASP since an explicit '[no] shutdown' command was entered
OsmoSTP(config-cs7)# asp asp2 2905 54321 m3ua
OsmoSTP(config-cs7-asp)# remote-ip 127.0.0.120
OsmoSTP(config-cs7-asp)# local-ip 27.0.0.1
+OsmoSTP(config-cs7-asp)# no shutdown
OsmoSTP(config-cs7-asp)# exit
+% NOTE: Skipping automatic restart of ASP since an explicit '[no] shutdown' command was entered
OsmoSTP(config-cs7)# asp asp3 2905 54321 m3ua
OsmoSTP(config-cs7-asp)# remote-ip 127.0.0.130
OsmoSTP(config-cs7-asp)# local-ip 27.0.0.1
+OsmoSTP(config-cs7-asp)# no shutdown
OsmoSTP(config-cs7-asp)# exit
+% NOTE: Skipping automatic restart of ASP since an explicit '[no] shutdown' command was entered
OsmoSTP(config-cs7)# as as1 m3ua
OsmoSTP(config-cs7-as)# asp asp1
OsmoSTP(config-cs7-as)# routing-key 56 0.1.2
@@ -36,16 +42,19 @@
remote-ip 127.0.0.110
role sg
sctp-role server
+ no shutdown
asp asp2 2905 54321 m3ua
local-ip 27.0.0.1
remote-ip 127.0.0.120
role sg
sctp-role server
+ no shutdown
asp asp3 2905 54321 m3ua
local-ip 27.0.0.1
remote-ip 127.0.0.130
role sg
sctp-role server
+ no shutdown
as as1 m3ua
asp asp1
routing-key 56 0.1.2
diff --git a/tests/vty/osmo_stp_test.vty b/tests/vty/osmo_stp_test.vty
index e56e0ff..de852e1 100644
--- a/tests/vty/osmo_stp_test.vty
+++ b/tests/vty/osmo_stp_test.vty
@@ -283,8 +283,12 @@
transport-role (client|server)
sctp-param init (num-ostreams|max-instreams|max-attempts|timeout) <0-65535>
no sctp-param init (num-ostreams|max-instreams|max-attempts|timeout)
+ quirk (no_notify|daud_in_asp|snm_inactive)
+ no quirk (no_notify|daud_in_asp|snm_inactive)
+ timer lm (wait_asp_up|wait_notify|wait_notify_rkm|wait_rk_reg_resp) <1-999999>
block
shutdown
+ no shutdown
...
OsmoSTP(config-cs7-asp)# ?
@@ -297,6 +301,8 @@
role Specify the xUA role for this ASP
transport-role Specify the transport layer role for this ASP
sctp-param Configure SCTP parameters
+ quirk Enable quirk to work around interop issues
+ timer Configure ASP default timer values
block Allows a SCTP Association with ASP, but doesn't let it become active
shutdown Terminates SCTP association; New associations will be rejected
...
@@ -305,6 +311,7 @@
...
sctp-param Configure SCTP parameters
quirk Disable quirk to work around interop issues
+ shutdown Terminates SCTP association; New associations will be rejected
...
OsmoSTP(config-cs7-asp)# remote-ip 127.0.0.200
@@ -351,8 +358,9 @@
remote-ip 127.0.0.201
...
end
+OsmoSTP(config-cs7-asp)# no shutdown
OsmoSTP(config-cs7-asp)# exit
-
+% NOTE: Skipping automatic restart of ASP since an explicit '[no] shutdown' command was entered
OsmoSTP(config-cs7)# as my-ass m3ua
OsmoSTP(config-cs7-as)# list
...
@@ -594,6 +602,7 @@
remote-ip 127.0.0.201
role sg
sctp-role server
+ no shutdown
as my-ass m3ua
asp my-asp
routing-key 0 3.2.1
--
To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/40197?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: libosmo-sigtran
Gerrit-Branch: master
Gerrit-Change-Id: I7e4eedb65c4f2952f8b39ca4c539ca2f40e9946c
Gerrit-Change-Number: 40197
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Hello Jenkins Builder,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/40192?usp=email
to look at the new patch set (#2).
The following approvals got outdated and were removed:
Verified+1 by Jenkins Builder
Change subject: stp: Store asp name in array of m3ua cfgs
......................................................................
stp: Store asp name in array of m3ua cfgs
This way we keep STP specific config in one place instead of having to
figure out the ASP name on each test where we want to modify that ASP.
Change-Id: I1d5d9113dc95a8da911a7a99260c9bfe6e9de7c9
---
M stp/STP_Tests_M3UA.ttcn
1 file changed, 23 insertions(+), 6 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/92/40192/2
--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/40192?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I1d5d9113dc95a8da911a7a99260c9bfe6e9de7c9
Gerrit-Change-Number: 40192
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/40194?usp=email )
Change subject: asp: Make sure previous stream_srv is immediatelly destroyed when requested
......................................................................
asp: Make sure previous stream_srv is immediatelly destroyed when requested
This will be needed when the asp is in SCTP=server mode and we request
it to shutdown/restart.
Change-Id: I8edd64234654ba987f35de2d7ad610e96bda27eb
---
M src/osmo_ss7_asp.c
1 file changed, 6 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-sigtran refs/changes/94/40194/1
diff --git a/src/osmo_ss7_asp.c b/src/osmo_ss7_asp.c
index 4044003..02dbcb8 100644
--- a/src/osmo_ss7_asp.c
+++ b/src/osmo_ss7_asp.c
@@ -699,6 +699,12 @@
asp->client = NULL;
osmo_stream_cli_destroy(cli);
}
+ if (asp->server) {
+ /* Make sure we close the previous stream right now: */
+ srv = asp->server;
+ asp->server = NULL;
+ osmo_stream_srv_destroy(srv);
+ }
} else {
/* We are in client mode now */
if (asp->server) {
--
To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/40194?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: libosmo-sigtran
Gerrit-Branch: master
Gerrit-Change-Id: I8edd64234654ba987f35de2d7ad610e96bda27eb
Gerrit-Change-Number: 40194
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/40193?usp=email )
Change subject: asp: Make sure asp->{client,server} is nulled before destroy callback
......................................................................
asp: Make sure asp->{client,server} is nulled before destroy callback
disconnect_cb() in case of stream_cli and closed_cb() in case of
stream_srv may call some libosmo-sigtran code. Make sure we don't access
the pointer anymore in that case for safety.
Change-Id: I3f0774eac630c8bc7e9a10f874e1c72763fd14a0
---
M src/osmo_ss7_asp.c
1 file changed, 7 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-sigtran refs/changes/93/40193/1
diff --git a/src/osmo_ss7_asp.c b/src/osmo_ss7_asp.c
index c054369..4044003 100644
--- a/src/osmo_ss7_asp.c
+++ b/src/osmo_ss7_asp.c
@@ -686,22 +686,27 @@
* announce disconnection to upper layers. */
int ss7_asp_disconnect_stream(struct osmo_ss7_asp *asp)
{
+ struct osmo_stream_cli *cli;
+ struct osmo_stream_srv *srv;
+
/* First tear down previous state if existing: */
if (asp->cfg.is_server) {
/* We are in server mode now */
if (asp->client) {
/* if we previously were in client mode,
* destroy it */
- osmo_stream_cli_destroy(asp->client);
+ cli = asp->client;
asp->client = NULL;
+ osmo_stream_cli_destroy(cli);
}
} else {
/* We are in client mode now */
if (asp->server) {
/* if we previously were in server mode,
* destroy it */
- osmo_stream_srv_destroy(asp->server);
+ srv = asp->server;
asp->server = NULL;
+ osmo_stream_srv_destroy(srv);
}
if (asp->client) {
/* Make sure we close the previous stream before starting a new one: */
--
To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/40193?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: libosmo-sigtran
Gerrit-Branch: master
Gerrit-Change-Id: I3f0774eac630c8bc7e9a10f874e1c72763fd14a0
Gerrit-Change-Number: 40193
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Attention is currently required from: daniel, fixeria, laforge, osmith.
pespin has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/40011?usp=email )
Change subject: Tx multiple Routing Contexts in NOTIFY on ASPs serving multiple AS
......................................................................
Patch Set 5:
(1 comment)
This change is ready for review.
Patchset:
PS5:
TTCN3 tests are now passing fine after having new correct expectancies here:
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/40191 stp: Update TC_rkm_unreg_active to expect multiple routing contexts
IMHO this patch can be merged now.
--
To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/40011?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: libosmo-sigtran
Gerrit-Branch: master
Gerrit-Change-Id: I646301ec3d08ef98f227cf4d19da1039e40cedd2
Gerrit-Change-Number: 40011
Gerrit-PatchSet: 5
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-CC: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: osmith <osmith(a)sysmocom.de>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: daniel <dwillmann(a)sysmocom.de>
Gerrit-Comment-Date: Fri, 02 May 2025 14:13:09 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/40190?usp=email )
Change subject: xua_asp_fsm: Reuse ss7_asp_get_all_rctx_be() in xua_msg_add_asp_rctx()
......................................................................
xua_asp_fsm: Reuse ss7_asp_get_all_rctx_be() in xua_msg_add_asp_rctx()
Change-Id: I6fe4f388b11991e7c7396c9d632b376e8591a8f3
---
M src/xua_asp_fsm.c
1 file changed, 5 insertions(+), 23 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-sigtran refs/changes/90/40190/1
diff --git a/src/xua_asp_fsm.c b/src/xua_asp_fsm.c
index 4603734..11a34b4 100644
--- a/src/xua_asp_fsm.c
+++ b/src/xua_asp_fsm.c
@@ -173,32 +173,14 @@
/* add M3UA_IEI_ROUTE_CTX to xua_msg containig all routing keys of ASs within ASP */
static int xua_msg_add_asp_rctx(struct xua_msg *xua, struct osmo_ss7_asp *asp)
{
- struct osmo_ss7_as *as;
uint32_t rctx[OSMO_SS7_MAX_RCTX_COUNT];
- unsigned int i = 0;
+ unsigned int cnt;
- /* iterate over all ASs and build array of routing contexts */
- llist_for_each_entry(as, &asp->inst->as_list, list) {
- if (!osmo_ss7_as_has_asp(as, asp))
- continue;
- rctx[i++] = htonl(as->cfg.routing_key.context);
- if (i >= ARRAY_SIZE(rctx)-1) {
- break;
- }
- }
- /* add xUA IE with routing contests to the message (if any) */
- if (i) {
- /* bail out (and not add the IE) if there's only one routing context (and hence
- * only one AS) within this ASP, and that routing context is zero, meaning no routing
- * context IE shall be used */
- if (i == 1 && rctx[0] == 0)
- return 0;
-
- xua_msg_add_data(xua, M3UA_IEI_ROUTE_CTX, i*sizeof(uint32_t), (uint8_t *)rctx);
- }
-
+ cnt = ss7_asp_get_all_rctx_be(asp, rctx, ARRAY_SIZE(rctx), NULL);
+ if (cnt > 0)
+ xua_msg_add_data(xua, M3UA_IEI_ROUTE_CTX, cnt*sizeof(uint32_t), (uint8_t *)rctx);
/* return count of routing contexts added */
- return i;
+ return cnt;
}
/* ask the xUA implementation to transmit a specific message */
--
To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/40190?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: libosmo-sigtran
Gerrit-Branch: master
Gerrit-Change-Id: I6fe4f388b11991e7c7396c9d632b376e8591a8f3
Gerrit-Change-Number: 40190
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>