mirror of
https://github.com/open5gs/open5gs.git
synced 2026-05-05 15:24:14 +00:00
[SMF/UPF] Changes subnet configuration (#2975)
The way subnet is set up has changed as shown below.
```
<OLD Format>
smf:
session:
- subnet: 10.45.0.1/16
<NEW Format>
smf:
session:
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
```
For more information, please refer to Pull Request #2975.
This commit is contained in:
parent
2b6369e9d9
commit
a6830b30a0
27 changed files with 202 additions and 109 deletions
|
|
@ -743,6 +743,7 @@ int ogs_pfcp_context_parse_config(const char *local, const char *remote)
|
|||
do {
|
||||
ogs_pfcp_subnet_t *subnet = NULL;
|
||||
const char *ipstr = NULL;
|
||||
const char *gateway = NULL;
|
||||
const char *mask_or_numbits = NULL;
|
||||
const char *dnn = NULL;
|
||||
const char *dev = self.tun_ifname;
|
||||
|
|
@ -781,6 +782,8 @@ int ogs_pfcp_context_parse_config(const char *local, const char *remote)
|
|||
mask_or_numbits = (const char *)v;
|
||||
}
|
||||
}
|
||||
} else if (!strcmp(subnet_key, "gateway")) {
|
||||
gateway = ogs_yaml_iter_value(&subnet_iter);
|
||||
} else if (!strcmp(subnet_key, "apn") ||
|
||||
!strcmp(subnet_key, "dnn")) {
|
||||
dnn = ogs_yaml_iter_value(&subnet_iter);
|
||||
|
|
@ -825,7 +828,7 @@ int ogs_pfcp_context_parse_config(const char *local, const char *remote)
|
|||
}
|
||||
|
||||
subnet = ogs_pfcp_subnet_add(
|
||||
ipstr, mask_or_numbits, dnn, dev);
|
||||
ipstr, mask_or_numbits, gateway, dnn, dev);
|
||||
ogs_assert(subnet);
|
||||
|
||||
subnet->num_of_range = num;
|
||||
|
|
@ -2150,7 +2153,7 @@ ogs_pfcp_dev_t *ogs_pfcp_dev_find_by_ifname(const char *ifname)
|
|||
|
||||
ogs_pfcp_subnet_t *ogs_pfcp_subnet_add(
|
||||
const char *ipstr, const char *mask_or_numbits,
|
||||
const char *dnn, const char *ifname)
|
||||
const char *gateway, const char *dnn, const char *ifname)
|
||||
{
|
||||
int rv;
|
||||
ogs_pfcp_dev_t *dev = NULL;
|
||||
|
|
@ -2179,6 +2182,43 @@ ogs_pfcp_subnet_t *ogs_pfcp_subnet_add(
|
|||
|
||||
subnet->family = subnet->gw.family;
|
||||
subnet->prefixlen = atoi(mask_or_numbits);
|
||||
|
||||
if (memcmp(subnet->gw.sub, subnet->sub.sub,
|
||||
sizeof(subnet->gw.sub)) != 0) {
|
||||
char *subnet_string = NULL;
|
||||
|
||||
if (subnet->family == AF_INET) {
|
||||
subnet_string = ogs_ipv4_to_string(subnet->sub.sub[0]);
|
||||
ogs_assert(subnet_string);
|
||||
} else if (subnet->family == AF_INET6) {
|
||||
subnet_string = ogs_ipv6addr_to_string(
|
||||
(uint8_t*)&subnet->sub.sub[0]);
|
||||
ogs_assert(subnet_string);
|
||||
}
|
||||
|
||||
ogs_warn("Please change the configuration files of "
|
||||
"smf.yaml and upf.yaml as below.");
|
||||
ogs_log_print(OGS_LOG_WARN, "\n<OLD Format>\n");
|
||||
ogs_log_print(OGS_LOG_WARN, "smf:\n");
|
||||
ogs_log_print(OGS_LOG_WARN, " session:\n");
|
||||
ogs_log_print(OGS_LOG_WARN, " - subnet: %s/%s\n",
|
||||
ipstr, mask_or_numbits);
|
||||
ogs_log_print(OGS_LOG_WARN, "\n<NEW Format>\n");
|
||||
ogs_log_print(OGS_LOG_WARN, "smf:\n");
|
||||
ogs_log_print(OGS_LOG_WARN, " session:\n");
|
||||
ogs_log_print(OGS_LOG_WARN, " - subnet: %s/%s\n",
|
||||
subnet_string ? subnet_string : "Unknown", mask_or_numbits);
|
||||
if (subnet->family == AF_INET)
|
||||
ogs_log_print(OGS_LOG_WARN, " gateway: %s", ipstr);
|
||||
ogs_log_print(OGS_LOG_WARN, "\n\n\n");
|
||||
|
||||
ogs_free(subnet_string);
|
||||
}
|
||||
}
|
||||
|
||||
if (gateway) {
|
||||
rv = ogs_ipsubnet(&subnet->gw, gateway, NULL);
|
||||
ogs_assert(rv == OGS_OK);
|
||||
}
|
||||
|
||||
if (dnn)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue