forked from acouzens/open5gs
[CORE] Increase SDU buffer to 32k (#2008)
This commit is contained in:
parent
43eb5f3d7f
commit
218b31d006
|
@ -425,10 +425,14 @@ int ogs_app_context_parse_config(void)
|
|||
const char *v = ogs_yaml_iter_value(&pool_iter);
|
||||
if (v)
|
||||
self.pool.defconfig.cluster_2048_pool = atoi(v);
|
||||
} else if (!strcmp(pool_key, "16384")) {
|
||||
} else if (!strcmp(pool_key, "8192")) {
|
||||
const char *v = ogs_yaml_iter_value(&pool_iter);
|
||||
if (v)
|
||||
self.pool.defconfig.cluster_16384_pool = atoi(v);
|
||||
self.pool.defconfig.cluster_8192_pool = atoi(v);
|
||||
} else if (!strcmp(pool_key, "32768")) {
|
||||
const char *v = ogs_yaml_iter_value(&pool_iter);
|
||||
if (v)
|
||||
self.pool.defconfig.cluster_32768_pool = atoi(v);
|
||||
} else if (!strcmp(pool_key, "big")) {
|
||||
const char *v = ogs_yaml_iter_value(&pool_iter);
|
||||
if (v)
|
||||
|
|
|
@ -206,6 +206,10 @@ static ogs_inline ogs_uint24_t ogs_htobe24(ogs_uint24_t x)
|
|||
#define OGS_MAX_FILEPATH_LEN 256
|
||||
#define OGS_MAX_IFNAME_LEN 32
|
||||
|
||||
#define OGS_MAX_SDU_LEN 32768 /* Should Heap */
|
||||
#define OGS_HUGE_LEN 8192 /* Can Stack */
|
||||
#define OGS_MAX_PKT_LEN 2048
|
||||
|
||||
#define OGS_FILE_LINE __FILE__ ":" OGS_STRINGIFY(__LINE__)
|
||||
|
||||
#define ogs_uint64_to_uint32(x) ((x >= 0xffffffffUL) ? 0xffffffffU : x)
|
||||
|
|
|
@ -28,7 +28,8 @@
|
|||
#define OGS_CLUSTER_512_SIZE 512
|
||||
#define OGS_CLUSTER_1024_SIZE 1024
|
||||
#define OGS_CLUSTER_2048_SIZE 2048
|
||||
#define OGS_CLUSTER_16384_SIZE 16384
|
||||
#define OGS_CLUSTER_8192_SIZE 8192
|
||||
#define OGS_CLUSTER_32768_SIZE 32768
|
||||
|
||||
/*
|
||||
*
|
||||
|
@ -48,7 +49,8 @@ typedef uint8_t ogs_cluster_256_t[OGS_CLUSTER_256_SIZE];
|
|||
typedef uint8_t ogs_cluster_512_t[OGS_CLUSTER_512_SIZE];
|
||||
typedef uint8_t ogs_cluster_1024_t[OGS_CLUSTER_1024_SIZE];
|
||||
typedef uint8_t ogs_cluster_2048_t[OGS_CLUSTER_2048_SIZE];
|
||||
typedef uint8_t ogs_cluster_16384_t[OGS_CLUSTER_16384_SIZE];
|
||||
typedef uint8_t ogs_cluster_8192_t[OGS_CLUSTER_8192_SIZE];
|
||||
typedef uint8_t ogs_cluster_32768_t[OGS_CLUSTER_32768_SIZE];
|
||||
typedef uint8_t ogs_cluster_big_t[OGS_CLUSTER_BIG_SIZE];
|
||||
|
||||
OGS_STATIC_ASSERT(sizeof(ogs_cluster_128_t) % sizeof(void *) == 0);
|
||||
|
@ -56,7 +58,8 @@ OGS_STATIC_ASSERT(sizeof(ogs_cluster_256_t) % sizeof(void *) == 0);
|
|||
OGS_STATIC_ASSERT(sizeof(ogs_cluster_512_t) % sizeof(void *) == 0);
|
||||
OGS_STATIC_ASSERT(sizeof(ogs_cluster_1024_t) % sizeof(void *) == 0);
|
||||
OGS_STATIC_ASSERT(sizeof(ogs_cluster_2048_t) % sizeof(void *) == 0);
|
||||
OGS_STATIC_ASSERT(sizeof(ogs_cluster_16384_t) % sizeof(void *) == 0);
|
||||
OGS_STATIC_ASSERT(sizeof(ogs_cluster_8192_t) % sizeof(void *) == 0);
|
||||
OGS_STATIC_ASSERT(sizeof(ogs_cluster_32768_t) % sizeof(void *) == 0);
|
||||
OGS_STATIC_ASSERT(sizeof(ogs_cluster_big_t) % sizeof(void *) == 0);
|
||||
|
||||
typedef struct ogs_pkbuf_pool_s {
|
||||
|
@ -68,7 +71,8 @@ typedef struct ogs_pkbuf_pool_s {
|
|||
OGS_POOL(cluster_512, ogs_cluster_512_t);
|
||||
OGS_POOL(cluster_1024, ogs_cluster_1024_t);
|
||||
OGS_POOL(cluster_2048, ogs_cluster_2048_t);
|
||||
OGS_POOL(cluster_16384, ogs_cluster_16384_t);
|
||||
OGS_POOL(cluster_8192, ogs_cluster_8192_t);
|
||||
OGS_POOL(cluster_32768, ogs_cluster_32768_t);
|
||||
OGS_POOL(cluster_big, ogs_cluster_big_t);
|
||||
|
||||
ogs_thread_mutex_t mutex;
|
||||
|
@ -116,7 +120,8 @@ void ogs_pkbuf_default_init(ogs_pkbuf_config_t *config)
|
|||
config->cluster_512_pool = 4096;
|
||||
config->cluster_1024_pool = 2048;
|
||||
config->cluster_2048_pool = 1024;
|
||||
config->cluster_16384_pool = 512;
|
||||
config->cluster_8192_pool = 256;
|
||||
config->cluster_32768_pool = 64;
|
||||
config->cluster_big_pool = 8;
|
||||
#endif
|
||||
}
|
||||
|
@ -151,8 +156,8 @@ ogs_pkbuf_pool_t *ogs_pkbuf_pool_create(ogs_pkbuf_config_t *config)
|
|||
|
||||
tmp = config->cluster_128_pool + config->cluster_256_pool +
|
||||
config->cluster_512_pool + config->cluster_1024_pool +
|
||||
config->cluster_2048_pool + config->cluster_16384_pool +
|
||||
config->cluster_big_pool;
|
||||
config->cluster_2048_pool + config->cluster_8192_pool +
|
||||
config->cluster_32768_pool + config->cluster_big_pool;
|
||||
|
||||
ogs_pool_init(&pool->pkbuf, tmp);
|
||||
ogs_pool_init(&pool->cluster, tmp);
|
||||
|
@ -162,7 +167,8 @@ ogs_pkbuf_pool_t *ogs_pkbuf_pool_create(ogs_pkbuf_config_t *config)
|
|||
ogs_pool_init(&pool->cluster_512, config->cluster_512_pool);
|
||||
ogs_pool_init(&pool->cluster_1024, config->cluster_1024_pool);
|
||||
ogs_pool_init(&pool->cluster_2048, config->cluster_2048_pool);
|
||||
ogs_pool_init(&pool->cluster_16384, config->cluster_16384_pool);
|
||||
ogs_pool_init(&pool->cluster_8192, config->cluster_8192_pool);
|
||||
ogs_pool_init(&pool->cluster_32768, config->cluster_32768_pool);
|
||||
ogs_pool_init(&pool->cluster_big, config->cluster_big_pool);
|
||||
#endif
|
||||
|
||||
|
@ -200,7 +206,8 @@ void ogs_pkbuf_pool_destroy(ogs_pkbuf_pool_t *pool)
|
|||
ogs_pool_final(&pool->cluster_512);
|
||||
ogs_pool_final(&pool->cluster_1024);
|
||||
ogs_pool_final(&pool->cluster_2048);
|
||||
ogs_pool_final(&pool->cluster_16384);
|
||||
ogs_pool_final(&pool->cluster_8192);
|
||||
ogs_pool_final(&pool->cluster_32768);
|
||||
ogs_pool_final(&pool->cluster_big);
|
||||
|
||||
ogs_thread_mutex_destroy(&pool->mutex);
|
||||
|
@ -405,13 +412,20 @@ static ogs_cluster_t *cluster_alloc(
|
|||
return NULL;
|
||||
}
|
||||
cluster->size = OGS_CLUSTER_2048_SIZE;
|
||||
} else if (size <= OGS_CLUSTER_16384_SIZE) {
|
||||
ogs_pool_alloc(&pool->cluster_16384, (ogs_cluster_16384_t**)&buffer);
|
||||
} else if (size <= OGS_CLUSTER_8192_SIZE) {
|
||||
ogs_pool_alloc(&pool->cluster_8192, (ogs_cluster_8192_t**)&buffer);
|
||||
if (!buffer) {
|
||||
ogs_error("ogs_pool_alloc() failed");
|
||||
return NULL;
|
||||
}
|
||||
cluster->size = OGS_CLUSTER_16384_SIZE;
|
||||
cluster->size = OGS_CLUSTER_8192_SIZE;
|
||||
} else if (size <= OGS_CLUSTER_32768_SIZE) {
|
||||
ogs_pool_alloc(&pool->cluster_32768, (ogs_cluster_32768_t**)&buffer);
|
||||
if (!buffer) {
|
||||
ogs_error("ogs_pool_alloc() failed");
|
||||
return NULL;
|
||||
}
|
||||
cluster->size = OGS_CLUSTER_32768_SIZE;
|
||||
} else if (size <= OGS_CLUSTER_BIG_SIZE) {
|
||||
ogs_pool_alloc(&pool->cluster_big, (ogs_cluster_big_t**)&buffer);
|
||||
if (!buffer) {
|
||||
|
@ -452,9 +466,13 @@ static void cluster_free(ogs_pkbuf_pool_t *pool, ogs_cluster_t *cluster)
|
|||
ogs_pool_free(
|
||||
&pool->cluster_2048, (ogs_cluster_2048_t*)cluster->buffer);
|
||||
break;
|
||||
case OGS_CLUSTER_16384_SIZE:
|
||||
case OGS_CLUSTER_8192_SIZE:
|
||||
ogs_pool_free(
|
||||
&pool->cluster_16384, (ogs_cluster_16384_t*)cluster->buffer);
|
||||
&pool->cluster_8192, (ogs_cluster_8192_t*)cluster->buffer);
|
||||
break;
|
||||
case OGS_CLUSTER_32768_SIZE:
|
||||
ogs_pool_free(
|
||||
&pool->cluster_32768, (ogs_cluster_32768_t*)cluster->buffer);
|
||||
break;
|
||||
case OGS_CLUSTER_BIG_SIZE:
|
||||
ogs_pool_free(&pool->cluster_big, (ogs_cluster_big_t*)cluster->buffer);
|
||||
|
|
|
@ -68,7 +68,8 @@ typedef struct ogs_pkbuf_config_s {
|
|||
int cluster_512_pool;
|
||||
int cluster_1024_pool;
|
||||
int cluster_2048_pool;
|
||||
int cluster_16384_pool;
|
||||
int cluster_8192_pool;
|
||||
int cluster_32768_pool;
|
||||
int cluster_big_pool;
|
||||
} ogs_pkbuf_config_t;
|
||||
|
||||
|
|
|
@ -54,8 +54,6 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define OGS_HUGE_LEN 16384
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define ogs_strtok_r strtok_s
|
||||
#define ogs_strcasecmp _stricmp
|
||||
|
|
|
@ -98,15 +98,19 @@ static void diam_gnutls_log_func(int level, const char *str)
|
|||
|
||||
static void diam_log_func(int printlevel, const char *format, va_list ap)
|
||||
{
|
||||
char buffer[OGS_HUGE_LEN*2];
|
||||
char *buffer = NULL;
|
||||
int ret = 0;
|
||||
|
||||
buffer = ogs_calloc(1, OGS_MAX_SDU_LEN);
|
||||
ogs_assert(buffer);
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
|
||||
ret = ogs_vsnprintf(buffer, OGS_HUGE_LEN*2, format, ap);
|
||||
ret = ogs_vsnprintf(buffer, OGS_MAX_SDU_LEN, format, ap);
|
||||
#pragma GCC diagnostic pop
|
||||
if (ret < 0 || ret > OGS_HUGE_LEN*2) {
|
||||
if (ret < 0 || ret > OGS_MAX_SDU_LEN) {
|
||||
ogs_error("vsnprintf() failed[ret=%d]", ret);
|
||||
ogs_free(buffer);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -142,4 +146,6 @@ static void diam_log_func(int printlevel, const char *format, va_list ap)
|
|||
diam_log_printf(OGS_LOG_ERROR, "[%d] %s\n", printlevel, buffer);
|
||||
break;
|
||||
}
|
||||
|
||||
ogs_free(buffer);
|
||||
}
|
||||
|
|
|
@ -52,8 +52,6 @@ extern "C" {
|
|||
#define OGS_MAX_NUM_OF_GTPU_RESOURCE 4
|
||||
#define OGS_MAX_NUM_OF_FRAMED_ROUTES_IN_PDI 8
|
||||
|
||||
#define OGS_MAX_SDU_LEN OGS_HUGE_LEN
|
||||
#define OGS_MAX_PKT_LEN 2048
|
||||
#define OGS_PLMN_ID_LEN 3
|
||||
#define OGS_MAX_PLMN_ID_BCD_LEN 6
|
||||
|
||||
|
|
|
@ -382,7 +382,7 @@ static connection_t *connection_add(
|
|||
request->h.uri = uri;
|
||||
}
|
||||
|
||||
curl_easy_setopt(conn->easy, CURLOPT_BUFFERSIZE, OGS_MAX_SDU_LEN*2);
|
||||
curl_easy_setopt(conn->easy, CURLOPT_BUFFERSIZE, OGS_MAX_SDU_LEN);
|
||||
|
||||
curl_easy_setopt(conn->easy, CURLOPT_SSL_VERIFYPEER, 0);
|
||||
curl_easy_setopt(conn->easy, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
|
|
|
@ -2239,7 +2239,7 @@ static int on_part_data(
|
|||
} else {
|
||||
offset = data->part[data->num_of_part].content_length;
|
||||
if ((data->part[data->num_of_part].content_length + length) >
|
||||
OGS_HUGE_LEN) {
|
||||
OGS_MAX_SDU_LEN) {
|
||||
ogs_error("Overflow length [%d:%d]",
|
||||
(int)data->part[data->num_of_part].content_length,
|
||||
(int)length);
|
||||
|
@ -2414,12 +2414,12 @@ static bool build_multipart(
|
|||
strcpy(boundary, "=-");
|
||||
ogs_base64_encode_binary(boundary + 2, digest, 16);
|
||||
|
||||
p = http->content = ogs_calloc(1, OGS_HUGE_LEN);
|
||||
p = http->content = ogs_calloc(1, OGS_MAX_SDU_LEN);
|
||||
if (!p) {
|
||||
ogs_error("ogs_calloc() failed");
|
||||
return false;
|
||||
}
|
||||
last = p + OGS_HUGE_LEN;
|
||||
last = p + OGS_MAX_SDU_LEN;
|
||||
|
||||
/* First boundary */
|
||||
p = ogs_slprintf(p, last, "--%s\r\n", boundary);
|
||||
|
|
|
@ -543,7 +543,7 @@ static _MHD_Result access_handler(
|
|||
} else {
|
||||
offset = request->http.content_length;
|
||||
if ((request->http.content_length +
|
||||
*upload_data_size) > OGS_HUGE_LEN) {
|
||||
*upload_data_size) > OGS_MAX_SDU_LEN) {
|
||||
ogs_error("Overflow : Content-Length[%d], upload_data_size[%d]",
|
||||
(int)request->http.content_length,
|
||||
(int)*upload_data_size);
|
||||
|
|
Loading…
Reference in New Issue