From fc27f7499b29ae2d191272312f3d89f88d4bdbf6 Mon Sep 17 00:00:00 2001 From: Sukchan Lee Date: Sat, 24 Apr 2021 20:56:14 +0900 Subject: [PATCH] [SMF/SGW-C] fix the PFCP RR selection (#953) The configuration has changed. PFCP node rr=0 is removed as shown below. sgwc: pfcp rr: 0 <-- Removed Introduced a new configuration method for SMF/SGW-C parameter: no_pfcp_rr_select: true By default, PFCP round robin selection is allowed. The above parameters prohibit selecting PFCP in a round robin manner. --- configs/open5gs/sgwc.yaml.in | 8 +++--- configs/open5gs/smf.yaml.in | 3 +++ lib/app/ogs-context.c | 3 +++ lib/app/ogs-context.h | 2 ++ src/sgwc/context.c | 50 ++++++++++++------------------------ src/smf/context.c | 50 ++++++++++++------------------------ 6 files changed, 45 insertions(+), 71 deletions(-) diff --git a/configs/open5gs/sgwc.yaml.in b/configs/open5gs/sgwc.yaml.in index b19b6fcc6..2ff89e786 100644 --- a/configs/open5gs/sgwc.yaml.in +++ b/configs/open5gs/sgwc.yaml.in @@ -67,15 +67,10 @@ sgwc: # # # -# o Round-Robin -# (note that round robin can be disabled for a particular node -# by setting flag 'rr' to 0) -# # sgwu: # pfcp: # - addr: 127.0.0.6 # - addr: 127.0.0.12 -# rr: 0 # - addr: 127.0.0.18 # # o SGWU selection by eNodeB TAC @@ -126,6 +121,9 @@ sgwu: # o Prefer IPv4 instead of IPv6 for estabishing new GTP connections. # prefer_ipv4: true # +# o Disable selection of SGW-U PFCP in Round-Robin manner +# no_pfcp_rr_select: true +# parameter: # diff --git a/configs/open5gs/smf.yaml.in b/configs/open5gs/smf.yaml.in index 728b0835f..111764eb2 100644 --- a/configs/open5gs/smf.yaml.in +++ b/configs/open5gs/smf.yaml.in @@ -444,6 +444,9 @@ upf: # o Prefer IPv4 instead of IPv6 for estabishing new GTP connections. # prefer_ipv4: true # +# o Disable selection of UPF PFCP in Round-Robin manner +# no_pfcp_rr_select: true +# parameter: # diff --git a/lib/app/ogs-context.c b/lib/app/ogs-context.c index 708d95bdc..4eedfdd54 100644 --- a/lib/app/ogs-context.c +++ b/lib/app/ogs-context.c @@ -354,6 +354,9 @@ int ogs_app_context_parse_config(void) parameter_key, "no_ipv4v6_local_addr_in_packet_filter")) { self.parameter.no_ipv4v6_local_addr_in_packet_filter = ogs_yaml_iter_bool(¶meter_iter); + } else if (!strcmp(parameter_key, "no_pfcp_rr_select")) { + self.parameter.no_pfcp_rr_select = + ogs_yaml_iter_bool(¶meter_iter); } else ogs_warn("unknown key `%s`", parameter_key); } diff --git a/lib/app/ogs-context.h b/lib/app/ogs-context.h index f6045a93a..e6af5e1e7 100644 --- a/lib/app/ogs-context.h +++ b/lib/app/ogs-context.h @@ -75,6 +75,8 @@ typedef struct ogs_app_context_s { int use_openair; int no_ipv4v6_local_addr_in_packet_filter; + + int no_pfcp_rr_select; } parameter; struct { diff --git a/src/sgwc/context.c b/src/sgwc/context.c index 8c7095740..c19d53450 100644 --- a/src/sgwc/context.c +++ b/src/sgwc/context.c @@ -332,48 +332,32 @@ static ogs_pfcp_node_t *selected_sgwu_node( ogs_assert(current); ogs_assert(sess); - int RR = 0, selected = 0; + /* continue search from current position */ + next = ogs_list_next(current); + for (node = next; node; node = ogs_list_next(node)) { + if (OGS_FSM_CHECK(&node->sm, sgwc_pfcp_state_associated) && + compare_ue_info(node, sess) == true) return node; + } + /* cyclic search from top to current position */ + for (node = ogs_list_first(&ogs_pfcp_self()->pfcp_peer_list); + node != next; node = ogs_list_next(node)) { + if (OGS_FSM_CHECK(&node->sm, sgwc_pfcp_state_associated) && + compare_ue_info(node, sess) == true) return node; + } - while (!selected) { + if (ogs_app()->parameter.no_pfcp_rr_select == 0) { /* continue search from current position */ next = ogs_list_next(current); for (node = next; node; node = ogs_list_next(node)) { - if (!RR) { - if (OGS_FSM_CHECK(&node->sm, sgwc_pfcp_state_associated) && - compare_ue_info(node, sess) == true) return node; - } else { - /* - * we are in RR mode - use next PFCP associated - * node that is suited for full list RR - */ - if (OGS_FSM_CHECK(&node->sm, sgwc_pfcp_state_associated) && - node->rr_enable == 1) return node; - } + if (OGS_FSM_CHECK(&node->sm, sgwc_pfcp_state_associated)) + return node; } /* cyclic search from top to current position */ for (node = ogs_list_first(&ogs_pfcp_self()->pfcp_peer_list); node != next; node = ogs_list_next(node)) { - if (!RR) { - if (OGS_FSM_CHECK(&node->sm, sgwc_pfcp_state_associated) && - compare_ue_info(node, sess) == true) return node; - } else { - /* - * we are in RR mode - use next PFCP associated - * node that is suited for full list RR - */ - if (OGS_FSM_CHECK(&node->sm, sgwc_pfcp_state_associated) && - node->rr_enable == 1) return node; - } + if (OGS_FSM_CHECK(&node->sm, sgwc_pfcp_state_associated)) + return node; } - - /* if a round robin search has already been carried out */ - if (RR) break; - - /* - * re-run search in round robin mode, - * find and use next PFCP associated node - */ - RR = 1; } ogs_error("No SGWUs are PFCP associated that are suited to RR"); diff --git a/src/smf/context.c b/src/smf/context.c index 61634edfd..255ef8015 100644 --- a/src/smf/context.c +++ b/src/smf/context.c @@ -884,48 +884,32 @@ static ogs_pfcp_node_t *selected_upf_node( ogs_assert(current); ogs_assert(sess); - int RR = 0, selected = 0; + /* continue search from current position */ + next = ogs_list_next(current); + for (node = next; node; node = ogs_list_next(node)) { + if (OGS_FSM_CHECK(&node->sm, smf_pfcp_state_associated) && + compare_ue_info(node, sess) == true) return node; + } + /* cyclic search from top to current position */ + for (node = ogs_list_first(&ogs_pfcp_self()->pfcp_peer_list); + node != next; node = ogs_list_next(node)) { + if (OGS_FSM_CHECK(&node->sm, smf_pfcp_state_associated) && + compare_ue_info(node, sess) == true) return node; + } - while (!selected) { + if (ogs_app()->parameter.no_pfcp_rr_select == 0) { /* continue search from current position */ next = ogs_list_next(current); for (node = next; node; node = ogs_list_next(node)) { - if (!RR) { - if (OGS_FSM_CHECK(&node->sm, smf_pfcp_state_associated) && - compare_ue_info(node, sess) == true) return node; - } else { - /* - * we are in RR mode - use next PFCP associated - * node that is suited for full list RR - */ - if (OGS_FSM_CHECK(&node->sm, smf_pfcp_state_associated) && - node->rr_enable == 1) return node; - } + if (OGS_FSM_CHECK(&node->sm, smf_pfcp_state_associated)) + return node; } /* cyclic search from top to current position */ for (node = ogs_list_first(&ogs_pfcp_self()->pfcp_peer_list); node != next; node = ogs_list_next(node)) { - if (!RR) { - if (OGS_FSM_CHECK(&node->sm, smf_pfcp_state_associated) && - compare_ue_info(node, sess) == true) return node; - } else { - /* - * we are in RR mode - use next PFCP associated - * node that is suited for full list RR - */ - if (OGS_FSM_CHECK(&node->sm, smf_pfcp_state_associated) && - node->rr_enable == 1) return node; - } + if (OGS_FSM_CHECK(&node->sm, smf_pfcp_state_associated)) + return node; } - - /* if a round robin search has already been carried out */ - if (RR) break; - - /* - * re-run search in round robin mode, - * find and use next PFCP associated node - */ - RR = 1; } ogs_error("No UPFs are PFCP associated that are suited to RR");