From 13a341e813439ae1d4651ee0b61a55c12dfd25d0 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Fri, 8 Sep 2023 16:51:47 +0200 Subject: [PATCH] asp,xua_srv: Use new osmo_stream API to request sockopt SCTP AUTH/ASCONF SUPPORTED Support to enable AUTH/ASCONF in the SCTP socket was added recently in libosmocore and libosmo-netif, in order to support the Peer Primary Address features used by the libosmo-sccp code. The code to request the AUTH/ASCONF support through setsockopt() was internally applied transparently by lisbosmo-netif's osmo_stream. This is not 100% disarable since other users of the library may not need/want that behavior. As a result, libosmo-netif's osmo_stream no longer enables the SCTP AUTH/ASCONF support by default, but it must be enabled through the new osmo_stream_{cli,srv_link}_set_param() API. This change in behavior of the API/implementation can be done because all these new features are pretty new and no release of libosmocore/libosmo-netif/libosmo-sccp has been released yet. Related: SYS#6501 Related: SYS#6558 Depends: libosmo-netif.git Change-Id I2607c1c926a625986cd851adc65dd8b4de83d6ab Change-Id: I16c97fc148792aa3e39b7414899660990c39dfff --- TODO-RELEASE | 2 +- src/osmo_ss7_asp.c | 5 +++++ src/osmo_ss7_xua_srv.c | 8 ++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/TODO-RELEASE b/TODO-RELEASE index 306eed99..172a1f99 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -11,5 +11,5 @@ libosmocore >1.8.0 uses new osmo_prim_operation_name() libosmo-netif > 1.3.0 uses osmo_stream_*_set_name() libosmo-sccp add API osmo_ss7_asp_get_name(), osmo_ss7_asp_get_proto() osmo_sccp_simple_client_on_ss7_id() behavior change: ASPs asp-clnt-* defined through VTY must explicitly configure "role" and "sctp-role" -libosmo-netif > 1.3.0 flag OSMO_STREAM_SCTP_MSG_FLAGS_NOTIFICATION set by osmo_stream_cli_recv() +libosmo-netif > 1.3.0 osmo_stream_srv_link_set_param(), osmo_stream_srv_link_set_param() libosmo-sccp add API osmo_ss7_asp_peer_init(), osmo_ss7_asp_peer_set_hosts2(), osmo_ss7_asp_peer_add_host2() diff --git a/src/osmo_ss7_asp.c b/src/osmo_ss7_asp.c index c2827302..ab01abdc 100644 --- a/src/osmo_ss7_asp.c +++ b/src/osmo_ss7_asp.c @@ -722,6 +722,7 @@ int osmo_ss7_asp_restart(struct osmo_ss7_asp *asp) { int rc; char bufloc[512], bufrem[512]; + uint8_t byte; OSMO_ASSERT(ss7_initialized); osmo_ss7_asp_peer_snprintf(bufloc, sizeof(bufloc), &asp->cfg.local); @@ -758,6 +759,10 @@ int osmo_ss7_asp_restart(struct osmo_ss7_asp *asp) else osmo_stream_cli_set_read_cb(asp->client, xua_cli_read_cb); 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)); rc = osmo_stream_cli_open(asp->client); if (rc < 0) { LOGPASP(asp, DLSS7, LOGL_ERROR, "Unable to open stream" diff --git a/src/osmo_ss7_xua_srv.c b/src/osmo_ss7_xua_srv.c index 04ae893f..57e909a2 100644 --- a/src/osmo_ss7_xua_srv.c +++ b/src/osmo_ss7_xua_srv.c @@ -227,6 +227,7 @@ osmo_ss7_xua_server_bind(struct osmo_xua_server *xs) { char buf[512]; int rc; + uint8_t byte; const char *proto = get_value_string(osmo_ss7_asp_protocol_vals, xs->cfg.proto); rc = osmo_ss7_asp_peer_snprintf(buf, sizeof(buf), &xs->cfg.local); @@ -236,6 +237,13 @@ osmo_ss7_xua_server_bind(struct osmo_xua_server *xs) LOGP(DLSS7, LOGL_INFO, "(Re)binding %s Server to %s\n", proto, buf); } + + /* 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)); + return osmo_stream_srv_link_open(xs->server); }