open5gs/src/upf/init.c

150 lines
3.6 KiB
C
Raw Normal View History

2020-04-26 19:36:05 +00:00
/*
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
*
* 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 "context.h"
2020-10-04 01:18:08 +00:00
#include "gtp-path.h"
#include "pfcp-path.h"
[UPF] Add metrics support Expose metrics with labels according to ETSI TS 128 552 V16.13.0 in UPF by using hash. The metrics are named respecting the rule: <generation>_<measurement_object_class>_<measurement_family_name>_<metric_name_as_in_TS_128_552> 5qi is not available in UPF. To present 5qi to the user, MN will have to maintain a table qfi->5qi for each QoS flow (will have to get information from SMF). So UPF has to expose qfi. qfi itself is not useful. When used, UPF will have to expose additional label to define the session (e.g. source interface). Label dnn is set to value of APN/DNN received in Establishment. Since SMF does not add APN/DNN to Establishment, the label is empty. When APN/DNN will be set by SMF, it should be added to sess in UPF and used in metrics on Modification and Deletion. Both datavolumeqosleveln3upf are exposed in bytes. MN is providing the transformation to kbits. fivegs_upffunction_upf_qosflows should expose the number of QFIs used in sessions, but exposes number of QER rules, which is currently equal to QFIs. The label snsssai is not provided since the slice is not available on UPF. Exposed metrics example: Standard counters: fivegs_ep_n3_gtp_indatapktn3upf 28637 fivegs_ep_n3_gtp_outdatapktn3upf 14729 fivegs_upffunction_sm_n4sessionestabreq 4 fivegs_upffunction_sm_n4sessionestabfail{cause="66"} 1 fivegs_upffunction_sm_n4sessionestabfail{cause="71"} 68 fivegs_upffunction_sm_n4sessionestabfail{cause="68"} 4 fivegs_upffunction_sm_n4sessionestabfail{cause="72"} 15 fivegs_upffunction_sm_n4sessionestabfail{cause="75"} 3 fivegs_upffunction_sm_n4sessionestabfail{cause="65"} 4 fivegs_upffunction_sm_n4sessionreport 0 fivegs_upffunction_sm_n4sessionreportsucc 0 fivegs_ep_n3_gtp_indatavolumeqosleveln3upf{qfi="1"} 39792997 fivegs_ep_n3_gtp_outdatavolumeqosleveln3upf{qfi="1"} 737548 Nonstandard gauge (added for controlling purposes - same metric as existing metric on AMF and SMF): fivegs_upffunction_upf_sessionnbr 1 Standard gauge: fivegs_upffunction_upf_qosflows{dnn=""} 1
2022-08-19 12:08:27 +00:00
#include "metrics.h"
2020-04-26 19:36:05 +00:00
static ogs_thread_t *thread;
static void upf_main(void *data);
static int initialized = 0;
int upf_initialize()
{
int rv;
2021-03-15 01:01:55 +00:00
ogs_gtp_context_init(OGS_MAX_NUM_OF_GTPU_RESOURCE);
ogs_pfcp_context_init();
[UPF] Add metrics support Expose metrics with labels according to ETSI TS 128 552 V16.13.0 in UPF by using hash. The metrics are named respecting the rule: <generation>_<measurement_object_class>_<measurement_family_name>_<metric_name_as_in_TS_128_552> 5qi is not available in UPF. To present 5qi to the user, MN will have to maintain a table qfi->5qi for each QoS flow (will have to get information from SMF). So UPF has to expose qfi. qfi itself is not useful. When used, UPF will have to expose additional label to define the session (e.g. source interface). Label dnn is set to value of APN/DNN received in Establishment. Since SMF does not add APN/DNN to Establishment, the label is empty. When APN/DNN will be set by SMF, it should be added to sess in UPF and used in metrics on Modification and Deletion. Both datavolumeqosleveln3upf are exposed in bytes. MN is providing the transformation to kbits. fivegs_upffunction_upf_qosflows should expose the number of QFIs used in sessions, but exposes number of QER rules, which is currently equal to QFIs. The label snsssai is not provided since the slice is not available on UPF. Exposed metrics example: Standard counters: fivegs_ep_n3_gtp_indatapktn3upf 28637 fivegs_ep_n3_gtp_outdatapktn3upf 14729 fivegs_upffunction_sm_n4sessionestabreq 4 fivegs_upffunction_sm_n4sessionestabfail{cause="66"} 1 fivegs_upffunction_sm_n4sessionestabfail{cause="71"} 68 fivegs_upffunction_sm_n4sessionestabfail{cause="68"} 4 fivegs_upffunction_sm_n4sessionestabfail{cause="72"} 15 fivegs_upffunction_sm_n4sessionestabfail{cause="75"} 3 fivegs_upffunction_sm_n4sessionestabfail{cause="65"} 4 fivegs_upffunction_sm_n4sessionreport 0 fivegs_upffunction_sm_n4sessionreportsucc 0 fivegs_ep_n3_gtp_indatavolumeqosleveln3upf{qfi="1"} 39792997 fivegs_ep_n3_gtp_outdatavolumeqosleveln3upf{qfi="1"} 737548 Nonstandard gauge (added for controlling purposes - same metric as existing metric on AMF and SMF): fivegs_upffunction_upf_sessionnbr 1 Standard gauge: fivegs_upffunction_upf_qosflows{dnn=""} 1
2022-08-19 12:08:27 +00:00
ogs_metrics_context_init();
2020-04-26 19:36:05 +00:00
upf_context_init();
upf_event_init();
2020-10-04 01:18:08 +00:00
upf_gtp_init();
2020-04-26 19:36:05 +00:00
rv = ogs_pfcp_xact_init();
2020-04-26 19:36:05 +00:00
if (rv != OGS_OK) return rv;
2021-03-15 01:01:55 +00:00
rv = ogs_gtp_context_parse_config("upf", "smf");
if (rv != OGS_OK) return rv;
2020-04-26 19:36:05 +00:00
rv = ogs_pfcp_context_parse_config("upf", "smf");
if (rv != OGS_OK) return rv;
[UPF] Add metrics support Expose metrics with labels according to ETSI TS 128 552 V16.13.0 in UPF by using hash. The metrics are named respecting the rule: <generation>_<measurement_object_class>_<measurement_family_name>_<metric_name_as_in_TS_128_552> 5qi is not available in UPF. To present 5qi to the user, MN will have to maintain a table qfi->5qi for each QoS flow (will have to get information from SMF). So UPF has to expose qfi. qfi itself is not useful. When used, UPF will have to expose additional label to define the session (e.g. source interface). Label dnn is set to value of APN/DNN received in Establishment. Since SMF does not add APN/DNN to Establishment, the label is empty. When APN/DNN will be set by SMF, it should be added to sess in UPF and used in metrics on Modification and Deletion. Both datavolumeqosleveln3upf are exposed in bytes. MN is providing the transformation to kbits. fivegs_upffunction_upf_qosflows should expose the number of QFIs used in sessions, but exposes number of QER rules, which is currently equal to QFIs. The label snsssai is not provided since the slice is not available on UPF. Exposed metrics example: Standard counters: fivegs_ep_n3_gtp_indatapktn3upf 28637 fivegs_ep_n3_gtp_outdatapktn3upf 14729 fivegs_upffunction_sm_n4sessionestabreq 4 fivegs_upffunction_sm_n4sessionestabfail{cause="66"} 1 fivegs_upffunction_sm_n4sessionestabfail{cause="71"} 68 fivegs_upffunction_sm_n4sessionestabfail{cause="68"} 4 fivegs_upffunction_sm_n4sessionestabfail{cause="72"} 15 fivegs_upffunction_sm_n4sessionestabfail{cause="75"} 3 fivegs_upffunction_sm_n4sessionestabfail{cause="65"} 4 fivegs_upffunction_sm_n4sessionreport 0 fivegs_upffunction_sm_n4sessionreportsucc 0 fivegs_ep_n3_gtp_indatavolumeqosleveln3upf{qfi="1"} 39792997 fivegs_ep_n3_gtp_outdatavolumeqosleveln3upf{qfi="1"} 737548 Nonstandard gauge (added for controlling purposes - same metric as existing metric on AMF and SMF): fivegs_upffunction_upf_sessionnbr 1 Standard gauge: fivegs_upffunction_upf_qosflows{dnn=""} 1
2022-08-19 12:08:27 +00:00
rv = ogs_metrics_context_parse_config("upf");
if (rv != OGS_OK) return rv;
2020-04-26 19:36:05 +00:00
rv = upf_context_parse_config();
if (rv != OGS_OK) return rv;
[UPF] Add metrics support Expose metrics with labels according to ETSI TS 128 552 V16.13.0 in UPF by using hash. The metrics are named respecting the rule: <generation>_<measurement_object_class>_<measurement_family_name>_<metric_name_as_in_TS_128_552> 5qi is not available in UPF. To present 5qi to the user, MN will have to maintain a table qfi->5qi for each QoS flow (will have to get information from SMF). So UPF has to expose qfi. qfi itself is not useful. When used, UPF will have to expose additional label to define the session (e.g. source interface). Label dnn is set to value of APN/DNN received in Establishment. Since SMF does not add APN/DNN to Establishment, the label is empty. When APN/DNN will be set by SMF, it should be added to sess in UPF and used in metrics on Modification and Deletion. Both datavolumeqosleveln3upf are exposed in bytes. MN is providing the transformation to kbits. fivegs_upffunction_upf_qosflows should expose the number of QFIs used in sessions, but exposes number of QER rules, which is currently equal to QFIs. The label snsssai is not provided since the slice is not available on UPF. Exposed metrics example: Standard counters: fivegs_ep_n3_gtp_indatapktn3upf 28637 fivegs_ep_n3_gtp_outdatapktn3upf 14729 fivegs_upffunction_sm_n4sessionestabreq 4 fivegs_upffunction_sm_n4sessionestabfail{cause="66"} 1 fivegs_upffunction_sm_n4sessionestabfail{cause="71"} 68 fivegs_upffunction_sm_n4sessionestabfail{cause="68"} 4 fivegs_upffunction_sm_n4sessionestabfail{cause="72"} 15 fivegs_upffunction_sm_n4sessionestabfail{cause="75"} 3 fivegs_upffunction_sm_n4sessionestabfail{cause="65"} 4 fivegs_upffunction_sm_n4sessionreport 0 fivegs_upffunction_sm_n4sessionreportsucc 0 fivegs_ep_n3_gtp_indatavolumeqosleveln3upf{qfi="1"} 39792997 fivegs_ep_n3_gtp_outdatavolumeqosleveln3upf{qfi="1"} 737548 Nonstandard gauge (added for controlling purposes - same metric as existing metric on AMF and SMF): fivegs_upffunction_upf_sessionnbr 1 Standard gauge: fivegs_upffunction_upf_qosflows{dnn=""} 1
2022-08-19 12:08:27 +00:00
rv = upf_metrics_open();
if (rv != 0) return OGS_ERROR;
2020-04-26 19:36:05 +00:00
rv = ogs_log_config_domain(
ogs_app()->logger.domain, ogs_app()->logger.level);
2020-04-26 19:36:05 +00:00
if (rv != OGS_OK) return rv;
rv = ogs_pfcp_ue_pool_generate();
if (rv != OGS_OK) return rv;
rv = upf_pfcp_open();
if (rv != OGS_OK) return rv;
rv = upf_gtp_open();
if (rv != OGS_OK) return rv;
2020-04-26 19:36:05 +00:00
thread = ogs_thread_create(upf_main, NULL);
if (!thread) return OGS_ERROR;
initialized = 1;
return OGS_OK;
}
void upf_terminate(void)
{
if (!initialized) return;
upf_event_term();
ogs_thread_destroy(thread);
upf_pfcp_close();
upf_gtp_close();
2020-04-26 19:36:05 +00:00
upf_context_final();
2020-10-04 01:18:08 +00:00
ogs_pfcp_context_final();
2021-03-15 01:01:55 +00:00
ogs_gtp_context_final();
[UPF] Add metrics support Expose metrics with labels according to ETSI TS 128 552 V16.13.0 in UPF by using hash. The metrics are named respecting the rule: <generation>_<measurement_object_class>_<measurement_family_name>_<metric_name_as_in_TS_128_552> 5qi is not available in UPF. To present 5qi to the user, MN will have to maintain a table qfi->5qi for each QoS flow (will have to get information from SMF). So UPF has to expose qfi. qfi itself is not useful. When used, UPF will have to expose additional label to define the session (e.g. source interface). Label dnn is set to value of APN/DNN received in Establishment. Since SMF does not add APN/DNN to Establishment, the label is empty. When APN/DNN will be set by SMF, it should be added to sess in UPF and used in metrics on Modification and Deletion. Both datavolumeqosleveln3upf are exposed in bytes. MN is providing the transformation to kbits. fivegs_upffunction_upf_qosflows should expose the number of QFIs used in sessions, but exposes number of QER rules, which is currently equal to QFIs. The label snsssai is not provided since the slice is not available on UPF. Exposed metrics example: Standard counters: fivegs_ep_n3_gtp_indatapktn3upf 28637 fivegs_ep_n3_gtp_outdatapktn3upf 14729 fivegs_upffunction_sm_n4sessionestabreq 4 fivegs_upffunction_sm_n4sessionestabfail{cause="66"} 1 fivegs_upffunction_sm_n4sessionestabfail{cause="71"} 68 fivegs_upffunction_sm_n4sessionestabfail{cause="68"} 4 fivegs_upffunction_sm_n4sessionestabfail{cause="72"} 15 fivegs_upffunction_sm_n4sessionestabfail{cause="75"} 3 fivegs_upffunction_sm_n4sessionestabfail{cause="65"} 4 fivegs_upffunction_sm_n4sessionreport 0 fivegs_upffunction_sm_n4sessionreportsucc 0 fivegs_ep_n3_gtp_indatavolumeqosleveln3upf{qfi="1"} 39792997 fivegs_ep_n3_gtp_outdatavolumeqosleveln3upf{qfi="1"} 737548 Nonstandard gauge (added for controlling purposes - same metric as existing metric on AMF and SMF): fivegs_upffunction_upf_sessionnbr 1 Standard gauge: fivegs_upffunction_upf_qosflows{dnn=""} 1
2022-08-19 12:08:27 +00:00
upf_metrics_close();
ogs_metrics_context_final();
2021-03-15 01:01:55 +00:00
2020-04-26 19:36:05 +00:00
ogs_pfcp_xact_final();
2020-10-04 01:18:08 +00:00
upf_gtp_final();
2020-04-26 19:36:05 +00:00
upf_event_final();
}
static void upf_main(void *data)
{
ogs_fsm_t upf_sm;
int rv;
ogs_fsm_init(&upf_sm, upf_state_initial, upf_state_final, 0);
2020-04-26 19:36:05 +00:00
for ( ;; ) {
ogs_pollset_poll(ogs_app()->pollset,
ogs_timer_mgr_next(ogs_app()->timer_mgr));
2020-04-26 19:36:05 +00:00
2020-07-14 01:53:41 +00:00
/*
* After ogs_pollset_poll(), ogs_timer_mgr_expire() must be called.
2020-04-26 19:36:05 +00:00
*
2020-07-14 01:53:41 +00:00
* The reason is why ogs_timer_mgr_next() can get the corrent value
* when ogs_timer_stop() is called internally in ogs_timer_mgr_expire().
*
* You should not use event-queue before ogs_timer_mgr_expire().
* In this case, ogs_timer_mgr_expire() does not work
* because 'if rv == OGS_DONE' statement is exiting and
* not calling ogs_timer_mgr_expire().
*/
ogs_timer_mgr_expire(ogs_app()->timer_mgr);
2020-04-26 19:36:05 +00:00
for ( ;; ) {
upf_event_t *e = NULL;
rv = ogs_queue_trypop(ogs_app()->queue, (void**)&e);
2020-04-26 19:36:05 +00:00
ogs_assert(rv != OGS_ERROR);
if (rv == OGS_DONE)
goto done;
if (rv == OGS_RETRY)
break;
ogs_assert(e);
ogs_fsm_dispatch(&upf_sm, e);
upf_event_free(e);
}
}
done:
ogs_fsm_fini(&upf_sm, 0);
}