LRU cache: move to 64 bits long keys (#2346)
Tradeoff between key comparison efficiency (i.e. no `memcmp`) and key length. At least in the ipv4 cases, we have no more different entries with the same key.
This commit is contained in:
@@ -1058,9 +1058,9 @@ extern "C" {
|
||||
/* LRU cache */
|
||||
struct ndpi_lru_cache* ndpi_lru_cache_init(u_int32_t num_entries, u_int32_t ttl, int shared);
|
||||
void ndpi_lru_free_cache(struct ndpi_lru_cache *c);
|
||||
u_int8_t ndpi_lru_find_cache(struct ndpi_lru_cache *c, u_int32_t key,
|
||||
u_int8_t ndpi_lru_find_cache(struct ndpi_lru_cache *c, u_int64_t key,
|
||||
u_int16_t *value, u_int8_t clean_key_when_found, u_int32_t now_sec);
|
||||
void ndpi_lru_add_to_cache(struct ndpi_lru_cache *c, u_int32_t key, u_int16_t value, u_int32_t now_sec);
|
||||
void ndpi_lru_add_to_cache(struct ndpi_lru_cache *c, u_int64_t key, u_int16_t value, u_int32_t now_sec);
|
||||
void ndpi_lru_get_stats(struct ndpi_lru_cache *c, struct ndpi_lru_cache_stats *stats);
|
||||
|
||||
int ndpi_get_lru_cache_stats(struct ndpi_global_context *g_ctx,
|
||||
|
||||
@@ -660,8 +660,8 @@ int is_rtp_or_rtcp(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
u_int8_t rtp_get_stream_type(u_int8_t payloadType, ndpi_multimedia_flow_type *s_type);
|
||||
|
||||
/* Bittorrent */
|
||||
u_int32_t make_bittorrent_host_key(struct ndpi_flow_struct *flow, int client, int offset);
|
||||
u_int32_t make_bittorrent_peers_key(struct ndpi_flow_struct *flow);
|
||||
u_int64_t make_bittorrent_host_key(struct ndpi_flow_struct *flow, int client, int offset);
|
||||
u_int64_t make_bittorrent_peers_key(struct ndpi_flow_struct *flow);
|
||||
int search_into_bittorrent_cache(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow);
|
||||
|
||||
@@ -673,7 +673,7 @@ int stun_search_into_zoom_cache(struct ndpi_detection_module_struct *ndpi_struct
|
||||
int tpkt_verify_hdr(const struct ndpi_packet_struct * const packet);
|
||||
|
||||
/* Mining Protocols (Ethereum, Monero, ...) */
|
||||
u_int32_t mining_make_lru_cache_key(struct ndpi_flow_struct *flow);
|
||||
u_int64_t mining_make_lru_cache_key(struct ndpi_flow_struct *flow);
|
||||
|
||||
|
||||
/* Protocols init */
|
||||
|
||||
@@ -757,7 +757,7 @@ typedef enum {
|
||||
} lru_cache_scope;
|
||||
|
||||
struct ndpi_lru_cache_entry {
|
||||
u_int32_t key; /* Store the whole key to avoid ambiguities */
|
||||
u_int64_t key; /* Store the whole key to avoid ambiguities */
|
||||
u_int32_t is_full:1, value:16, pad:15;
|
||||
u_int32_t timestamp; /* sec */
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user