mirror of
https://github.com/open5gs/open5gs.git
synced 2025-11-01 20:44:06 +00:00
[GTP/PFCP] Enable server to bind to multiple addresses via FQDN resolution (#3431)
Modified the `ogs_gtp/pfcp_context_parse_config` function to iterate through all configured GTP/PFCP server addresses. When a Fully Qualified Domain Name (FQDN) resolves to multiple IP addresses, the server now binds and listens on each IP address individually. These modifications enhance the flexibility and reliability of the GTP/PFCP server within Open5GS, allowing it to handle multiple network interfaces and redundant IP configurations as required.
This commit is contained in:
@@ -200,6 +200,7 @@ int ogs_gtp_context_parse_config(const char *local, const char *remote)
|
||||
server_key);
|
||||
}
|
||||
|
||||
/* Add address information */
|
||||
addr = NULL;
|
||||
for (i = 0; i < num; i++) {
|
||||
rv = ogs_addaddrinfo(&addr,
|
||||
@@ -207,17 +208,30 @@ int ogs_gtp_context_parse_config(const char *local, const char *remote)
|
||||
ogs_assert(rv == OGS_OK);
|
||||
}
|
||||
|
||||
/* Add each address as a separate socknode */
|
||||
if (addr) {
|
||||
if (ogs_global_conf()->parameter.
|
||||
no_ipv4 == 0)
|
||||
ogs_socknode_add(
|
||||
&self.gtpc_list, AF_INET, addr,
|
||||
is_option ? &option : NULL);
|
||||
if (ogs_global_conf()->parameter.
|
||||
no_ipv6 == 0)
|
||||
ogs_socknode_add(
|
||||
&self.gtpc_list6, AF_INET6, addr,
|
||||
is_option ? &option : NULL);
|
||||
ogs_sockaddr_t *current = addr;
|
||||
while (current) {
|
||||
if (current->ogs_sa_family ==
|
||||
AF_INET &&
|
||||
ogs_global_conf()->
|
||||
parameter.no_ipv4 == 0) {
|
||||
ogs_socknode_add(&self.gtpc_list,
|
||||
AF_INET, current,
|
||||
is_option ?
|
||||
&option : NULL);
|
||||
}
|
||||
if (current->ogs_sa_family ==
|
||||
AF_INET6 &&
|
||||
ogs_global_conf()->
|
||||
parameter.no_ipv6 == 0) {
|
||||
ogs_socknode_add(&self.gtpc_list6,
|
||||
AF_INET6, current,
|
||||
is_option ?
|
||||
&option : NULL);
|
||||
}
|
||||
current = current->next;
|
||||
}
|
||||
ogs_freeaddrinfo(addr);
|
||||
}
|
||||
|
||||
@@ -417,16 +431,28 @@ int ogs_gtp_context_parse_config(const char *local, const char *remote)
|
||||
ogs_list_init(&list6);
|
||||
|
||||
if (addr) {
|
||||
if (ogs_global_conf()->parameter.
|
||||
no_ipv4 == 0)
|
||||
ogs_socknode_add(
|
||||
&list, AF_INET, addr,
|
||||
is_option ? &option : NULL);
|
||||
if (ogs_global_conf()->parameter.
|
||||
no_ipv6 == 0)
|
||||
ogs_socknode_add(
|
||||
&list6, AF_INET6, addr,
|
||||
is_option ? &option : NULL);
|
||||
ogs_sockaddr_t *current = addr;
|
||||
while (current) {
|
||||
if (current->ogs_sa_family ==
|
||||
AF_INET &&
|
||||
ogs_global_conf()->
|
||||
parameter.no_ipv4 == 0) {
|
||||
ogs_socknode_add(&list,
|
||||
AF_INET, current,
|
||||
is_option ?
|
||||
&option : NULL);
|
||||
}
|
||||
if (current->ogs_sa_family ==
|
||||
AF_INET6 &&
|
||||
ogs_global_conf()->
|
||||
parameter.no_ipv6 == 0) {
|
||||
ogs_socknode_add(&list6,
|
||||
AF_INET6, current,
|
||||
is_option ?
|
||||
&option : NULL);
|
||||
}
|
||||
current = current->next;
|
||||
}
|
||||
ogs_freeaddrinfo(addr);
|
||||
}
|
||||
|
||||
|
||||
@@ -371,6 +371,7 @@ int ogs_pfcp_context_parse_config(const char *local, const char *remote)
|
||||
server_key);
|
||||
}
|
||||
|
||||
/* Add address information */
|
||||
addr = NULL;
|
||||
for (i = 0; i < num; i++) {
|
||||
rv = ogs_addaddrinfo(&addr,
|
||||
@@ -378,20 +379,34 @@ int ogs_pfcp_context_parse_config(const char *local, const char *remote)
|
||||
ogs_assert(rv == OGS_OK);
|
||||
}
|
||||
|
||||
/* Add each address as a separate socknode */
|
||||
if (addr) {
|
||||
if (ogs_global_conf()->
|
||||
parameter.no_ipv4 == 0)
|
||||
ogs_socknode_add(
|
||||
&self.pfcp_list, AF_INET, addr,
|
||||
is_option ? &option : NULL);
|
||||
if (ogs_global_conf()->
|
||||
parameter.no_ipv6 == 0)
|
||||
ogs_socknode_add(
|
||||
&self.pfcp_list6, AF_INET6, addr,
|
||||
is_option ? &option : NULL);
|
||||
ogs_sockaddr_t *current = addr;
|
||||
while (current) {
|
||||
if (current->ogs_sa_family ==
|
||||
AF_INET &&
|
||||
ogs_global_conf()->
|
||||
parameter.no_ipv4 == 0) {
|
||||
ogs_socknode_add(&self.pfcp_list,
|
||||
AF_INET, current,
|
||||
is_option ?
|
||||
&option : NULL);
|
||||
}
|
||||
if (current->ogs_sa_family ==
|
||||
AF_INET6 &&
|
||||
ogs_global_conf()->
|
||||
parameter.no_ipv6 == 0) {
|
||||
ogs_socknode_add(&self.pfcp_list6,
|
||||
AF_INET6, current,
|
||||
is_option ?
|
||||
&option : NULL);
|
||||
}
|
||||
current = current->next;
|
||||
}
|
||||
ogs_freeaddrinfo(addr);
|
||||
}
|
||||
|
||||
/* Process advertise addresses if needed */
|
||||
addr = NULL;
|
||||
for (i = 0; i < num_of_advertise; i++) {
|
||||
rv = ogs_addaddrinfo(&addr,
|
||||
@@ -420,6 +435,7 @@ int ogs_pfcp_context_parse_config(const char *local, const char *remote)
|
||||
ogs_freeaddrinfo(addr);
|
||||
}
|
||||
|
||||
/* Bind to device if specified */
|
||||
if (dev) {
|
||||
rv = ogs_socknode_probe(
|
||||
ogs_global_conf()->
|
||||
|
||||
Reference in New Issue
Block a user