aboutsummaryrefslogtreecommitdiff
path: root/src/lib/protocols
diff options
context:
space:
mode:
authorNardi Ivan <nardi.ivan@gmail.com>2022-09-22 17:42:46 +0200
committerToni <matzeton@googlemail.com>2022-09-23 18:33:48 +0200
commit1f345b311f7f4bb3246a649ced3cec11d742b6e4 (patch)
treeaf829d9cfa5840f44d7207c2554107f65de55f47 /src/lib/protocols
parent83de3e4716eb7dcc373f0fcad4b59e83ea140fb1 (diff)
Sizes of LRU caches are now configurable
0 as size value disable the cache. The diffs in unit tests are due to the fact that some lookups are performed before the first insert: before this change these lookups weren't counted because the cache was not yet initialized, now they are.
Diffstat (limited to 'src/lib/protocols')
-rw-r--r--src/lib/protocols/bittorrent.c3
-rw-r--r--src/lib/protocols/hangout.c2
-rw-r--r--src/lib/protocols/http.c3
-rw-r--r--src/lib/protocols/mining.c2
-rw-r--r--src/lib/protocols/ookla.c3
-rw-r--r--src/lib/protocols/stun.c3
-rw-r--r--src/lib/protocols/tls.c3
7 files changed, 0 insertions, 19 deletions
diff --git a/src/lib/protocols/bittorrent.c b/src/lib/protocols/bittorrent.c
index c28c8bcd4..cac66b6be 100644
--- a/src/lib/protocols/bittorrent.c
+++ b/src/lib/protocols/bittorrent.c
@@ -118,9 +118,6 @@ static void ndpi_add_connection_as_bittorrent(struct ndpi_detection_module_struc
flow->extra_packets_func = search_bittorrent_again;
}
- if(ndpi_struct->bittorrent_cache == NULL)
- ndpi_struct->bittorrent_cache = ndpi_lru_cache_init(32768);
-
if(ndpi_struct->bittorrent_cache && packet->iph) {
u_int32_t key1, key2, i;
diff --git a/src/lib/protocols/hangout.c b/src/lib/protocols/hangout.c
index 7f5414ef0..c8ae84177 100644
--- a/src/lib/protocols/hangout.c
+++ b/src/lib/protocols/hangout.c
@@ -98,8 +98,6 @@ void ndpi_search_hangout(struct ndpi_detection_module_struct *ndpi_struct,
NDPI_LOG_INFO(ndpi_struct, "found Hangout\n");
/* Hangout is over STUN hence the LRU cache is shared */
- if(ndpi_struct->stun_cache == NULL)
- ndpi_struct->stun_cache = ndpi_lru_cache_init(1024);
if(ndpi_struct->stun_cache && packet->iph) {
u_int32_t key = get_stun_lru_key(flow, !matched_src);
diff --git a/src/lib/protocols/http.c b/src/lib/protocols/http.c
index b50967a3c..96e0e309a 100644
--- a/src/lib/protocols/http.c
+++ b/src/lib/protocols/http.c
@@ -1171,9 +1171,6 @@ static void ndpi_check_http_tcp(struct ndpi_detection_module_struct *ndpi_struct
ookla_found:
ndpi_int_http_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_OOKLA, NDPI_PROTOCOL_CATEGORY_WEB);
- if(ndpi_struct->ookla_cache == NULL)
- ndpi_struct->ookla_cache = ndpi_lru_cache_init(1024);
-
if(ndpi_struct->ookla_cache != NULL) {
if(packet->iph != NULL) {
if(packet->tcp->source == htons(8080))
diff --git a/src/lib/protocols/mining.c b/src/lib/protocols/mining.c
index eb5e651d9..6d6e48f02 100644
--- a/src/lib/protocols/mining.c
+++ b/src/lib/protocols/mining.c
@@ -28,8 +28,6 @@
static void cacheMiningHostTwins(struct ndpi_detection_module_struct *ndpi_struct,
u_int32_t host_keys /* network byte order */) {
- if(ndpi_struct->mining_cache == NULL) ndpi_struct->mining_cache = ndpi_lru_cache_init(1024);
-
if(ndpi_struct->mining_cache)
ndpi_lru_add_to_cache(ndpi_struct->mining_cache, host_keys, NDPI_PROTOCOL_MINING);
}
diff --git a/src/lib/protocols/ookla.c b/src/lib/protocols/ookla.c
index 5f4c170bf..a57231c30 100644
--- a/src/lib/protocols/ookla.c
+++ b/src/lib/protocols/ookla.c
@@ -56,9 +56,6 @@ void ndpi_search_ookla(struct ndpi_detection_module_struct* ndpi_struct, struct
&& (packet->payload[2] == 0x0A)) {
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_OOKLA, NDPI_PROTOCOL_UNKNOWN, NDPI_CONFIDENCE_DPI);
- if(ndpi_struct->ookla_cache == NULL)
- ndpi_struct->ookla_cache = ndpi_lru_cache_init(1024);
-
if(ndpi_struct->ookla_cache != NULL) {
/* In order to avoid creating an IPv6 LRU we hash the IPv6 address */
h = ndpi_quick_hash((unsigned char *)&packet->iphv6->ip6_dst, sizeof(packet->iphv6->ip6_dst));
diff --git a/src/lib/protocols/stun.c b/src/lib/protocols/stun.c
index b0826fd4b..a09e898d6 100644
--- a/src/lib/protocols/stun.c
+++ b/src/lib/protocols/stun.c
@@ -58,9 +58,6 @@ static void ndpi_int_stun_add_connection(struct ndpi_detection_module_struct *nd
app_proto = NDPI_PROTOCOL_FACEBOOK_VOIP;
}
- if(ndpi_struct->stun_cache == NULL)
- ndpi_struct->stun_cache = ndpi_lru_cache_init(1024);
-
if(ndpi_struct->stun_cache
&& packet->iph
&& (app_proto != NDPI_PROTOCOL_UNKNOWN)
diff --git a/src/lib/protocols/tls.c b/src/lib/protocols/tls.c
index 3cfe70e3a..8210f51fe 100644
--- a/src/lib/protocols/tls.c
+++ b/src/lib/protocols/tls.c
@@ -695,9 +695,6 @@ static void processCertificateElements(struct ndpi_detection_module_struct *ndpi
flow->category = ndpi_get_proto_category(ndpi_struct, ret);
ndpi_check_subprotocol_risk(ndpi_struct, flow, proto_id);
- if(ndpi_struct->tls_cert_cache == NULL)
- ndpi_struct->tls_cert_cache = ndpi_lru_cache_init(1024);
-
if(ndpi_struct->tls_cert_cache && packet->iph && packet->tcp) {
u_int32_t key = packet->iph->saddr + packet->tcp->source; /* Server */