From 1b98bec0abb61fb86180a13869434da8519bd261 Mon Sep 17 00:00:00 2001 From: Ivan Nardi <12729895+IvanNardi@users.noreply.github.com> Date: Wed, 18 Jan 2023 18:18:36 +0100 Subject: LRU caches: add a generic (optional and configurable) expiration logic (#1855) Two caches already implemented a similar mechanism: make it generic. --- src/lib/protocols/tls.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/lib/protocols/tls.c') diff --git a/src/lib/protocols/tls.c b/src/lib/protocols/tls.c index 49c465bae..299e59ecb 100644 --- a/src/lib/protocols/tls.c +++ b/src/lib/protocols/tls.c @@ -340,7 +340,8 @@ static void checkTLSSubprotocol(struct ndpi_detection_module_struct *ndpi_struct key = make_tls_cert_key(packet, is_from_client); if(ndpi_lru_find_cache(ndpi_struct->tls_cert_cache, key, - &cached_proto, 0 /* Don't remove it as it can be used for other connections */)) { + &cached_proto, 0 /* Don't remove it as it can be used for other connections */, + ndpi_get_current_time(flow))) { ndpi_protocol ret = { __get_master(ndpi_struct, flow), cached_proto, NDPI_PROTOCOL_UNKNOWN /* unused */, NDPI_PROTOCOL_CATEGORY_UNSPECIFIED, NULL}; ndpi_set_detected_protocol(ndpi_struct, flow, cached_proto, __get_master(ndpi_struct, flow), NDPI_CONFIDENCE_DPI_CACHE); @@ -730,7 +731,7 @@ static void processCertificateElements(struct ndpi_detection_module_struct *ndpi if(ndpi_struct->tls_cert_cache) { u_int32_t key = make_tls_cert_key(packet, 0 /* from the server */); - ndpi_lru_add_to_cache(ndpi_struct->tls_cert_cache, key, proto_id); + ndpi_lru_add_to_cache(ndpi_struct->tls_cert_cache, key, proto_id, ndpi_get_current_time(flow)); } } } -- cgit v1.2.3