From ff4e010501ff057e353c7f1d9785b5caadceade3 Mon Sep 17 00:00:00 2001 From: Ivan Nardi <12729895+IvanNardi@users.noreply.github.com> Date: Thu, 7 Jul 2022 17:49:35 +0200 Subject: Avoid spurious calls to extra dissection (#1648) If the extra callabck is not set, calling the extra dissection is only a waste of resources... --- src/lib/ndpi_main.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c index ee338ce76..795a7fe80 100644 --- a/src/lib/ndpi_main.c +++ b/src/lib/ndpi_main.c @@ -6097,8 +6097,10 @@ ndpi_protocol ndpi_detection_process_packet(struct ndpi_detection_module_struct return(ret); } - if(ndpi_str->max_packets_to_process > 0 && flow->num_processed_pkts >= ndpi_str->max_packets_to_process) + if(ndpi_str->max_packets_to_process > 0 && flow->num_processed_pkts >= ndpi_str->max_packets_to_process) { + flow->extra_packets_func = NULL; /* To allow ndpi_extra_dissection_possible() to fail */ return(ret); /* Avoid spending too much time with this flow */ + } flow->num_processed_pkts++; @@ -8043,6 +8045,9 @@ u_int8_t ndpi_extra_dissection_possible(struct ndpi_detection_module_struct *ndp proto); #endif + if(!flow->extra_packets_func) + return(0); + switch(proto) { case NDPI_PROTOCOL_TLS: case NDPI_PROTOCOL_DTLS: @@ -8091,19 +8096,10 @@ u_int8_t ndpi_extra_dissection_possible(struct ndpi_detection_module_struct *ndp break; case NDPI_PROTOCOL_SKYPE_TEAMS: - if(flow->extra_packets_func) - return(1); - break; - case NDPI_PROTOCOL_QUIC: - if(flow->extra_packets_func) - return(1); - break; - case NDPI_PROTOCOL_KERBEROS: case NDPI_PROTOCOL_SNMP: - if(flow->extra_packets_func) - return(1); + return(1); break; case NDPI_PROTOCOL_BITTORRENT: -- cgit v1.2.3