Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change PFCP node search order, fix typo, add feature to disable RR for a node #560

Merged
merged 3 commits into from Sep 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 12 additions & 7 deletions configs/open5gs/sgwc.yaml.in
Expand Up @@ -61,15 +61,20 @@ sgwc:
# pfcp:
# addr: 127.0.0.6
#
# <UPF_SELECTION_MODE - EPC only>
# <SGWU_SELECTION_MODE - EPC only>
#
# 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 UPF selection by eNodeB TAC
# o SGWU selection by eNodeB TAC
# (either single TAC or multiple TACs, DECIMAL representation)
#
# sgwu:
Expand All @@ -79,24 +84,24 @@ sgwc:
# - addr: 127.0.0.12
# tac: [3,5,8]
#
# o UPF selection by UE's DNN/APN (either single DNN/APN or multiple DNNs/APNs)
# o SGWU selection by UE's APN (either single APN or multiple APNs)
#
# sgwu:
# pfcp:
# - addr: 127.0.0.6
# dnn: ims
# apn: ims
# - addr: 127.0.0.12
# apn: [internet, web]
#
# o UPF selection by CellID(e_cell_id: 28bit, nr_cell_id: 36bit)
# (either single enb_id or multiple enb_ids, HEX representation)
# o SGWU selection by CellID(e_cell_id: 28bit)
# (either single e_cell_id or multiple e_cell_id, HEX representation)
#
# sgwu:
# pfcp:
# - addr: 127.0.0.6
# e_cell_id: 463
# - addr: 127.0.0.12
# nr_cell_id: [123456789, 9413]
# e_cell_id: [123456789, 9413]
#
sgwu:
pfcp:
Expand Down
5 changes: 5 additions & 0 deletions configs/open5gs/smf.yaml.in
Expand Up @@ -246,10 +246,15 @@ nrf:
# <UPF_SELECTION_MODE - EPC only>
#
# o Round-Robin
# (note that round robin can be disabled for a particular node
# by setting flag 'rr' to 0)
#
# upf:
# pfcp:
# - addr: 127.0.0.7
# - addr: 127.0.0.12
# rr: 0
# - addr: 127.0.0.19
#
# o UPF selection by eNodeB TAC
# (either single TAC or multiple TACs, DECIMAL representation)
Expand Down
6 changes: 6 additions & 0 deletions lib/pfcp/context.c
Expand Up @@ -408,6 +408,7 @@ int ogs_pfcp_context_parse_config(const char *local, const char *remote)
uint8_t num_of_e_cell_id = 0;
uint32_t nr_cell_id[OGS_MAX_NUM_OF_CELL_ID] = {0,};
uint8_t num_of_nr_cell_id = 0;
uint8_t rr_enable = 1; /* full list RR enabled by default */

if (ogs_yaml_iter_type(&pfcp_array) ==
YAML_MAPPING_NODE) {
Expand Down Expand Up @@ -570,6 +571,9 @@ int ogs_pfcp_context_parse_config(const char *local, const char *remote)
} while (
ogs_yaml_iter_type(&nr_cell_id_iter) ==
YAML_SEQUENCE_NODE);
} else if (!strcmp(pfcp_key, "rr")) {
const char *v = ogs_yaml_iter_value(&pfcp_iter);
if (v) rr_enable = atoi(v);
} else
ogs_warn("unknown key `%s`", pfcp_key);
}
Expand Down Expand Up @@ -609,6 +613,8 @@ int ogs_pfcp_context_parse_config(const char *local, const char *remote)
if (num_of_nr_cell_id != 0)
memcpy(node->nr_cell_id, nr_cell_id,
sizeof(node->nr_cell_id));

node->rr_enable = rr_enable;
} while (ogs_yaml_iter_type(&pfcp_array) ==
YAML_SEQUENCE_NODE);
}
Expand Down
1 change: 1 addition & 0 deletions lib/pfcp/context.h
Expand Up @@ -93,6 +93,7 @@ typedef struct ogs_pfcp_node_s {
uint8_t num_of_e_cell_id;
uint32_t nr_cell_id[OGS_MAX_NUM_OF_CELL_ID];
uint8_t num_of_nr_cell_id;
uint8_t rr_enable; /* flag to enable/ disable full list RR for this node */

ogs_list_t gtpu_resource_list; /* User Plane IP Resource Information */
} ogs_pfcp_node_t;
Expand Down
26 changes: 17 additions & 9 deletions src/sgwc/context.c
Expand Up @@ -431,14 +431,14 @@ static bool compare_ue_info(ogs_pfcp_node_t *node, sgwc_sess_t *sess)
sgwc_ue = sess->sgwc_ue;
ogs_assert(sgwc_ue);

for (i = 0; i < node->num_of_tac; i++)
if (node->tac[i] == sgwc_ue->e_tai.tac) return true;
for (i = 0; i < node->num_of_apn; i++)
if (strcmp(node->apn[i], sess->pdn.apn) == 0) return true;

for (i = 0; i < node->num_of_e_cell_id; i++)
if (node->e_cell_id[i] == sgwc_ue->e_cgi.cell_id) return true;

for (i = 0; i < node->num_of_apn; i++)
if (strcmp(node->apn[i], sess->pdn.apn) == 0) return true;
for (i = 0; i < node->num_of_tac; i++)
if (node->tac[i] == sgwc_ue->e_tai.tac) return true;

return false;
}
Expand All @@ -461,8 +461,12 @@ static ogs_pfcp_node_t *selected_sgwu_node(
if (OGS_FSM_CHECK(&node->sm, sgwc_pfcp_state_associated) &&
compare_ue_info(node, sess) == true) return node;
} else {
if (OGS_FSM_CHECK(&node->sm, sgwc_pfcp_state_associated))
return node;
/*
* 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;
}
}
/* cyclic search from top to current position */
Expand All @@ -472,8 +476,12 @@ static ogs_pfcp_node_t *selected_sgwu_node(
if (OGS_FSM_CHECK(&node->sm, sgwc_pfcp_state_associated) &&
compare_ue_info(node, sess) == true) return node;
} else {
if (OGS_FSM_CHECK(&node->sm, sgwc_pfcp_state_associated))
return node;
/*
* 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;
}
}

Expand All @@ -487,7 +495,7 @@ static ogs_pfcp_node_t *selected_sgwu_node(
RR = 1;
}

ogs_error("No SGWUs are PFCP associated");
ogs_error("No SGWUs are PFCP associated that are suited to RR");
return ogs_list_first(&ogs_pfcp_self()->peer_list);
}

Expand Down
28 changes: 18 additions & 10 deletions src/smf/context.c
Expand Up @@ -611,18 +611,18 @@ static bool compare_ue_info(ogs_pfcp_node_t *node, smf_sess_t *sess)
ogs_assert(node);
ogs_assert(sess);

for (i = 0; i < node->num_of_tac; i++)
if (node->tac[i] == sess->e_tai.tac ||
node->tac[i] == sess->nr_tai.tac.v) return true;
for (i = 0; i < node->num_of_apn; i++)
if (strcmp(node->apn[i], sess->pdn.apn) == 0) return true;

for (i = 0; i < node->num_of_e_cell_id; i++)
if (node->e_cell_id[i] == sess->e_cgi.cell_id) return true;

for (i = 0; i < node->num_of_nr_cell_id; i++)
if (node->nr_cell_id[i] == sess->nr_cgi.cell_id) return true;

for (i = 0; i < node->num_of_apn; i++)
if (strcmp(node->apn[i], sess->pdn.apn) == 0) return true;
for (i = 0; i < node->num_of_tac; i++)
if ((node->tac[i] == sess->e_tai.tac) ||
(node->tac[i] == sess->nr_tai.tac.v)) return true;

return false;
}
Expand All @@ -645,8 +645,12 @@ static ogs_pfcp_node_t *selected_upf_node(
if (OGS_FSM_CHECK(&node->sm, smf_pfcp_state_associated) &&
compare_ue_info(node, sess) == true) return node;
} else {
if (OGS_FSM_CHECK(&node->sm, smf_pfcp_state_associated))
return node;
/*
* 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;
}
}
/* cyclic search from top to current position */
Expand All @@ -656,8 +660,12 @@ static ogs_pfcp_node_t *selected_upf_node(
if (OGS_FSM_CHECK(&node->sm, smf_pfcp_state_associated) &&
compare_ue_info(node, sess) == true) return node;
} else {
if (OGS_FSM_CHECK(&node->sm, smf_pfcp_state_associated))
return node;
/*
* 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;
}
}

Expand All @@ -671,7 +679,7 @@ static ogs_pfcp_node_t *selected_upf_node(
RR = 1;
}

ogs_error("No UPFs are PFCP associated");
ogs_error("No UPFs are PFCP associated that are suited to RR");
return ogs_list_first(&ogs_pfcp_self()->peer_list);
}

Expand Down