diff options
author | Ivan Nardi <12729895+IvanNardi@users.noreply.github.com> | 2025-01-30 21:26:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-30 21:26:47 +0100 |
commit | c669bb31402ffc52aba774163d8a7e25eba00fc5 (patch) | |
tree | 7f15ecdd6c9230887885990a93a365a2b2ed3b26 /src/lib/protocols | |
parent | aacade6d9571bdf6fc9bd0b5cbbafb65d5123f8f (diff) |
DNS: fix relationship between FPC and subclassification (#2702)
Allow optimal FPC even if DNS subclassification is disabled
Diffstat (limited to 'src/lib/protocols')
-rw-r--r-- | src/lib/protocols/dns.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/lib/protocols/dns.c b/src/lib/protocols/dns.c index ce991735d..bd55f19e7 100644 --- a/src/lib/protocols/dns.c +++ b/src/lib/protocols/dns.c @@ -819,16 +819,19 @@ static void ndpi_search_dns(struct ndpi_detection_module_struct *ndpi_struct, st } if(len > 0) { - if(ndpi_struct->cfg.dns_subclassification_enabled) { + if(ndpi_struct->cfg.dns_subclassification_enabled || ndpi_struct->cfg.fpc_enabled) { ndpi_protocol_match_result ret_match; - ret.proto.app_protocol = ndpi_match_host_subprotocol(ndpi_struct, flow, + /* Avoid writing on flow (i.e. updating classification) if subclassification is disabled */ + ret.proto.app_protocol = ndpi_match_host_subprotocol(ndpi_struct, ndpi_struct->cfg.dns_subclassification_enabled ? flow : NULL, flow->host_server_name, strlen(flow->host_server_name), &ret_match, NDPI_PROTOCOL_DNS); /* Add to FPC DNS cache */ - if(ret.proto.app_protocol != NDPI_PROTOCOL_UNKNOWN && + if(ndpi_struct->cfg.fpc_enabled && + ret.proto.app_protocol != NDPI_PROTOCOL_UNKNOWN && + ret.proto.app_protocol != NDPI_PROTOCOL_DNS && (flow->protos.dns.rsp_type == 0x1 || flow->protos.dns.rsp_type == 0x1c) && /* A, AAAA */ ndpi_struct->fpc_dns_cache) { ndpi_lru_add_to_cache(ndpi_struct->fpc_dns_cache, @@ -836,6 +839,9 @@ static void ndpi_search_dns(struct ndpi_detection_module_struct *ndpi_struct, st ndpi_get_current_time(flow)); } + if(!ndpi_struct->cfg.dns_subclassification_enabled) + ret.proto.app_protocol = NDPI_PROTOCOL_UNKNOWN; + if(ret.proto.app_protocol == NDPI_PROTOCOL_UNKNOWN) ret.proto.master_protocol = checkDNSSubprotocol(s_port, d_port); else |