forked from acouzens/open5gs
SGW packet buffer is changed to 65536
This commit is contained in:
parent
60dc4402c6
commit
71f1b1cfa4
|
@ -1 +1 @@
|
|||
Subproject commit 864034bb4686b29f798e3300c200c674bf619b57
|
||||
Subproject commit 720c9521aea86c341875cac9ca2de2cf3e621c45
|
|
@ -107,9 +107,8 @@ typedef struct sgw_bearer_s {
|
|||
/* Pkts which will be buffered in case of UE-IDLE */
|
||||
uint32_t num_buffered_pkt;
|
||||
|
||||
/* FIXME: The value should be depdendant on the clbuf number. */
|
||||
#define MAX_NUM_BUFFER_PKT 512
|
||||
ogs_pkbuf_t* buffered_pkts[MAX_NUM_BUFFER_PKT];
|
||||
#define MAX_NUM_OF_PACKET_BUFFER 512
|
||||
ogs_pkbuf_t* buffered_pkts[MAX_NUM_OF_PACKET_BUFFER];
|
||||
|
||||
ogs_list_t tunnel_list;
|
||||
sgw_sess_t *sess;
|
||||
|
|
|
@ -2,10 +2,13 @@
|
|||
#include "gtp/gtp_node.h"
|
||||
#include "gtp/gtp_path.h"
|
||||
|
||||
#include "app/context.h"
|
||||
#include "sgw_context.h"
|
||||
#include "sgw_event.h"
|
||||
#include "sgw_gtp_path.h"
|
||||
|
||||
static ogs_pkbuf_pool_t *packet_pool = NULL;
|
||||
|
||||
static void _gtpv2_c_recv_cb(short when, ogs_socket_t fd, void *data)
|
||||
{
|
||||
sgw_event_t *e = NULL;
|
||||
|
@ -59,8 +62,9 @@ static void _gtpv1_u_recv_cb(short when, ogs_socket_t fd, void *data)
|
|||
int i;
|
||||
|
||||
ogs_assert(fd != INVALID_SOCKET);
|
||||
ogs_assert(packet_pool);
|
||||
|
||||
pkbuf = ogs_pkbuf_alloc(NULL, MAX_SDU_LEN);
|
||||
pkbuf = ogs_pkbuf_alloc(packet_pool, MAX_SDU_LEN);
|
||||
ogs_pkbuf_put(pkbuf, MAX_SDU_LEN);
|
||||
|
||||
rv = gtp_recvfrom(fd, pkbuf, &from);
|
||||
|
@ -71,15 +75,13 @@ static void _gtpv1_u_recv_cb(short when, ogs_socket_t fd, void *data)
|
|||
}
|
||||
|
||||
gtp_h = (gtp_header_t *)pkbuf->data;
|
||||
if (gtp_h->type == GTPU_MSGTYPE_ECHO_REQ)
|
||||
{
|
||||
if (gtp_h->type == GTPU_MSGTYPE_ECHO_REQ) {
|
||||
ogs_pkbuf_t *echo_rsp;
|
||||
|
||||
ogs_debug("[SGW] RECV Echo Request from [%s]",
|
||||
OGS_ADDR(&from, buf));
|
||||
echo_rsp = gtp_handle_echo_req(pkbuf);
|
||||
if (echo_rsp)
|
||||
{
|
||||
if (echo_rsp) {
|
||||
ssize_t sent;
|
||||
|
||||
/* Echo reply */
|
||||
|
@ -87,17 +89,14 @@ static void _gtpv1_u_recv_cb(short when, ogs_socket_t fd, void *data)
|
|||
OGS_ADDR(&from, buf));
|
||||
|
||||
sent = ogs_sendto(fd, echo_rsp->data, echo_rsp->len, 0, &from);
|
||||
if (sent < 0 || sent != echo_rsp->len)
|
||||
{
|
||||
if (sent < 0 || sent != echo_rsp->len) {
|
||||
ogs_log_message(OGS_LOG_ERROR, ogs_socket_errno,
|
||||
"ogs_sendto() failed");
|
||||
}
|
||||
ogs_pkbuf_free(echo_rsp);
|
||||
}
|
||||
}
|
||||
else if (gtp_h->type == GTPU_MSGTYPE_GPDU ||
|
||||
gtp_h->type == GTPU_MSGTYPE_END_MARKER)
|
||||
{
|
||||
} else if (gtp_h->type == GTPU_MSGTYPE_GPDU ||
|
||||
gtp_h->type == GTPU_MSGTYPE_END_MARKER) {
|
||||
teid = ntohl(gtp_h->teid);
|
||||
if (gtp_h->type == GTPU_MSGTYPE_GPDU)
|
||||
ogs_debug("[SGW] RECV GPU-U from [%s] : TEID[0x%x]",
|
||||
|
@ -107,8 +106,7 @@ static void _gtpv1_u_recv_cb(short when, ogs_socket_t fd, void *data)
|
|||
OGS_ADDR(&from, buf), teid);
|
||||
|
||||
tunnel = sgw_tunnel_find_by_teid(teid);
|
||||
if (!tunnel)
|
||||
{
|
||||
if (!tunnel) {
|
||||
if (gtp_h->type == GTPU_MSGTYPE_GPDU)
|
||||
ogs_warn("[SGW] RECV GPU-U from [%s] : No TEID[0x%x]",
|
||||
OGS_ADDR(&from, buf), teid);
|
||||
|
@ -122,8 +120,7 @@ static void _gtpv1_u_recv_cb(short when, ogs_socket_t fd, void *data)
|
|||
ogs_assert(bearer);
|
||||
|
||||
/* Convert TEID */
|
||||
if (tunnel->interface_type == GTP_F_TEID_S1_U_SGW_GTP_U)
|
||||
{
|
||||
if (tunnel->interface_type == GTP_F_TEID_S1_U_SGW_GTP_U) {
|
||||
sgw_tunnel_t *s5u_tunnel = NULL;
|
||||
|
||||
s5u_tunnel = sgw_s5u_tunnel_in_bearer(bearer);
|
||||
|
@ -136,12 +133,10 @@ static void _gtpv1_u_recv_cb(short when, ogs_socket_t fd, void *data)
|
|||
|
||||
gtp_h->teid = htonl(s5u_tunnel->remote_teid);
|
||||
gtp_sendto(s5u_tunnel->gnode, pkbuf);
|
||||
}
|
||||
else if (tunnel->interface_type ==
|
||||
} else if (tunnel->interface_type ==
|
||||
GTP_F_TEID_SGW_GTP_U_FOR_DL_DATA_FORWARDING ||
|
||||
tunnel->interface_type ==
|
||||
GTP_F_TEID_SGW_GTP_U_FOR_UL_DATA_FORWARDING)
|
||||
{
|
||||
GTP_F_TEID_SGW_GTP_U_FOR_UL_DATA_FORWARDING) {
|
||||
sgw_tunnel_t *indirect_tunnel = NULL;
|
||||
|
||||
indirect_tunnel = sgw_tunnel_find_by_interface_type(bearer,
|
||||
|
@ -155,16 +150,13 @@ static void _gtpv1_u_recv_cb(short when, ogs_socket_t fd, void *data)
|
|||
|
||||
gtp_h->teid = htonl(indirect_tunnel->remote_teid);
|
||||
gtp_sendto(indirect_tunnel->gnode, pkbuf);
|
||||
}
|
||||
else if (tunnel->interface_type == GTP_F_TEID_S5_S8_SGW_GTP_U)
|
||||
{
|
||||
} else if (tunnel->interface_type == GTP_F_TEID_S5_S8_SGW_GTP_U) {
|
||||
sgw_tunnel_t *s1u_tunnel = NULL;
|
||||
|
||||
s1u_tunnel = sgw_s1u_tunnel_in_bearer(bearer);
|
||||
ogs_assert(s1u_tunnel);
|
||||
|
||||
if (s1u_tunnel->remote_teid)
|
||||
{
|
||||
if (s1u_tunnel->remote_teid) {
|
||||
ogs_assert(s1u_tunnel->gnode);
|
||||
ogs_assert(s1u_tunnel->gnode->sock);
|
||||
ogs_debug("[SGW] SEND GPU-U to ENB[%s]: TEID[0x%x]",
|
||||
|
@ -172,8 +164,7 @@ static void _gtpv1_u_recv_cb(short when, ogs_socket_t fd, void *data)
|
|||
s1u_tunnel->remote_teid);
|
||||
|
||||
/* If there is buffered packet, send it first */
|
||||
for (i = 0; i < bearer->num_buffered_pkt; i++)
|
||||
{
|
||||
for (i = 0; i < bearer->num_buffered_pkt; i++) {
|
||||
gtp_header_t *gtp_h = NULL;
|
||||
|
||||
gtp_h = (gtp_header_t *)bearer->buffered_pkts[i]->data;
|
||||
|
@ -186,9 +177,7 @@ static void _gtpv1_u_recv_cb(short when, ogs_socket_t fd, void *data)
|
|||
|
||||
gtp_h->teid = htonl(s1u_tunnel->remote_teid);
|
||||
gtp_sendto(s1u_tunnel->gnode, pkbuf);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
/* S1U path is deactivated.
|
||||
* Send downlink_data_notification to MME.
|
||||
*
|
||||
|
@ -202,11 +191,9 @@ static void _gtpv1_u_recv_cb(short when, ogs_socket_t fd, void *data)
|
|||
|
||||
ogs_debug("[SGW] S1U PATH deactivated : STATE[0x%x]",
|
||||
SGW_GET_UE_STATE(sgw_ue));
|
||||
if ((SGW_GET_UE_STATE(sgw_ue) & SGW_S1U_INACTIVE))
|
||||
{
|
||||
if ((SGW_GET_UE_STATE(sgw_ue) & SGW_S1U_INACTIVE)) {
|
||||
ogs_debug(" SGW-S1U Inactive");
|
||||
if (!(SGW_GET_UE_STATE(sgw_ue) & SGW_DL_NOTI_SENT))
|
||||
{
|
||||
if (!(SGW_GET_UE_STATE(sgw_ue) & SGW_DL_NOTI_SENT)) {
|
||||
sgw_event_t *e;
|
||||
|
||||
ogs_debug(" EVENT DL Data Notification");
|
||||
|
@ -223,15 +210,12 @@ static void _gtpv1_u_recv_cb(short when, ogs_socket_t fd, void *data)
|
|||
}
|
||||
|
||||
/* Buffer the packet */
|
||||
if (bearer->num_buffered_pkt < MAX_NUM_BUFFER_PKT)
|
||||
{
|
||||
if (bearer->num_buffered_pkt < MAX_NUM_OF_PACKET_BUFFER) {
|
||||
bearer->buffered_pkts[bearer->num_buffered_pkt++] =
|
||||
pkbuf;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
/* UE is S1U_ACTIVE state but there is no s1u teid */
|
||||
ogs_debug("[SGW] UE is ACITVE but there is no matched "
|
||||
"ENB_S1U_TEID[%d]", teid);
|
||||
|
@ -251,16 +235,22 @@ int sgw_gtp_open()
|
|||
ogs_socknode_t *node = NULL;
|
||||
ogs_sock_t *sock = NULL;
|
||||
|
||||
ogs_list_for_each(&sgw_self()->gtpc_list, node)
|
||||
{
|
||||
ogs_pkbuf_config_t config;
|
||||
memset(&config, 0, sizeof config);
|
||||
|
||||
config.pkbuf_pool = config.cluster_pool = config.cluster_8192_pool =
|
||||
context_self()->config.max.packet.pool;
|
||||
|
||||
packet_pool = ogs_pkbuf_pool_create(&config);
|
||||
|
||||
ogs_list_for_each(&sgw_self()->gtpc_list, node) {
|
||||
ogs_socknode_set_poll(node, sgw_self()->pollset,
|
||||
OGS_POLLIN, _gtpv2_c_recv_cb, NULL);
|
||||
|
||||
sock = gtp_server(node);
|
||||
ogs_assert(sock);
|
||||
}
|
||||
ogs_list_for_each(&sgw_self()->gtpc_list6, node)
|
||||
{
|
||||
ogs_list_for_each(&sgw_self()->gtpc_list6, node) {
|
||||
ogs_socknode_set_poll(node, sgw_self()->pollset,
|
||||
OGS_POLLIN, _gtpv2_c_recv_cb, NULL);
|
||||
|
||||
|
@ -275,16 +265,14 @@ int sgw_gtp_open()
|
|||
|
||||
ogs_assert(sgw_self()->gtpc_addr || sgw_self()->gtpc_addr6);
|
||||
|
||||
ogs_list_for_each(&sgw_self()->gtpu_list, node)
|
||||
{
|
||||
ogs_list_for_each(&sgw_self()->gtpu_list, node) {
|
||||
ogs_socknode_set_poll(node, sgw_self()->pollset,
|
||||
OGS_POLLIN, _gtpv1_u_recv_cb, NULL);
|
||||
|
||||
sock = gtp_server(node);
|
||||
ogs_assert(sock);
|
||||
}
|
||||
ogs_list_for_each(&sgw_self()->gtpu_list6, node)
|
||||
{
|
||||
ogs_list_for_each(&sgw_self()->gtpu_list6, node) {
|
||||
ogs_socknode_set_poll(node, sgw_self()->pollset,
|
||||
OGS_POLLIN, _gtpv1_u_recv_cb, NULL);
|
||||
|
||||
|
@ -308,6 +296,8 @@ void sgw_gtp_close()
|
|||
ogs_socknode_remove_all(&sgw_self()->gtpc_list6);
|
||||
ogs_socknode_remove_all(&sgw_self()->gtpu_list);
|
||||
ogs_socknode_remove_all(&sgw_self()->gtpu_list6);
|
||||
|
||||
ogs_pkbuf_pool_destroy(packet_pool);
|
||||
}
|
||||
|
||||
int sgw_gtp_send_end_marker(sgw_tunnel_t *s1u_tunnel)
|
||||
|
|
Loading…
Reference in New Issue