Remove "zoom" cache (#2420)

This cache was added in b6b4967aa, when there was no real Zoom support.
With 63f349319, a proper identification of multimedia stream has been
added, making this cache quite useless: any improvements on Zoom
classification should be properly done in Zoom dissector.

Tested for some months with a few 10Gbits links of residential traffic: the
cache pretty much never returned a valid hit.
This commit is contained in:
Ivan Nardi
2024-05-06 12:51:45 +02:00
committed by GitHub
parent b7d77972bc
commit 95fe21015d
549 changed files with 5 additions and 676 deletions
-9
View File
@@ -157,9 +157,6 @@ struct ndpi_global_context {
/* NDPI_PROTOCOL_BITTORRENT */
struct ndpi_lru_cache *bittorrent_global_cache;
/* NDPI_PROTOCOL_ZOOM */
struct ndpi_lru_cache *zoom_global_cache;
/* NDPI_PROTOCOL_STUN and subprotocols */
struct ndpi_lru_cache *stun_global_cache;
struct ndpi_lru_cache *stun_zoom_global_cache;
@@ -211,9 +208,6 @@ struct ndpi_detection_module_config_struct {
int bittorrent_cache_num_entries;
int bittorrent_cache_ttl;
int bittorrent_cache_scope;
int zoom_cache_num_entries;
int zoom_cache_ttl;
int zoom_cache_scope;
int stun_cache_num_entries;
int stun_cache_ttl;
int stun_cache_scope;
@@ -360,9 +354,6 @@ struct ndpi_detection_module_struct {
/* NDPI_PROTOCOL_BITTORRENT */
struct ndpi_lru_cache *bittorrent_cache;
/* NDPI_PROTOCOL_ZOOM */
struct ndpi_lru_cache *zoom_cache;
/* NDPI_PROTOCOL_STUN and subprotocols */
struct ndpi_lru_cache *stun_cache;
struct ndpi_lru_cache *stun_zoom_cache;
-1
View File
@@ -742,7 +742,6 @@ struct ndpi_automa_stats {
typedef enum {
NDPI_LRUCACHE_OOKLA = 0,
NDPI_LRUCACHE_BITTORRENT,
NDPI_LRUCACHE_ZOOM,
NDPI_LRUCACHE_STUN,
NDPI_LRUCACHE_TLS_CERT,
NDPI_LRUCACHE_MINING,
-97
View File
@@ -3224,8 +3224,6 @@ void ndpi_global_deinit(struct ndpi_global_context *g_ctx) {
ndpi_lru_free_cache(g_ctx->ookla_global_cache);
if(g_ctx->bittorrent_global_cache)
ndpi_lru_free_cache(g_ctx->bittorrent_global_cache);
if(g_ctx->zoom_global_cache)
ndpi_lru_free_cache(g_ctx->zoom_global_cache);
if(g_ctx->stun_global_cache)
ndpi_lru_free_cache(g_ctx->stun_global_cache);
if(g_ctx->stun_zoom_global_cache)
@@ -3738,22 +3736,6 @@ int ndpi_finalize_initialization(struct ndpi_detection_module_struct *ndpi_str)
ndpi_str->cfg.bittorrent_cache_num_entries);
}
}
if(ndpi_str->cfg.zoom_cache_num_entries > 0) {
if(ndpi_str->cfg.zoom_cache_scope == NDPI_LRUCACHE_SCOPE_GLOBAL) {
if(!ndpi_str->g_ctx->zoom_global_cache) {
ndpi_str->g_ctx->zoom_global_cache = ndpi_lru_cache_init(ndpi_str->cfg.zoom_cache_num_entries,
ndpi_str->cfg.zoom_cache_ttl, 1);
}
ndpi_str->zoom_cache = ndpi_str->g_ctx->zoom_global_cache;
} else {
ndpi_str->zoom_cache = ndpi_lru_cache_init(ndpi_str->cfg.zoom_cache_num_entries,
ndpi_str->cfg.zoom_cache_ttl, 0);
}
if(!ndpi_str->zoom_cache) {
NDPI_LOG_ERR(ndpi_str, "Error allocating lru cache (num_entries %u)\n",
ndpi_str->cfg.zoom_cache_num_entries);
}
}
if(ndpi_str->cfg.stun_cache_num_entries > 0) {
if(ndpi_str->cfg.stun_cache_scope == NDPI_LRUCACHE_SCOPE_GLOBAL) {
if(!ndpi_str->g_ctx->stun_global_cache) {
@@ -4156,10 +4138,6 @@ void ndpi_exit_detection_module(struct ndpi_detection_module_struct *ndpi_str) {
ndpi_str->bittorrent_cache)
ndpi_lru_free_cache(ndpi_str->bittorrent_cache);
if(!ndpi_str->cfg.zoom_cache_scope &&
ndpi_str->zoom_cache)
ndpi_lru_free_cache(ndpi_str->zoom_cache);
if(!ndpi_str->cfg.stun_cache_scope &&
ndpi_str->stun_cache)
ndpi_lru_free_cache(ndpi_str->stun_cache);
@@ -7583,61 +7561,6 @@ int search_into_bittorrent_cache(struct ndpi_detection_module_struct *ndpi_struc
/* ********************************************************************************* */
/* #define ZOOM_CACHE_DEBUG */
static u_int64_t make_zoom_key(struct ndpi_flow_struct *flow, int server) {
u_int64_t key;
if(server) {
if(flow->is_ipv6)
key = ndpi_quick_hash64((const char *)flow->s_address.v6, 16);
else
key = flow->s_address.v4;
} else {
if(flow->is_ipv6)
key = ndpi_quick_hash64((const char *)flow->c_address.v6, 16);
else
key = flow->c_address.v4;
}
return key;
}
/* ********************************************************************************* */
static u_int8_t ndpi_search_into_zoom_cache(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow, int server) {
if(ndpi_struct->zoom_cache) {
u_int16_t cached_proto;
u_int64_t key;
key = make_zoom_key(flow, server);
u_int8_t found = ndpi_lru_find_cache(ndpi_struct->zoom_cache, key, &cached_proto,
0 /* Don't remove it as it can be used for other connections */,
ndpi_get_current_time(flow));
#ifdef ZOOM_CACHE_DEBUG
printf("[Zoom] *** [TCP] SEARCHING key 0x%llx [found: %u]\n", (long long unsigned int)key, found);
#endif
return(found);
}
return(0);
}
/* ********************************************************************************* */
static void ndpi_add_connection_as_zoom(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow) {
if(ndpi_struct->zoom_cache)
ndpi_lru_add_to_cache(ndpi_struct->zoom_cache, make_zoom_key(flow, 1), NDPI_PROTOCOL_ZOOM, ndpi_get_current_time(flow));
}
/* ********************************************************************************* */
/*
NOTE:
@@ -7707,15 +7630,6 @@ ndpi_protocol ndpi_detection_giveup(struct ndpi_detection_module_struct *ndpi_st
ret.app_protocol = flow->detected_protocol_stack[0];
}
/* Does it looks like Zoom? */
if(ret.app_protocol == NDPI_PROTOCOL_UNKNOWN &&
flow->l4_proto == IPPROTO_UDP && /* Zoom/UDP used for video */
((ntohs(flow->s_port) == 8801 && ndpi_search_into_zoom_cache(ndpi_str, flow, 1)) ||
(ntohs(flow->c_port) == 8801 && ndpi_search_into_zoom_cache(ndpi_str, flow, 0)))) {
ndpi_set_detected_protocol(ndpi_str, flow, NDPI_PROTOCOL_ZOOM, NDPI_PROTOCOL_UNKNOWN, NDPI_CONFIDENCE_DPI_PARTIAL_CACHE);
ret.app_protocol = flow->detected_protocol_stack[0];
}
/* Does it looks like Zoom (via STUN)? */
if(ret.app_protocol == NDPI_PROTOCOL_UNKNOWN &&
stun_search_into_zoom_cache(ndpi_str, flow)) {
@@ -8614,10 +8528,6 @@ static ndpi_protocol ndpi_internal_detection_process_packet(struct ndpi_detectio
/* ndpi_reconcile_protocols(ndpi_str, flow, &ret); */
/* Zoom cache */
if((ret.app_protocol == NDPI_PROTOCOL_ZOOM) && (flow->l4_proto == IPPROTO_TCP))
ndpi_add_connection_as_zoom(ndpi_str, flow);
if(ndpi_str->cfg.fully_encrypted_heuristic &&
ret.app_protocol == NDPI_PROTOCOL_UNKNOWN && /* Only for unknown traffic */
flow->packet_counter == 1 && packet->payload_packet_len > 0) {
@@ -10235,9 +10145,6 @@ int ndpi_get_lru_cache_stats(struct ndpi_global_context *g_ctx,
case NDPI_LRUCACHE_BITTORRENT:
ndpi_lru_get_stats(is_local ? ndpi_struct->bittorrent_cache : g_ctx->bittorrent_global_cache, stats);
return 0;
case NDPI_LRUCACHE_ZOOM:
ndpi_lru_get_stats(is_local ? ndpi_struct->zoom_cache : g_ctx->zoom_global_cache, stats);
return 0;
case NDPI_LRUCACHE_STUN:
ndpi_lru_get_stats(is_local ? ndpi_struct->stun_cache : g_ctx->stun_global_cache, stats);
return 0;
@@ -11270,10 +11177,6 @@ static const struct cfg_param {
{ NULL, "lru.bittorrent.ttl", "0", "0", "16777215", CFG_PARAM_INT, __OFF(bittorrent_cache_ttl), NULL },
{ NULL, "lru.bittorrent.scope", "0", "0", "1", CFG_PARAM_INT, __OFF(bittorrent_cache_scope), clbk_only_with_global_ctx },
{ NULL, "lru.zoom.size", "512", "0", "16777215", CFG_PARAM_INT, __OFF(zoom_cache_num_entries), NULL },
{ NULL, "lru.zoom.ttl", "0", "0", "16777215", CFG_PARAM_INT, __OFF(zoom_cache_ttl), NULL },
{ NULL, "lru.zoom.scope", "0", "0", "1", CFG_PARAM_INT, __OFF(zoom_cache_scope), clbk_only_with_global_ctx },
{ NULL, "lru.stun.size", "1024", "0", "16777215", CFG_PARAM_INT, __OFF(stun_cache_num_entries), NULL },
{ NULL, "lru.stun.ttl", "0", "0", "16777215", CFG_PARAM_INT, __OFF(stun_cache_ttl), NULL },
{ NULL, "lru.stun.scope", "0", "0", "1", CFG_PARAM_INT, __OFF(stun_cache_scope), clbk_only_with_global_ctx },
+1 -1
View File
@@ -3128,7 +3128,7 @@ int64_t ndpi_strtonum(const char *numstr, int64_t minval, int64_t maxval, const
const char *ndpi_lru_cache_idx_to_name(lru_cache_type idx)
{
const char *names[NDPI_LRUCACHE_MAX] = { "ookla", "bittorrent", "zoom", "stun",
const char *names[NDPI_LRUCACHE_MAX] = { "ookla", "bittorrent", "stun",
"tls_cert", "mining", "msteams", "stun_zoom" };
if(idx < 0 || idx >= NDPI_LRUCACHE_MAX)