forked from acouzens/open5gs
Introduce new configuration for SCTP streams
SCTP initmsg - Number of output streams : configured(default:30) - Maximum input streams : 65535 - Maximum attempts : 4 - Maximum initial timeout : 8 seconds
This commit is contained in:
parent
3148d4cd67
commit
e18467889c
|
@ -194,6 +194,8 @@ CORE_DECLARE(status_t) tcp_client(sock_id *new, c_sockaddr_t *sa_list);
|
|||
/*
|
||||
* SCTP Socket
|
||||
*/
|
||||
CORE_DECLARE(void) sctp_set_num_ostreams(int sctp_streams);
|
||||
|
||||
CORE_DECLARE(status_t) sctp_socket(sock_id *new, int family, int type);
|
||||
CORE_DECLARE(status_t) sctp_server(sock_id *new,
|
||||
int type, c_sockaddr_t *sa_list);
|
||||
|
|
|
@ -12,8 +12,16 @@ static status_t set_paddrparams(sock_id id, c_uint32_t spp_hbinterval);
|
|||
static status_t set_rtoinfo(sock_id id,
|
||||
c_uint32_t srto_initial, c_uint32_t srto_min, c_uint32_t srto_max);
|
||||
static status_t set_initmsg(sock_id id,
|
||||
c_uint32_t sinit_num_ostreams, c_uint32_t sinit_max_instreams,
|
||||
c_uint32_t sinit_max_attempts, c_uint32_t sinit_max_init_timeo);
|
||||
|
||||
static int sctp_num_ostreams = -1;
|
||||
|
||||
void sctp_set_num_ostreams(int sctp_streams)
|
||||
{
|
||||
sctp_num_ostreams = sctp_streams;
|
||||
}
|
||||
|
||||
status_t sctp_socket(sock_id *new, int family, int type)
|
||||
{
|
||||
status_t rv;
|
||||
|
@ -41,10 +49,11 @@ status_t sctp_socket(sock_id *new, int family, int type)
|
|||
/*
|
||||
* INITMSG
|
||||
*
|
||||
* max number of input streams : 65535
|
||||
* max attemtps : 4
|
||||
* max initial timeout : 8 secs
|
||||
*/
|
||||
rv = set_initmsg(*new, 4, 8000);
|
||||
rv = set_initmsg(*new, sctp_num_ostreams, 65535, 4, 8000);
|
||||
d_assert(rv == CORE_OK, return CORE_ERROR,);
|
||||
|
||||
return CORE_OK;
|
||||
|
@ -394,6 +403,7 @@ static status_t set_rtoinfo(sock_id id,
|
|||
}
|
||||
|
||||
static status_t set_initmsg(sock_id id,
|
||||
c_uint32_t sinit_num_ostreams, c_uint32_t sinit_max_instreams,
|
||||
c_uint32_t sinit_max_attempts, c_uint32_t sinit_max_init_timeo)
|
||||
{
|
||||
sock_t *sock = (sock_t *)id;
|
||||
|
@ -401,7 +411,8 @@ static status_t set_initmsg(sock_id id,
|
|||
socklen_t socklen;
|
||||
|
||||
d_assert(id, return CORE_ERROR,);
|
||||
|
||||
d_assert(sinit_num_ostreams > 1, return CORE_ERROR,
|
||||
"Invalid SCTP number of output streams = %d\n", sctp_num_ostreams);
|
||||
|
||||
memset(&initmsg, 0, sizeof(initmsg));
|
||||
socklen = sizeof(initmsg);
|
||||
|
@ -419,6 +430,8 @@ static status_t set_initmsg(sock_id id,
|
|||
initmsg.sinit_max_attempts,
|
||||
initmsg.sinit_max_init_timeo);
|
||||
|
||||
initmsg.sinit_num_ostreams = sinit_num_ostreams;
|
||||
initmsg.sinit_max_instreams = sinit_max_instreams;
|
||||
initmsg.sinit_max_attempts = sinit_max_attempts;
|
||||
initmsg.sinit_max_init_timeo = sinit_max_init_timeo;
|
||||
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
|
||||
#include "context.h"
|
||||
|
||||
#define DEFAULT_SCTP_STREAMS 30
|
||||
|
||||
static context_t self;
|
||||
|
||||
static int context_initialized = 0;
|
||||
|
@ -103,6 +105,7 @@ status_t context_setup_trace_module()
|
|||
static status_t context_prepare()
|
||||
{
|
||||
self.logger.console = -1;
|
||||
self.parameter.sctp_streams = DEFAULT_SCTP_STREAMS;
|
||||
|
||||
return CORE_OK;
|
||||
}
|
||||
|
@ -256,6 +259,11 @@ status_t context_parse_config()
|
|||
self.parameter.no_pcrf =
|
||||
yaml_iter_bool(¶meter_iter);
|
||||
}
|
||||
else if (!strcmp(parameter_key, "sctp_streams"))
|
||||
{
|
||||
const char *v = yaml_iter_value(¶meter_iter);
|
||||
if (v) self.parameter.sctp_streams = atoi(v);
|
||||
}
|
||||
else if (!strcmp(parameter_key, "no_ipv4"))
|
||||
{
|
||||
self.parameter.no_ipv4 =
|
||||
|
|
|
@ -54,6 +54,7 @@ typedef struct _context_t {
|
|||
int no_pcrf;
|
||||
|
||||
/* Network */
|
||||
int sctp_streams;
|
||||
int no_ipv4;
|
||||
int no_ipv6;
|
||||
int prefer_ipv4;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "gtp/gtp_xact.h"
|
||||
|
||||
#include "app/context.h"
|
||||
#include "mme_event.h"
|
||||
|
||||
#include "mme_fd_path.h"
|
||||
|
@ -42,7 +43,9 @@ status_t mme_initialize()
|
|||
if (rv != CORE_OK) return CORE_ERROR;
|
||||
|
||||
#define USRSCTP_LOCAL_UDP_PORT 9899
|
||||
rv = s1ap_init(USRSCTP_LOCAL_UDP_PORT);
|
||||
rv = s1ap_init(
|
||||
context_self()->parameter.sctp_streams,
|
||||
USRSCTP_LOCAL_UDP_PORT);
|
||||
if (rv != CORE_OK) return rv;
|
||||
|
||||
rv = thread_create(&sm_thread, NULL, sm_main, NULL);
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
CORE_DECLARE(status_t) s1ap_init(c_uint16_t port);
|
||||
CORE_DECLARE(status_t) s1ap_init(int sctp_streams, c_uint16_t port);
|
||||
CORE_DECLARE(status_t) s1ap_final();
|
||||
|
||||
CORE_DECLARE(status_t) s1ap_open();
|
||||
|
|
|
@ -9,8 +9,9 @@
|
|||
|
||||
static int s1ap_accept_handler(sock_id sock, void *data);
|
||||
|
||||
status_t s1ap_init(c_uint16_t port)
|
||||
status_t s1ap_init(int sctp_streams, c_uint16_t port)
|
||||
{
|
||||
sctp_set_num_ostreams(sctp_streams);
|
||||
return CORE_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,9 @@ static int s1ap_usrsctp_recv_handler(struct socket *sock,
|
|||
static c_sockaddr_t *usrsctp_remote_addr(union sctp_sockstore *store);
|
||||
static void debug_printf(const char *format, ...);
|
||||
|
||||
status_t s1ap_init(c_uint16_t port)
|
||||
static int sctp_num_ostreams = -1;
|
||||
|
||||
status_t s1ap_init(int sctp_streams, c_uint16_t port)
|
||||
{
|
||||
usrsctp_init(port, NULL, debug_printf);
|
||||
#ifdef SCTP_DEBUG
|
||||
|
@ -45,6 +47,7 @@ status_t s1ap_init(c_uint16_t port)
|
|||
#endif
|
||||
usrsctp_sysctl_set_sctp_blackhole(2);
|
||||
usrsctp_sysctl_set_sctp_enable_sack_immediately(1);
|
||||
sctp_num_ostreams = sctp_streams;
|
||||
|
||||
return CORE_OK;
|
||||
}
|
||||
|
@ -238,6 +241,8 @@ static status_t s1ap_usrsctp_socket(sock_id *new,
|
|||
SCTP_ADAPTATION_INDICATION,
|
||||
SCTP_PARTIAL_DELIVERY_EVENT
|
||||
};
|
||||
struct sctp_initmsg initmsg;
|
||||
socklen_t socklen;
|
||||
int i;
|
||||
|
||||
if (!(sock = usrsctp_socket(family, type, IPPROTO_SCTP,
|
||||
|
@ -268,6 +273,50 @@ static status_t s1ap_usrsctp_socket(sock_id *new,
|
|||
}
|
||||
}
|
||||
|
||||
memset(&initmsg, 0, sizeof(struct sctp_initmsg));
|
||||
socklen = sizeof(struct sctp_initmsg);
|
||||
if (usrsctp_getsockopt(sock, IPPROTO_SCTP, SCTP_INITMSG, &initmsg, &socklen) != 0)
|
||||
{
|
||||
d_error("getsockopt for SCTP_INITMSG failed(%d:%s)",
|
||||
errno, strerror( errno ));
|
||||
return CORE_ERROR;
|
||||
}
|
||||
|
||||
d_trace(3, "Old INITMSG (numout:%d maxin:%d maxattempt:%d maxinit_to:%d)\n",
|
||||
initmsg.sinit_num_ostreams,
|
||||
initmsg.sinit_max_instreams,
|
||||
initmsg.sinit_max_attempts,
|
||||
initmsg.sinit_max_init_timeo);
|
||||
|
||||
/*
|
||||
* INITMSG
|
||||
*
|
||||
* max number of input streams : 65535
|
||||
* max attemtps : 4
|
||||
* max initial timeout : 8 secs
|
||||
*/
|
||||
d_assert(sctp_num_ostreams > 1, return CORE_ERROR,
|
||||
"Invalid SCTP number of output streams = %d\n", sctp_num_ostreams);
|
||||
|
||||
initmsg.sinit_num_ostreams = sctp_num_ostreams;
|
||||
initmsg.sinit_max_instreams = 65535;
|
||||
initmsg.sinit_max_attempts = 4;
|
||||
initmsg.sinit_max_init_timeo = 8000;
|
||||
|
||||
if (usrsctp_setsockopt(sock, IPPROTO_SCTP, SCTP_INITMSG,
|
||||
&initmsg, sizeof(initmsg)) != 0)
|
||||
{
|
||||
d_error("setsockopt for SCTP_INITMSG failed(%d:%s)",
|
||||
errno, strerror( errno ));
|
||||
return CORE_ERROR;
|
||||
}
|
||||
|
||||
d_trace(3,"New INITMSG (numout:%d maxin:%d maxattempt:%d maxinit_to:%d)\n",
|
||||
initmsg.sinit_num_ostreams,
|
||||
initmsg.sinit_max_instreams,
|
||||
initmsg.sinit_max_attempts,
|
||||
initmsg.sinit_max_init_timeo);
|
||||
|
||||
*new = (sock_id)sock;
|
||||
|
||||
return CORE_OK;
|
||||
|
|
|
@ -13,6 +13,9 @@ logger:
|
|||
#
|
||||
# parameter:
|
||||
#
|
||||
# o Number of output streams per SCTP associations.
|
||||
# sctp_streams: 30
|
||||
#
|
||||
# o Disable use of IPv4 addresses (only IPv6)
|
||||
# no_ipv4: true
|
||||
#
|
||||
|
|
Loading…
Reference in New Issue