From aaa528b2e8be012c7c67299af41e227d2bc4dc45 Mon Sep 17 00:00:00 2001 From: Ivan Nardi <12729895+IvanNardi@users.noreply.github.com> Date: Mon, 23 Jun 2025 15:29:32 +0200 Subject: If `NDPI_KNOWN_PROTOCOL_ON_NON_STANDARD_PORT` risk is disabled, avoid some work (#2899) --- src/lib/ndpi_main.c | 3 +++ src/lib/ndpi_utils.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'src/lib') diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c index 57de07ce6..117689656 100644 --- a/src/lib/ndpi_main.c +++ b/src/lib/ndpi_main.c @@ -9678,6 +9678,9 @@ static void check_proto_on_non_std_port_risk(struct ndpi_detection_module_struct default_ports_tree_node_t *found; ndpi_port_range *default_ports; + if(!is_flowrisk_enabled(ndpi_str, NDPI_KNOWN_PROTOCOL_ON_NON_STANDARD_PORT)) + return; + if(packet->udp) found = ndpi_get_guessed_protocol_id(ndpi_str, IPPROTO_UDP, ntohs(flow->c_port), diff --git a/src/lib/ndpi_utils.c b/src/lib/ndpi_utils.c index 4e3d9f582..8844bf7d7 100644 --- a/src/lib/ndpi_utils.c +++ b/src/lib/ndpi_utils.c @@ -3020,7 +3020,7 @@ static u_int8_t ndpi_check_ipv6_exception(struct ndpi_detection_module_struct *n /* ********************************************************************************* */ -static int is_flowrisk_enabled(struct ndpi_detection_module_struct *ndpi_str, ndpi_risk_enum flowrisk_id) +int is_flowrisk_enabled(struct ndpi_detection_module_struct *ndpi_str, ndpi_risk_enum flowrisk_id) { if(ndpi_bitmask_is_set(&ndpi_str->cfg.flowrisk_bitmask, flowrisk_id) == 0) return 0; -- cgit v1.2.3