pespin has submitted this change. (
https://gerrit.osmocom.org/c/libosmo-sigtran/+/40480?usp=email )
Change subject: asp,xua_srv: Apply SCTP sockopts only on SCTP osckets
......................................................................
asp,xua_srv: Apply SCTP sockopts only on SCTP osckets
Otherwise if user somehow configured those paremeters over VTY, they
would end up trying to be applied and most probably fail.
Take the chance to split that really specific code to helper functions
to sanitize a bit some lifecycle code paths.
Change-Id: I013c51efd03a3f5561bf9849c8841b1c7e66c172
---
M src/ss7_asp.c
M src/ss7_xua_srv.c
2 files changed, 58 insertions(+), 34 deletions(-)
Approvals:
Jenkins Builder: Verified
osmith: Looks good to me, but someone else must approve
fixeria: Looks good to me, approved
diff --git a/src/ss7_asp.c b/src/ss7_asp.c
index 71e5627..d7e9b12 100644
--- a/src/ss7_asp.c
+++ b/src/ss7_asp.c
@@ -416,6 +416,34 @@
}
}
+static int asp_client_apply_sctp_init_pars(struct osmo_ss7_asp *asp)
+{
+ uint8_t byte;
+
+ OSMO_ASSERT(asp->client);
+ byte = 1; /*AUTH is needed by ASCONF. enable, don't abort socket creation if AUTH
can't be enabled */
+ osmo_stream_cli_set_param(asp->client,
OSMO_STREAM_CLI_PAR_SCTP_SOCKOPT_AUTH_SUPPORTED, &byte, sizeof(byte));
+ byte = 1; /* enable, don't abort socket creation if ASCONF can't be enabled */
+ osmo_stream_cli_set_param(asp->client,
OSMO_STREAM_CLI_PAR_SCTP_SOCKOPT_ASCONF_SUPPORTED, &byte, sizeof(byte));
+ if (asp->cfg.sctp_init.num_ostreams_present)
+ osmo_stream_cli_set_param(asp->client, OSMO_STREAM_CLI_PAR_SCTP_INIT_NUM_OSTREAMS,
+ &asp->cfg.sctp_init.num_ostreams_value,
+ sizeof(asp->cfg.sctp_init.num_ostreams_value));
+ if (asp->cfg.sctp_init.max_instreams_present)
+ osmo_stream_cli_set_param(asp->client, OSMO_STREAM_CLI_PAR_SCTP_INIT_MAX_INSTREAMS,
+ &asp->cfg.sctp_init.max_instreams_value,
+ sizeof(asp->cfg.sctp_init.max_instreams_value));
+ if (asp->cfg.sctp_init.max_attempts_present)
+ osmo_stream_cli_set_param(asp->client, OSMO_STREAM_CLI_PAR_SCTP_INIT_MAX_ATTEMPTS,
+ &asp->cfg.sctp_init.max_attempts_value,
+ sizeof(asp->cfg.sctp_init.max_attempts_value));
+ if (asp->cfg.sctp_init.max_init_timeo_present)
+ osmo_stream_cli_set_param(asp->client, OSMO_STREAM_CLI_PAR_SCTP_INIT_TIMEOUT,
+ &asp->cfg.sctp_init.max_init_timeo_value,
+ sizeof(asp->cfg.sctp_init.max_init_timeo_value));
+ return 0;
+}
+
/* Set default values for local and remote peer hosts if they are not yet set.
* \param[in] asp ASP for which to set default hosts.
* \returns true if values where changed, false otherwise.
@@ -650,7 +678,6 @@
static int ss7_asp_start_client(struct osmo_ss7_asp *asp)
{
- uint8_t byte;
int rc;
if (!asp->client)
@@ -693,26 +720,10 @@
break;
}
osmo_stream_cli_set_data(asp->client, asp);
- byte = 1; /*AUTH is needed by ASCONF. enable, don't abort socket creation if AUTH
can't be enabled */
- osmo_stream_cli_set_param(asp->client,
OSMO_STREAM_CLI_PAR_SCTP_SOCKOPT_AUTH_SUPPORTED, &byte, sizeof(byte));
- byte = 1; /* enable, don't abort socket creation if ASCONF can't be enabled */
- osmo_stream_cli_set_param(asp->client,
OSMO_STREAM_CLI_PAR_SCTP_SOCKOPT_ASCONF_SUPPORTED, &byte, sizeof(byte));
- if (asp->cfg.sctp_init.num_ostreams_present)
- osmo_stream_cli_set_param(asp->client, OSMO_STREAM_CLI_PAR_SCTP_INIT_NUM_OSTREAMS,
- &asp->cfg.sctp_init.num_ostreams_value,
- sizeof(asp->cfg.sctp_init.num_ostreams_value));
- if (asp->cfg.sctp_init.max_instreams_present)
- osmo_stream_cli_set_param(asp->client, OSMO_STREAM_CLI_PAR_SCTP_INIT_MAX_INSTREAMS,
- &asp->cfg.sctp_init.max_instreams_value,
- sizeof(asp->cfg.sctp_init.max_instreams_value));
- if (asp->cfg.sctp_init.max_attempts_present)
- osmo_stream_cli_set_param(asp->client, OSMO_STREAM_CLI_PAR_SCTP_INIT_MAX_ATTEMPTS,
- &asp->cfg.sctp_init.max_attempts_value,
- sizeof(asp->cfg.sctp_init.max_attempts_value));
- if (asp->cfg.sctp_init.max_init_timeo_present)
- osmo_stream_cli_set_param(asp->client, OSMO_STREAM_CLI_PAR_SCTP_INIT_TIMEOUT,
- &asp->cfg.sctp_init.max_init_timeo_value,
- sizeof(asp->cfg.sctp_init.max_init_timeo_value));
+
+ if (asp->cfg.trans_proto == IPPROTO_SCTP)
+ asp_client_apply_sctp_init_pars(asp);
+
rc = osmo_stream_cli_open(asp->client);
return rc;
}
diff --git a/src/ss7_xua_srv.c b/src/ss7_xua_srv.c
index 893797a..120f165 100644
--- a/src/ss7_xua_srv.c
+++ b/src/ss7_xua_srv.c
@@ -281,6 +281,28 @@
local_port, local_host);
}
+static int ss7_xua_srv_apply_sctp_init_pars(struct osmo_xua_server *xs)
+{
+ uint8_t byte;
+ OSMO_ASSERT(xs->server);
+
+ byte = 1; /*AUTH is needed by ASCONF. enable, don't abort socket creation if AUTH
can't be enabled */
+ osmo_stream_srv_link_set_param(xs->server,
OSMO_STREAM_SRV_LINK_PAR_SCTP_SOCKOPT_AUTH_SUPPORTED,
+ &byte, sizeof(byte));
+ byte = 1; /* enable, don't abort socket creation if ASCONF can't be enabled */
+ osmo_stream_srv_link_set_param(xs->server,
OSMO_STREAM_SRV_LINK_PAR_SCTP_SOCKOPT_ASCONF_SUPPORTED,
+ &byte, sizeof(byte));
+ if (xs->cfg.sctp_init.num_ostreams_present)
+ osmo_stream_srv_link_set_param(xs->server,
OSMO_STREAM_SRV_LINK_PAR_SCTP_INIT_NUM_OSTREAMS,
+ &xs->cfg.sctp_init.num_ostreams_value,
+ sizeof(xs->cfg.sctp_init.num_ostreams_value));
+ if (xs->cfg.sctp_init.max_instreams_present)
+ osmo_stream_srv_link_set_param(xs->server,
OSMO_STREAM_SRV_LINK_PAR_SCTP_INIT_MAX_INSTREAMS,
+ &xs->cfg.sctp_init.max_instreams_value,
+ sizeof(xs->cfg.sctp_init.max_instreams_value));
+ return 0;
+}
+
/*! \brief Set the xUA server to bind/listen to the currently configured ip/port
* \param[in] xs xUA server to operate
* \returns 0 on success, negative value on error.
@@ -290,7 +312,6 @@
{
char buf[512];
int rc;
- uint8_t byte;
const char *proto = get_value_string(osmo_ss7_asp_protocol_vals, xs->cfg.proto);
rc = ss7_asp_peer_snprintf(buf, sizeof(buf), &xs->cfg.local);
@@ -302,18 +323,10 @@
}
/* Applying xUA Server config which may have changed through VTY on the srv_link before
opening it: */
- byte = 1; /*AUTH is needed by ASCONF. enable, don't abort socket creation if AUTH
can't be enabled */
- osmo_stream_srv_link_set_param(xs->server,
OSMO_STREAM_SRV_LINK_PAR_SCTP_SOCKOPT_AUTH_SUPPORTED, &byte, sizeof(byte));
- byte = 1; /* enable, don't abort socket creation if ASCONF can't be enabled */
- osmo_stream_srv_link_set_param(xs->server,
OSMO_STREAM_SRV_LINK_PAR_SCTP_SOCKOPT_ASCONF_SUPPORTED, &byte, sizeof(byte));
- if (xs->cfg.sctp_init.num_ostreams_present)
- osmo_stream_srv_link_set_param(xs->server,
OSMO_STREAM_SRV_LINK_PAR_SCTP_INIT_NUM_OSTREAMS,
- &xs->cfg.sctp_init.num_ostreams_value,
- sizeof(xs->cfg.sctp_init.num_ostreams_value));
- if (xs->cfg.sctp_init.max_instreams_present)
- osmo_stream_srv_link_set_param(xs->server,
OSMO_STREAM_SRV_LINK_PAR_SCTP_INIT_MAX_INSTREAMS,
- &xs->cfg.sctp_init.max_instreams_value,
- sizeof(xs->cfg.sctp_init.max_instreams_value));
+ if (xs->cfg.trans_proto == IPPROTO_SCTP) {
+ if ((rc = ss7_xua_srv_apply_sctp_init_pars(xs)) < 0)
+ LOGP(DLSS7, LOGL_NOTICE, "Failed applying %s Server SCTP INIT parameters\n",
proto);
+ }
return osmo_stream_srv_link_open(xs->server);
}
--
To view, visit
https://gerrit.osmocom.org/c/libosmo-sigtran/+/40480?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: I013c51efd03a3f5561bf9849c8841b1c7e66c172
Gerrit-Change-Number: 40480
Gerrit-PatchSet: 2
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>