[SBI] Fixed invalid format of subscrCond (#2630)

The format of subscrCond must be 'oneOf'.
This commit is contained in:
Sukchan Lee 2023-09-24 09:00:23 +09:00
parent 227dc1a90d
commit d4f2b545a3
10 changed files with 72 additions and 34 deletions

View File

@ -1861,15 +1861,21 @@ ogs_sbi_subscription_spec_t *ogs_sbi_subscription_spec_add(
{
ogs_sbi_subscription_spec_t *subscription_spec = NULL;
ogs_assert(nf_type);
/* Issue #2630 : The format of subscrCond is invalid. Must be 'oneOf'. */
ogs_assert(!nf_type || !service_name);
ogs_pool_alloc(&subscription_spec_pool, &subscription_spec);
ogs_assert(subscription_spec);
memset(subscription_spec, 0, sizeof(ogs_sbi_subscription_spec_t));
subscription_spec->subscr_cond.nf_type = nf_type;
if (service_name)
if (nf_type)
subscription_spec->subscr_cond.nf_type = nf_type;
else if (service_name)
subscription_spec->subscr_cond.service_name = ogs_strdup(service_name);
else {
ogs_fatal("SubscrCond must be 'oneOf'.");
ogs_assert_if_reached();
}
ogs_list_add(&ogs_sbi_self()->subscription_spec_list, subscription_spec);

View File

@ -1501,6 +1501,10 @@ ogs_sbi_request_t *ogs_nnrf_nfm_build_status_subscribe(
ogs_assert(subscription_data);
ogs_assert(subscription_data->req_nf_type);
/* Issue #2630 : The format of subscrCond is invalid. Must be 'oneOf'. */
ogs_assert(!subscription_data->subscr_cond.nf_type ||
!subscription_data->subscr_cond.service_name);
memset(&message, 0, sizeof(message));
message.h.method = (char *)OGS_SBI_HTTP_METHOD_POST;
message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NNRF_NFM;
@ -1549,10 +1553,12 @@ ogs_sbi_request_t *ogs_nnrf_nfm_build_status_subscribe(
if (subscription_data->subscr_cond.nf_type) {
SubscrCond.nf_type = subscription_data->subscr_cond.nf_type;
SubscriptionData->subscr_cond = &SubscrCond;
}
if (subscription_data->subscr_cond.service_name) {
} else if (subscription_data->subscr_cond.service_name) {
SubscrCond.service_name = subscription_data->subscr_cond.service_name;
SubscriptionData->subscr_cond = &SubscrCond;
} else {
ogs_fatal("SubscrCond must be 'oneOf'.");
ogs_assert_if_reached();
}
message.SubscriptionData = SubscriptionData;

View File

@ -94,16 +94,25 @@ bool ogs_nnrf_nfm_send_nf_status_subscribe(
ogs_sbi_request_t *request = NULL;
ogs_sbi_subscription_data_t *subscription_data = NULL;
/* Issue #2630 : The format of subscrCond is invalid. Must be 'oneOf'. */
ogs_assert(!subscr_cond_nf_type || !subscr_cond_service_name);
subscription_data = ogs_sbi_subscription_data_add();
ogs_assert(subscription_data);
subscription_data->req_nf_type = req_nf_type;
if (req_nf_instance_id)
subscription_data->req_nf_instance_id = ogs_strdup(req_nf_instance_id);
subscription_data->subscr_cond.nf_type = subscr_cond_nf_type;
if (subscr_cond_service_name)
if (subscr_cond_nf_type)
subscription_data->subscr_cond.nf_type = subscr_cond_nf_type;
else if (subscr_cond_service_name)
subscription_data->subscr_cond.service_name =
ogs_strdup(subscr_cond_service_name);
else {
ogs_fatal("SubscrCond must be 'oneOf'.");
ogs_assert_if_reached();
}
request = ogs_nnrf_nfm_build_status_subscribe(subscription_data);
if (!request) {

View File

@ -54,17 +54,17 @@ int amf_sbi_open(void)
/* Setup Subscription-Data */
ogs_sbi_subscription_spec_add(
OpenAPI_nf_type_AUSF, OGS_SBI_SERVICE_NAME_NAUSF_AUTH);
OpenAPI_nf_type_NULL, OGS_SBI_SERVICE_NAME_NAUSF_AUTH);
ogs_sbi_subscription_spec_add(
OpenAPI_nf_type_UDM, OGS_SBI_SERVICE_NAME_NUDM_UECM);
OpenAPI_nf_type_NULL, OGS_SBI_SERVICE_NAME_NUDM_UECM);
ogs_sbi_subscription_spec_add(
OpenAPI_nf_type_UDM, OGS_SBI_SERVICE_NAME_NUDM_SDM);
OpenAPI_nf_type_NULL, OGS_SBI_SERVICE_NAME_NUDM_SDM);
ogs_sbi_subscription_spec_add(
OpenAPI_nf_type_PCF, OGS_SBI_SERVICE_NAME_NPCF_AM_POLICY_CONTROL);
OpenAPI_nf_type_NULL, OGS_SBI_SERVICE_NAME_NPCF_AM_POLICY_CONTROL);
ogs_sbi_subscription_spec_add(
OpenAPI_nf_type_SMF, OGS_SBI_SERVICE_NAME_NSMF_PDUSESSION);
OpenAPI_nf_type_NULL, OGS_SBI_SERVICE_NAME_NSMF_PDUSESSION);
ogs_sbi_subscription_spec_add(
OpenAPI_nf_type_NSSF, OGS_SBI_SERVICE_NAME_NNSSF_NSSELECTION);
OpenAPI_nf_type_NULL, OGS_SBI_SERVICE_NAME_NNSSF_NSSELECTION);
if (ogs_sbi_server_start_all(ogs_sbi_server_handler) != OGS_OK)
return OGS_ERROR;

View File

@ -51,7 +51,7 @@ int ausf_sbi_open(void)
/* Setup Subscription-Data */
ogs_sbi_subscription_spec_add(
OpenAPI_nf_type_UDM, OGS_SBI_SERVICE_NAME_NUDM_UEAU);
OpenAPI_nf_type_NULL, OGS_SBI_SERVICE_NAME_NUDM_UEAU);
if (ogs_sbi_server_start_all(ogs_sbi_server_handler) != OGS_OK)
return OGS_ERROR;

View File

@ -268,7 +268,7 @@ bool nrf_nnrf_handle_nf_status_subscribe(
if (!subscription_data->req_nf_instance_id) {
ogs_error("ogs_strdup() failed");
ogs_sbi_subscription_data_remove(subscription_data);
return NULL;
return false;
}
}
@ -281,7 +281,7 @@ bool nrf_nnrf_handle_nf_status_subscribe(
if (!SubscriptionData->subscription_id) {
ogs_error("ogs_strdup() failed");
ogs_sbi_subscription_data_remove(subscription_data);
return NULL;
return false;
}
if (SubscriptionData->requester_features) {
@ -302,15 +302,29 @@ bool nrf_nnrf_handle_nf_status_subscribe(
if (!SubscriptionData->nrf_supported_features) {
ogs_error("ogs_strdup() failed");
ogs_sbi_subscription_data_remove(subscription_data);
return NULL;
return false;
}
SubscrCond = SubscriptionData->subscr_cond;
if (SubscrCond) {
subscription_data->subscr_cond.nf_type = SubscrCond->nf_type;
if (SubscrCond->service_name)
/* Issue #2630 : The format of subscrCond is invalid. Must be 'oneOf'. */
if (SubscrCond->nf_type && SubscrCond->service_name) {
ogs_error("SubscrCond must be 'oneOf'");
ogs_sbi_subscription_data_remove(subscription_data);
return false;
}
if (SubscrCond->nf_type)
subscription_data->subscr_cond.nf_type = SubscrCond->nf_type;
else if (SubscrCond->service_name)
subscription_data->subscr_cond.service_name =
ogs_strdup(SubscrCond->service_name);
else {
ogs_error("No SubscrCond");
ogs_sbi_subscription_data_remove(subscription_data);
return false;
}
}
subscription_data->notification_uri =

View File

@ -121,16 +121,14 @@ bool nrf_nnrf_nfm_send_nf_status_notify_all(
strcmp(subscription_data->req_nf_instance_id, nf_instance->id) == 0)
continue;
if (subscription_data->subscr_cond.nf_type &&
subscription_data->subscr_cond.nf_type != nf_instance->nf_type)
continue;
/* Issue #2630 : The format of subscrCond is invalid. Must be 'oneOf'. */
if (subscription_data->subscr_cond.nf_type) {
if (subscription_data->req_nf_type &&
ogs_sbi_nf_instance_is_allowed_nf_type(
nf_instance, subscription_data->req_nf_type) == false)
continue;
if (subscription_data->subscr_cond.nf_type != nf_instance->nf_type)
continue;
} else if (subscription_data->subscr_cond.service_name) {
if (subscription_data->subscr_cond.service_name) {
ogs_sbi_nf_service_t *nf_service =
ogs_sbi_nf_service_find_by_name(nf_instance,
subscription_data->subscr_cond.service_name);
@ -142,6 +140,11 @@ bool nrf_nnrf_nfm_send_nf_status_notify_all(
continue;
}
if (subscription_data->req_nf_type &&
ogs_sbi_nf_instance_is_allowed_nf_type(
nf_instance, subscription_data->req_nf_type) == false)
continue;
rc = nrf_nnrf_nfm_send_nf_status_notify(
subscription_data, event, nf_instance);
if (rc == false) {

View File

@ -98,9 +98,9 @@ int pcf_sbi_open(void)
/* Setup Subscription-Data */
ogs_sbi_subscription_spec_add(
OpenAPI_nf_type_BSF, OGS_SBI_SERVICE_NAME_NBSF_MANAGEMENT);
OpenAPI_nf_type_NULL, OGS_SBI_SERVICE_NAME_NBSF_MANAGEMENT);
ogs_sbi_subscription_spec_add(
OpenAPI_nf_type_UDR, OGS_SBI_SERVICE_NAME_NUDR_DR);
OpenAPI_nf_type_NULL, OGS_SBI_SERVICE_NAME_NUDR_DR);
if (ogs_sbi_server_start_all(ogs_sbi_server_handler) != OGS_OK)
return OGS_ERROR;

View File

@ -62,13 +62,13 @@ int smf_sbi_open(void)
/* Setup Subscription-Data */
ogs_sbi_subscription_spec_add(
OpenAPI_nf_type_AMF, OGS_SBI_SERVICE_NAME_NAMF_COMM);
OpenAPI_nf_type_NULL, OGS_SBI_SERVICE_NAME_NAMF_COMM);
ogs_sbi_subscription_spec_add(
OpenAPI_nf_type_PCF, OGS_SBI_SERVICE_NAME_NPCF_SMPOLICYCONTROL);
OpenAPI_nf_type_NULL, OGS_SBI_SERVICE_NAME_NPCF_SMPOLICYCONTROL);
ogs_sbi_subscription_spec_add(
OpenAPI_nf_type_UDM, OGS_SBI_SERVICE_NAME_NUDM_SDM);
OpenAPI_nf_type_NULL, OGS_SBI_SERVICE_NAME_NUDM_SDM);
ogs_sbi_subscription_spec_add(
OpenAPI_nf_type_UDM, OGS_SBI_SERVICE_NAME_NUDM_UECM);
OpenAPI_nf_type_NULL, OGS_SBI_SERVICE_NAME_NUDM_UECM);
if (ogs_sbi_server_start_all(ogs_sbi_server_handler) != OGS_OK)
return OGS_ERROR;

View File

@ -38,7 +38,7 @@ int af_sbi_open(void)
/* Setup Subscription-Data */
ogs_sbi_subscription_spec_add(
OpenAPI_nf_type_BSF, OGS_SBI_SERVICE_NAME_NBSF_MANAGEMENT);
OpenAPI_nf_type_NULL, OGS_SBI_SERVICE_NAME_NBSF_MANAGEMENT);
if (ogs_sbi_server_start_all(ogs_sbi_server_handler) != OGS_OK)
return OGS_ERROR;