[PFCP] Reduce DNS spam for FQDN nodes (#3431) (#3664)

Each received PFCP message triggered ogs_pfcp_node_find(), causing a DNS
resolution if node_id was FQDN. Under heavy traffic, this could lead to
excessive DNS queries.

- Implement a 300-second refresh interval to avoid repeated DNS lookups.
- Store last_dns_refresh in each node to defer new queries until needed.
- Treat config-based nodes with no Node ID as UNKNOWN, matching them by IP
  alone until ogs_pfcp_node_merge() updates their ID.
- Validate IPv4, IPv6, or FQDN types in ogs_pfcp_node_merge() and reject
  invalid IDs.
- Provide inline code comments for clarity and maintainability.
This commit is contained in:
Sukchan Lee 2025-01-18 12:15:00 +09:00
parent ba6a84d1b3
commit 9c370ff89a
5 changed files with 193 additions and 91 deletions

View file

@ -84,17 +84,20 @@ typedef struct ogs_pfcp_context_s {
typedef struct ogs_pfcp_node_s {
ogs_lnode_t lnode; /* A node of list_t */
ogs_sockaddr_t *config_addr; /* Configured addresses */
ogs_sockaddr_t *config_addr; /* Configured addresses */
ogs_pfcp_node_id_t node_id; /* PFCP node ID */
/* List of addresses:: final merged address list */
ogs_sockaddr_t *addr_list;
ogs_sockaddr_t *addr_list;
/*
* Iterator for round-robin sendto operations.
* Points to the current address in the round-robin sequence.
*/
ogs_sockaddr_t *current_addr;
ogs_sockaddr_t *current_addr;
/* Timestamp of last DNS refresh for FQDN nodes. */
ogs_time_t last_dns_refresh;
ogs_list_t local_list;
ogs_list_t remote_list;
@ -417,7 +420,7 @@ int ogs_pfcp_node_merge(ogs_pfcp_node_t *node,
ogs_pfcp_node_id_t *node_id, ogs_sockaddr_t *from);
void ogs_pfcp_node_remove(ogs_list_t *list, ogs_pfcp_node_t *node);
void ogs_pfcp_node_remove_all(ogs_list_t *list);
int ogs_pfcp_node_id_compare(
bool ogs_pfcp_node_id_compare(
const ogs_pfcp_node_id_t *id1, const ogs_pfcp_node_id_t *id2);
ogs_gtpu_resource_t *ogs_pfcp_find_gtpu_resource(ogs_list_t *list,