pespin has uploaded this change for review. (
https://gerrit.osmocom.org/c/libosmo-sccp/+/33237 )
Change subject: osmo_sccp_simple_client_on_ss7_id(): Always follow VTY config of ASP if it
was explicitly defined in VTY
......................................................................
osmo_sccp_simple_client_on_ss7_id(): Always follow VTY config of ASP if it was explicitly
defined in VTY
The VTY config defaults are "role sg" and "sctp-role server".
However, if not set explicitly in VTY,
osmo_sccp_simple_client_on_ss7_id() was replacing them to "role asp" and
"sctp-role client".
This is fine if the ASP is not defined/created at the VTY (aka
dynamically created with no config), but if the ASP is defined in the
VTY it becomes really confusing, since it's picking different defaults
than the usual ones.
Hence, follow always the same VTY defaults in
osmo_sccp_simple_client_on_ss7_id().
As a result of this change:
- Programs not defining the ASP over VTY keep the same behavior (ASP is
created with role=asp and sctp-role=client)
- Programs defining ASP over VTY (eg. "asp asp-clnt-msc-0 5000 0 m3ua")
explicitly setting "role" and "sctp-role": keep the same behavior
- Programs defining ASP over VTY but not explicitly setting "role" or
"sctp-role", will get now the usual defaults instead.
So in summary, strange cases where osmo_sccp_simple_client_on_ss7_id()
is used (osmo-bsc, osmo-hnbgw, osmo-msc) and the dynamically created
ASP is created through VTY, then the config file must also explicitly
define the following lines:
role asp
sctp-role client
This patch also changes the "show running-config" VTY cmd to also always
show the configured role and sctp-role values, which are of vital
importance to understand a given setup.
Change-Id: Ie81987265118e48173211f88b27a006115dc62d4
---
M include/osmocom/sigtran/osmo_ss7.h
M src/osmo_ss7_vty.c
M src/sccp_user.c
M tests/vty/ss7_asp_test.vty
4 files changed, 49 insertions(+), 22 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/37/33237/1
diff --git a/include/osmocom/sigtran/osmo_ss7.h b/include/osmocom/sigtran/osmo_ss7.h
index f413983..eff16b9 100644
--- a/include/osmocom/sigtran/osmo_ss7.h
+++ b/include/osmocom/sigtran/osmo_ss7.h
@@ -430,8 +430,6 @@
enum osmo_ss7_asp_admin_state adm_state;
bool is_server;
enum osmo_ss7_asp_role role;
- bool role_set_by_vty;
- bool sctp_role_set_by_vty;
struct osmo_ss7_asp_peer local;
struct osmo_ss7_asp_peer remote;
diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c
index 421ba9c..2a7c53b 100644
--- a/src/osmo_ss7_vty.c
+++ b/src/osmo_ss7_vty.c
@@ -715,8 +715,6 @@
return CMD_WARNING;
} else
OSMO_ASSERT(0);
-
- asp->cfg.role_set_by_vty = true;
return CMD_SUCCESS;
}
@@ -735,8 +733,6 @@
asp->cfg.is_server = true;
else
OSMO_ASSERT(0);
-
- asp->cfg.sctp_role_set_by_vty = true;
return CMD_SUCCESS;
}
@@ -851,12 +847,9 @@
}
if (asp->cfg.qos_class)
vty_out(vty, " qos-class %u%s", asp->cfg.qos_class, VTY_NEWLINE);
- if (asp->cfg.role_set_by_vty) {
- vty_out(vty, " role %s%s",
osmo_str_tolower(get_value_string(osmo_ss7_asp_role_names, asp->cfg.role)),
- VTY_NEWLINE);
- }
- if (asp->cfg.sctp_role_set_by_vty || !asp->cfg.is_server)
- vty_out(vty, " sctp-role %s%s", asp->cfg.is_server ? "server" :
"client", VTY_NEWLINE);
+ vty_out(vty, " role %s%s",
osmo_str_tolower(get_value_string(osmo_ss7_asp_role_names, asp->cfg.role)),
+ VTY_NEWLINE);
+ vty_out(vty, " sctp-role %s%s", asp->cfg.is_server ? "server" :
"client", VTY_NEWLINE);
for (i = 0; i < sizeof(uint32_t) * 8; i++) {
if (!(asp->cfg.quirks & ((uint32_t) 1 << i)))
continue;
diff --git a/src/sccp_user.c b/src/sccp_user.c
index 982f188..aac6ee0 100644
--- a/src/sccp_user.c
+++ b/src/sccp_user.c
@@ -630,6 +630,10 @@
if (!asp)
goto out_rt;
asp_created = true;
+ /* Ensure that the ASP we use is set to sctp-role client. */
+ asp->cfg.is_server = false;
+ /* Ensure that the ASP we use is set to role ASP. */
+ asp->cfg.role = OSMO_SS7_ASP_ROLE_ASP;
if (default_local_ip)
osmo_ss7_asp_peer_set_hosts(&asp->cfg.local, asp, &default_local_ip, 1);
if (default_remote_ip)
@@ -642,11 +646,6 @@
osmo_ss7_as_add_asp(as, asp->cfg.name);
}
- /* Make sure that the sctp-role of this ASP is set to "client" unless the
user
- * made a conscious decision about the role via the VTY */
- if (!asp->cfg.sctp_role_set_by_vty)
- asp->cfg.is_server = false;
-
/* If ASP was configured through VTY it may be explicitly configured as
* SCTP server. It may be a bit confusing since this function is to create
* a "SCCP simple client", but this allows users of this API such as
@@ -667,11 +666,6 @@
}
}
- /* Make sure that the role of this ASP is set to ASP unless the user
- * made a concious decision about the role via the VTY */
- if (!asp->cfg.role_set_by_vty)
- asp->cfg.role = OSMO_SS7_ASP_ROLE_ASP;
-
/* Restart ASP */
if (prot != OSMO_SS7_ASP_PROT_IPA)
osmo_ss7_asp_use_default_lm(asp, LOGL_DEBUG);
diff --git a/tests/vty/ss7_asp_test.vty b/tests/vty/ss7_asp_test.vty
index 14ca25a..bd1c139 100644
--- a/tests/vty/ss7_asp_test.vty
+++ b/tests/vty/ss7_asp_test.vty
@@ -343,6 +343,8 @@
asp my-asp 12345 54321 m3ua
local-ip 127.0.0.100
remote-ip 127.0.0.200
+ role sg
+ sctp-role server
as my-ass m3ua
asp my-asp
routing-key 0 3.2.1
--
To view, visit
https://gerrit.osmocom.org/c/libosmo-sccp/+/33237
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Change-Id: Ie81987265118e48173211f88b27a006115dc62d4
Gerrit-Change-Number: 33237
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: newchange