[UPF] test code for unspecified address (#1776)

This commit is contained in:
Sukchan Lee 2022-10-01 13:23:15 +09:00
parent 773c7df3e6
commit 1acb7f72b4
4 changed files with 135 additions and 0 deletions

View File

@ -466,6 +466,36 @@ static void _gtpv1_u_recv_cb(short when, ogs_socket_t fd, void *data)
*/
if (far->dst_if != OGS_PFCP_INTERFACE_ACCESS) {
/*
* Discussion #1776 was raised,
* but we decided not to allow unspecified addresses
* because Open5GS has already sent interface identifiers
* in the registgration/attach process.
*
*
* RFC4861
* 4. Message Formats
* 4.1. Router Solicitation Message Format
* IP Fields:
* Source Address
* An IP address assigned to the sending interface, or
* the unspecified address if no address is assigned
* to the sending interface.
*
* 6.1. Message Validation
* 6.1.1. Validation of Router Solicitation Messages
* Hosts MUST silently discard any received Router Solicitation
* Messages.
*
* A router MUST silently discard any received Router Solicitation
* messages that do not satisfy all of the following validity checks:
*
* ..
* ..
*
* - If the IP source address is the unspecified address, there is no
* source link-layer address option in the message.
*/
if (IN6_IS_ADDR_LINKLOCAL((struct in6_addr *)src_addr) &&
src_addr[2] == sess->ipv6->addr[2] &&
src_addr[3] == sess->ipv6->addr[3]) {

View File

@ -209,6 +209,47 @@ static void test1_func(abts_case *tc, void *data)
ABTS_PTR_NOTNULL(tc, recvbuf);
testgtpu_recv(test_ue, recvbuf);
/*
* Discussion #1776 was raised,
* but we decided not to allow unspecified addresses
* because Open5GS has already sent interface identifiers
* in the registgration/attach process.
*
*
* RFC4861
* 4. Message Formats
* 4.1. Router Solicitation Message Format
* IP Fields:
* Source Address
* An IP address assigned to the sending interface, or
* the unspecified address if no address is assigned
* to the sending interface.
*
* 6.1. Message Validation
* 6.1.1. Validation of Router Solicitation Messages
* Hosts MUST silently discard any received Router Solicitation
* Messages.
*
* A router MUST silently discard any received Router Solicitation
* messages that do not satisfy all of the following validity checks:
*
* ..
* ..
*
* - If the IP source address is the unspecified address, there is no
* source link-layer address option in the message.
*/
#if 0
/* Send GTP-U Router Solicitation with an unspecified source address */
rv = test_gtpu_send_slacc_rs_with_unspecified_source_address(gtpu, bearer);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
/* Receive GTP-U Router Solicitation */
recvbuf = test_gtpu_read(gtpu);
ABTS_PTR_NOTNULL(tc, recvbuf);
testgtpu_recv(test_ue, recvbuf);
#endif
/* Send GTP-U ICMP Packet */
rv = test_gtpu_send_ping(gtpu, bearer, TEST_PING_IPV4);
ABTS_INT_EQUAL(tc, OGS_OK, rv);

View File

@ -409,6 +409,68 @@ int test_gtpu_send_slacc_rs(ogs_socknode_t *node, test_bearer_t *bearer)
return test_gtpu_send(node, bearer, &gtp_hdesc, &ext_hdesc, pkbuf);
}
int test_gtpu_send_slacc_rs_with_unspecified_source_address(
ogs_socknode_t *node, test_bearer_t *bearer)
{
test_sess_t *sess = NULL;
ogs_gtp2_header_t gtp_hdesc;
ogs_gtp2_extension_header_t ext_hdesc;
ogs_pkbuf_t *pkbuf = NULL;
struct ip6_hdr *ip6_h = NULL;
uint8_t *src_addr = NULL;
const char *payload =
"60000000"
"00103afffe800000 0000000074ee25ff fee4b579ff020000 0000000000000000"
"000000028500da95 00000000010176ee 25e4b579";
unsigned char tmp[OGS_MAX_SDU_LEN];
int payload_len = 56;
ogs_assert(bearer);
sess = bearer->sess;
ogs_assert(sess);
pkbuf = ogs_pkbuf_alloc(
NULL, 200 /* enough for ICMP; use smaller buffer */);
ogs_assert(pkbuf);
ogs_pkbuf_reserve(pkbuf, OGS_GTPV1U_5GC_HEADER_LEN);
ogs_pkbuf_put(pkbuf, 200-OGS_GTPV1U_5GC_HEADER_LEN);
memset(pkbuf->data, 0, pkbuf->len);
OGS_HEX(payload, strlen(payload), tmp);
memcpy(pkbuf->data, tmp, payload_len);
ogs_pkbuf_trim(pkbuf, payload_len);
memset(&gtp_hdesc, 0, sizeof(gtp_hdesc));
memset(&ext_hdesc, 0, sizeof(ext_hdesc));
gtp_hdesc.type = OGS_GTPU_MSGTYPE_GPDU;
gtp_hdesc.flags = OGS_GTPU_FLAGS_S;
if (bearer->qfi) {
gtp_hdesc.teid = sess->upf_n3_teid;
/*
* Discussion #1506
* Router Soliciation should include QFI in 5G Core
*/
ext_hdesc.qos_flow_identifier = bearer->qfi;
} else if (bearer->ebi) {
gtp_hdesc.teid = bearer->sgw_s1u_teid;
} else {
ogs_fatal("No QFI[%d] and EBI[%d]", bearer->qfi, bearer->ebi);
ogs_assert_if_reached();
}
return test_gtpu_send(node, bearer, &gtp_hdesc, &ext_hdesc, pkbuf);
}
int test_gtpu_send_error_indication(
ogs_socknode_t *node, test_bearer_t *bearer)
{

View File

@ -40,6 +40,8 @@ int test_gtpu_send(
int test_gtpu_send_ping(
ogs_socknode_t *node, test_bearer_t *bearer, const char *dst_ip);
int test_gtpu_send_slacc_rs(ogs_socknode_t *node, test_bearer_t *bearer);
int test_gtpu_send_slacc_rs_with_unspecified_source_address(
ogs_socknode_t *node, test_bearer_t *bearer);
int test_gtpu_send_error_indication(
ogs_socknode_t *node, test_bearer_t *bearer);
int test_gtpu_send_indirect_data_forwarding(