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.
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user