aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2023-06-08 18:51:02 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2023-06-13 20:07:18 +0200
commit83db938859428ce3835239e2692d93c557b750e1 (patch)
tree84ccda6eb67c51411f29aca01a2ed8b56c5afde3
parent0aff5d101df25978524d52624c7137987820eb1d (diff)
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
-rw-r--r--include/osmocom/sigtran/osmo_ss7.h2
-rw-r--r--src/osmo_ss7_vty.c13
-rw-r--r--src/sccp_user.c14
-rw-r--r--tests/vty/ss7_asp_test.vty2
4 files changed, 9 insertions, 22 deletions
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 @@ struct osmo_ss7_asp {
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 2418428..09e5f0a 100644
--- a/src/osmo_ss7_vty.c
+++ b/src/osmo_ss7_vty.c
@@ -715,8 +715,6 @@ DEFUN_ATTR(asp_role, asp_role_cmd,
return CMD_WARNING;
} else
OSMO_ASSERT(0);
-
- asp->cfg.role_set_by_vty = true;
return CMD_SUCCESS;
}
@@ -735,8 +733,6 @@ DEFUN_ATTR(sctp_role, asp_sctp_role_cmd,
asp->cfg.is_server = true;
else
OSMO_ASSERT(0);
-
- asp->cfg.sctp_role_set_by_vty = true;
return CMD_SUCCESS;
}
@@ -851,12 +847,9 @@ static void write_one_asp(struct vty *vty, struct osmo_ss7_asp *asp, bool show_d
}
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 f1a4203..aac6ee0 100644
--- a/src/sccp_user.c
+++ b/src/sccp_user.c
@@ -630,6 +630,10 @@ osmo_sccp_simple_client_on_ss7_id(void *ctx, uint32_t ss7_id, const char *name,
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_sccp_simple_client_on_ss7_id(void *ctx, uint32_t ss7_id, const char *name,
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 @@ osmo_sccp_simple_client_on_ss7_id(void *ctx, uint32_t ss7_id, const char *name,
}
}
- /* Make sure that the role of this ASP is set to ASP unless the user
- * made a conscious 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 5faabd9..ffa263f 100644
--- a/tests/vty/ss7_asp_test.vty
+++ b/tests/vty/ss7_asp_test.vty
@@ -343,6 +343,8 @@ cs7 instance 0
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