2021-06-21 13:36:38 +00:00
|
|
|
/*
|
[GTP/PFCP]] incorrect dst TEI=0/SEID=0 (#3043)
If eg. PCRF or AAA diameter link is not yet ready (eg. PCRF crashed), and
a client sends a CreateSessionRequest announcing its ow F-TEID,
then open5gs-smfd answers with Create Session Response Cause=
"Remote peer not responding", but it is not setting the received F-TEID
in the header of the response, instead it sends with TEI=0.
As a result, the peer cannot match the CreateSessionResponse, and needs
to rely on its own timeout timer to figure out that specific request failed.
This also happens in PFCP, so to solve this problem, I added teid/seid_presence
to the interface that sends the error message as shown below.
void ogs_gtp2_send_error_message(ogs_gtp_xact_t *xact,
int teid_presence, uint32_t teid, uint8_t type, uint8_t cause_value);
void ogs_pfcp_send_error_message(
ogs_pfcp_xact_t *xact, int seid_presence, uint64_t seid, uint8_t type,
uint8_t cause_value, uint16_t offending_ie_value);
2024-03-23 01:00:08 +00:00
|
|
|
* Copyright (C) 2019-2024 by Sukchan Lee <acetcom@gmail.com>
|
2021-06-21 13:36:38 +00:00
|
|
|
*
|
|
|
|
* This file is part of Open5GS.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "test-common.h"
|
|
|
|
#include "s2b-build.h"
|
|
|
|
#include "s2b-handler.h"
|
|
|
|
|
|
|
|
ogs_socknode_t *test_epdg_server(uint16_t port)
|
|
|
|
{
|
|
|
|
int rv;
|
|
|
|
ogs_sockaddr_t *addr = NULL;
|
|
|
|
ogs_socknode_t *node = NULL;
|
|
|
|
ogs_sock_t *sock = NULL;
|
|
|
|
|
|
|
|
ogs_assert(port);
|
|
|
|
|
|
|
|
#define TEST_EPDG_IPV4 "127.0.0.5"
|
|
|
|
|
|
|
|
rv = ogs_getaddrinfo(&addr, AF_UNSPEC, TEST_EPDG_IPV4, port, 0);
|
|
|
|
ogs_assert(rv == OGS_OK);
|
|
|
|
|
|
|
|
node = ogs_socknode_new(addr);
|
|
|
|
ogs_assert(node);
|
|
|
|
|
2022-03-15 13:03:50 +00:00
|
|
|
sock = ogs_udp_server(node->addr, NULL);
|
2021-06-21 13:36:38 +00:00
|
|
|
ogs_assert(sock);
|
|
|
|
|
2022-03-15 13:03:50 +00:00
|
|
|
node->sock = sock;
|
|
|
|
|
2021-06-21 13:36:38 +00:00
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
|
|
|
void test_epdg_close(ogs_socknode_t *node)
|
|
|
|
{
|
|
|
|
ogs_socknode_free(node);
|
|
|
|
}
|
|
|
|
|
|
|
|
ogs_pkbuf_t *test_epdg_read(ogs_socknode_t *node)
|
|
|
|
{
|
|
|
|
int rc = 0;
|
|
|
|
ogs_sockaddr_t from;
|
|
|
|
ogs_pkbuf_t *recvbuf = ogs_pkbuf_alloc(NULL, OGS_MAX_SDU_LEN);
|
|
|
|
ogs_assert(recvbuf);
|
|
|
|
ogs_pkbuf_put(recvbuf, OGS_MAX_SDU_LEN);
|
|
|
|
|
|
|
|
ogs_assert(node);
|
|
|
|
ogs_assert(node->sock);
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
rc = ogs_recvfrom(
|
|
|
|
node->sock->fd, recvbuf->data, recvbuf->len, 0, &from);
|
|
|
|
if (rc <= 0) {
|
|
|
|
ogs_log_message(OGS_LOG_ERROR, ogs_socket_errno,
|
|
|
|
"ogs_recvfrom() failed");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
recvbuf->len = rc;
|
|
|
|
|
|
|
|
return recvbuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
void test_s2b_recv(test_sess_t *sess, ogs_pkbuf_t *pkbuf)
|
|
|
|
{
|
|
|
|
int rv;
|
2022-04-12 22:07:39 +00:00
|
|
|
ogs_gtp2_message_t gtp_message;
|
2021-06-21 13:36:38 +00:00
|
|
|
ogs_gtp_xact_t *xact = NULL;
|
|
|
|
|
|
|
|
ogs_assert(sess);
|
|
|
|
ogs_assert(sess->gnode);
|
|
|
|
ogs_assert(pkbuf);
|
|
|
|
|
2022-04-12 22:07:39 +00:00
|
|
|
if (ogs_gtp2_parse_msg(>p_message, pkbuf) != OGS_OK) {
|
|
|
|
ogs_error("ogs_gtp2_parse_msg() failed");
|
2021-06-21 13:36:38 +00:00
|
|
|
ogs_pkbuf_free(pkbuf);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = ogs_gtp_xact_receive(sess->gnode, >p_message.h, &xact);
|
|
|
|
if (rv != OGS_OK) {
|
|
|
|
ogs_error("ogs_gtp_xact_receive() failed");
|
|
|
|
ogs_pkbuf_free(pkbuf);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (gtp_message.h.type) {
|
2022-04-12 22:07:39 +00:00
|
|
|
case OGS_GTP2_CREATE_SESSION_RESPONSE_TYPE:
|
2021-06-21 13:36:38 +00:00
|
|
|
test_s2b_handle_create_session_response(
|
|
|
|
xact, sess, >p_message.create_session_response);
|
|
|
|
break;
|
2022-04-12 22:07:39 +00:00
|
|
|
case OGS_GTP2_DELETE_SESSION_RESPONSE_TYPE:
|
2021-06-21 13:36:38 +00:00
|
|
|
test_s2b_handle_delete_session_response(
|
|
|
|
xact, sess, >p_message.delete_session_response);
|
|
|
|
break;
|
2022-04-12 22:07:39 +00:00
|
|
|
case OGS_GTP2_CREATE_BEARER_REQUEST_TYPE:
|
2021-06-21 13:36:38 +00:00
|
|
|
test_s2b_handle_create_bearer_request(
|
|
|
|
xact, sess, >p_message.create_bearer_request);
|
|
|
|
break;
|
2022-04-12 22:07:39 +00:00
|
|
|
case OGS_GTP2_DELETE_BEARER_REQUEST_TYPE:
|
2021-06-21 13:36:38 +00:00
|
|
|
test_s2b_handle_delete_bearer_request(
|
|
|
|
xact, sess, >p_message.delete_bearer_request);
|
|
|
|
break;
|
|
|
|
default:
|
2022-08-24 12:02:28 +00:00
|
|
|
ogs_error("Not implemented(type:%d)", gtp_message.h.type);
|
2021-06-21 13:36:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ogs_pkbuf_free(pkbuf);
|
|
|
|
}
|
|
|
|
|
|
|
|
int test_s2b_send_create_session_request(test_sess_t *sess, bool handover_ind)
|
|
|
|
{
|
|
|
|
int rv;
|
2022-04-12 22:07:39 +00:00
|
|
|
ogs_gtp2_header_t h;
|
2021-06-21 13:36:38 +00:00
|
|
|
ogs_pkbuf_t *pkbuf = NULL;
|
|
|
|
ogs_gtp_xact_t *xact = NULL;
|
|
|
|
|
|
|
|
ogs_assert(sess);
|
|
|
|
|
2022-04-12 22:07:39 +00:00
|
|
|
memset(&h, 0, sizeof(ogs_gtp2_header_t));
|
|
|
|
h.type = OGS_GTP2_CREATE_SESSION_REQUEST_TYPE;
|
[GTP/PFCP]] incorrect dst TEI=0/SEID=0 (#3043)
If eg. PCRF or AAA diameter link is not yet ready (eg. PCRF crashed), and
a client sends a CreateSessionRequest announcing its ow F-TEID,
then open5gs-smfd answers with Create Session Response Cause=
"Remote peer not responding", but it is not setting the received F-TEID
in the header of the response, instead it sends with TEI=0.
As a result, the peer cannot match the CreateSessionResponse, and needs
to rely on its own timeout timer to figure out that specific request failed.
This also happens in PFCP, so to solve this problem, I added teid/seid_presence
to the interface that sends the error message as shown below.
void ogs_gtp2_send_error_message(ogs_gtp_xact_t *xact,
int teid_presence, uint32_t teid, uint8_t type, uint8_t cause_value);
void ogs_pfcp_send_error_message(
ogs_pfcp_xact_t *xact, int seid_presence, uint64_t seid, uint8_t type,
uint8_t cause_value, uint16_t offending_ie_value);
2024-03-23 01:00:08 +00:00
|
|
|
h.teid_presence = OGS_GTP2_TEID_PRESENCE;
|
2021-06-21 13:36:38 +00:00
|
|
|
h.teid = sess->smf_s2b_c_teid;
|
|
|
|
|
|
|
|
pkbuf = test_s2b_build_create_session_request(h.type, sess, handover_ind);
|
2023-01-23 15:01:36 +00:00
|
|
|
if (!pkbuf) {
|
|
|
|
ogs_error("test_s2b_build_create_session_request() failed");
|
|
|
|
return OGS_ERROR;
|
|
|
|
}
|
2021-06-21 13:36:38 +00:00
|
|
|
|
|
|
|
xact = ogs_gtp_xact_local_create(sess->gnode, &h, pkbuf, NULL, sess);
|
2023-01-23 15:01:36 +00:00
|
|
|
if (!xact) {
|
|
|
|
ogs_error("ogs_gtp_xact_local_create() failed");
|
|
|
|
return OGS_ERROR;
|
|
|
|
}
|
2021-06-21 13:36:38 +00:00
|
|
|
|
|
|
|
rv = ogs_gtp_xact_commit(xact);
|
|
|
|
ogs_expect(rv == OGS_OK);
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
int test_s2b_send_delete_session_request(test_sess_t *sess)
|
|
|
|
{
|
|
|
|
int rv;
|
2022-04-12 22:07:39 +00:00
|
|
|
ogs_gtp2_header_t h;
|
2021-06-21 13:36:38 +00:00
|
|
|
ogs_pkbuf_t *pkbuf = NULL;
|
|
|
|
ogs_gtp_xact_t *xact = NULL;
|
|
|
|
|
|
|
|
ogs_assert(sess);
|
|
|
|
|
2022-04-12 22:07:39 +00:00
|
|
|
memset(&h, 0, sizeof(ogs_gtp2_header_t));
|
|
|
|
h.type = OGS_GTP2_DELETE_SESSION_REQUEST_TYPE;
|
[GTP/PFCP]] incorrect dst TEI=0/SEID=0 (#3043)
If eg. PCRF or AAA diameter link is not yet ready (eg. PCRF crashed), and
a client sends a CreateSessionRequest announcing its ow F-TEID,
then open5gs-smfd answers with Create Session Response Cause=
"Remote peer not responding", but it is not setting the received F-TEID
in the header of the response, instead it sends with TEI=0.
As a result, the peer cannot match the CreateSessionResponse, and needs
to rely on its own timeout timer to figure out that specific request failed.
This also happens in PFCP, so to solve this problem, I added teid/seid_presence
to the interface that sends the error message as shown below.
void ogs_gtp2_send_error_message(ogs_gtp_xact_t *xact,
int teid_presence, uint32_t teid, uint8_t type, uint8_t cause_value);
void ogs_pfcp_send_error_message(
ogs_pfcp_xact_t *xact, int seid_presence, uint64_t seid, uint8_t type,
uint8_t cause_value, uint16_t offending_ie_value);
2024-03-23 01:00:08 +00:00
|
|
|
h.teid_presence = OGS_GTP2_TEID_PRESENCE;
|
2021-06-21 13:36:38 +00:00
|
|
|
h.teid = sess->smf_s2b_c_teid;
|
|
|
|
|
|
|
|
pkbuf = test_s2b_build_delete_session_request(h.type, sess);
|
2023-01-23 15:01:36 +00:00
|
|
|
if (!pkbuf) {
|
|
|
|
ogs_error("test_s2b_build_delete_session_request() failed");
|
|
|
|
return OGS_ERROR;
|
|
|
|
}
|
2021-06-21 13:36:38 +00:00
|
|
|
|
|
|
|
xact = ogs_gtp_xact_local_create(sess->gnode, &h, pkbuf, NULL, sess);
|
2023-01-23 15:01:36 +00:00
|
|
|
if (!xact) {
|
|
|
|
ogs_error("ogs_gtp_xact_local_create() failed");
|
|
|
|
return OGS_ERROR;
|
|
|
|
}
|
2021-06-21 13:36:38 +00:00
|
|
|
|
|
|
|
rv = ogs_gtp_xact_commit(xact);
|
|
|
|
ogs_expect(rv == OGS_OK);
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
int test_s2b_send_create_bearer_response(
|
|
|
|
test_bearer_t *bearer, ogs_gtp_xact_t *xact)
|
|
|
|
{
|
|
|
|
int rv;
|
2022-04-12 22:07:39 +00:00
|
|
|
ogs_gtp2_header_t h;
|
2021-06-21 13:36:38 +00:00
|
|
|
ogs_pkbuf_t *pkbuf = NULL;
|
|
|
|
test_sess_t *sess = NULL;
|
|
|
|
|
|
|
|
ogs_assert(xact);
|
|
|
|
ogs_assert(bearer);
|
|
|
|
sess = bearer->sess;
|
|
|
|
ogs_assert(sess);
|
|
|
|
|
2022-04-12 22:07:39 +00:00
|
|
|
memset(&h, 0, sizeof(ogs_gtp2_header_t));
|
|
|
|
h.type = OGS_GTP2_CREATE_BEARER_RESPONSE_TYPE;
|
[GTP/PFCP]] incorrect dst TEI=0/SEID=0 (#3043)
If eg. PCRF or AAA diameter link is not yet ready (eg. PCRF crashed), and
a client sends a CreateSessionRequest announcing its ow F-TEID,
then open5gs-smfd answers with Create Session Response Cause=
"Remote peer not responding", but it is not setting the received F-TEID
in the header of the response, instead it sends with TEI=0.
As a result, the peer cannot match the CreateSessionResponse, and needs
to rely on its own timeout timer to figure out that specific request failed.
This also happens in PFCP, so to solve this problem, I added teid/seid_presence
to the interface that sends the error message as shown below.
void ogs_gtp2_send_error_message(ogs_gtp_xact_t *xact,
int teid_presence, uint32_t teid, uint8_t type, uint8_t cause_value);
void ogs_pfcp_send_error_message(
ogs_pfcp_xact_t *xact, int seid_presence, uint64_t seid, uint8_t type,
uint8_t cause_value, uint16_t offending_ie_value);
2024-03-23 01:00:08 +00:00
|
|
|
h.teid_presence = OGS_GTP2_TEID_PRESENCE;
|
2021-06-21 13:36:38 +00:00
|
|
|
h.teid = sess->smf_s2b_c_teid;
|
|
|
|
|
|
|
|
pkbuf = test_s2b_build_create_bearer_response(h.type, bearer);
|
2023-01-23 15:01:36 +00:00
|
|
|
if (!pkbuf) {
|
|
|
|
ogs_error("test_s2b_build_create_bearer_response() failed");
|
|
|
|
return OGS_ERROR;
|
|
|
|
}
|
2021-06-21 13:36:38 +00:00
|
|
|
|
|
|
|
rv = ogs_gtp_xact_update_tx(xact, &h, pkbuf);
|
2023-01-23 15:01:36 +00:00
|
|
|
if (rv != OGS_OK) {
|
|
|
|
ogs_error("ogs_gtp_xact_update_tx() failed");
|
|
|
|
return OGS_ERROR;
|
|
|
|
}
|
2021-06-21 13:36:38 +00:00
|
|
|
|
|
|
|
rv = ogs_gtp_xact_commit(xact);
|
|
|
|
ogs_expect(rv == OGS_OK);
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
int test_s2b_send_delete_bearer_response(
|
|
|
|
test_bearer_t *bearer, ogs_gtp_xact_t *xact)
|
|
|
|
{
|
|
|
|
int rv;
|
2022-04-12 22:07:39 +00:00
|
|
|
ogs_gtp2_header_t h;
|
2021-06-21 13:36:38 +00:00
|
|
|
ogs_pkbuf_t *pkbuf = NULL;
|
|
|
|
test_sess_t *sess = NULL;
|
|
|
|
|
|
|
|
ogs_assert(xact);
|
|
|
|
ogs_assert(bearer);
|
|
|
|
sess = bearer->sess;
|
|
|
|
ogs_assert(sess);
|
|
|
|
|
2022-04-12 22:07:39 +00:00
|
|
|
memset(&h, 0, sizeof(ogs_gtp2_header_t));
|
|
|
|
h.type = OGS_GTP2_DELETE_BEARER_RESPONSE_TYPE;
|
[GTP/PFCP]] incorrect dst TEI=0/SEID=0 (#3043)
If eg. PCRF or AAA diameter link is not yet ready (eg. PCRF crashed), and
a client sends a CreateSessionRequest announcing its ow F-TEID,
then open5gs-smfd answers with Create Session Response Cause=
"Remote peer not responding", but it is not setting the received F-TEID
in the header of the response, instead it sends with TEI=0.
As a result, the peer cannot match the CreateSessionResponse, and needs
to rely on its own timeout timer to figure out that specific request failed.
This also happens in PFCP, so to solve this problem, I added teid/seid_presence
to the interface that sends the error message as shown below.
void ogs_gtp2_send_error_message(ogs_gtp_xact_t *xact,
int teid_presence, uint32_t teid, uint8_t type, uint8_t cause_value);
void ogs_pfcp_send_error_message(
ogs_pfcp_xact_t *xact, int seid_presence, uint64_t seid, uint8_t type,
uint8_t cause_value, uint16_t offending_ie_value);
2024-03-23 01:00:08 +00:00
|
|
|
h.teid_presence = OGS_GTP2_TEID_PRESENCE;
|
2021-06-21 13:36:38 +00:00
|
|
|
h.teid = sess->smf_s2b_c_teid;
|
|
|
|
|
|
|
|
pkbuf = test_s2b_build_delete_bearer_response(h.type, bearer);
|
2023-01-23 15:01:36 +00:00
|
|
|
if (!pkbuf) {
|
|
|
|
ogs_error("test_s2b_build_delete_bearer_response() failed");
|
|
|
|
return OGS_ERROR;
|
|
|
|
}
|
2021-06-21 13:36:38 +00:00
|
|
|
|
|
|
|
rv = ogs_gtp_xact_update_tx(xact, &h, pkbuf);
|
2023-01-23 15:01:36 +00:00
|
|
|
if (rv != OGS_OK) {
|
|
|
|
ogs_error("ogs_gtp_xact_update_tx() failed");
|
|
|
|
return OGS_ERROR;
|
|
|
|
}
|
2021-06-21 13:36:38 +00:00
|
|
|
|
|
|
|
rv = ogs_gtp_xact_commit(xact);
|
|
|
|
ogs_expect(rv == OGS_OK);
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|