MaxMind DB: Fixup IPv6 address interning.

Intern IPv6 addresses into their own hash table.

Change-Id: I1ad60bf56585fcd89964e949e8754af3c7512a75
Reviewed-on: https://code.wireshark.org/review/26414
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
Gerald Combs 2018-03-10 09:20:12 -08:00
parent aae6b8442c
commit 5564c222e2
1 changed files with 7 additions and 2 deletions

View File

@ -47,6 +47,7 @@ static wmem_map_t *mmdb_ipv6_map;
// Interned strings
static wmem_map_t *mmdb_str_chunk;
static wmem_map_t *mmdb_ipv6_chunk;
/* Child mmdbresolve process */
static char cur_addr[WS_INET6_ADDRSTRLEN];
@ -115,11 +116,11 @@ static const char *chunkify_string(char *key) {
}
static const void *chunkify_v6_addr(const ws_in6_addr *addr) {
void *chunk_v6_bytes = (char *) wmem_map_lookup(mmdb_ipv6_map, addr->bytes);
void *chunk_v6_bytes = (char *) wmem_map_lookup(mmdb_ipv6_chunk, addr->bytes);
if (!chunk_v6_bytes) {
chunk_v6_bytes = wmem_memdup(wmem_epan_scope(), addr->bytes, sizeof(ws_in6_addr));
wmem_map_insert(mmdb_ipv6_map, chunk_v6_bytes, chunk_v6_bytes);
wmem_map_insert(mmdb_ipv6_chunk, chunk_v6_bytes, chunk_v6_bytes);
}
return chunk_v6_bytes;
@ -237,6 +238,10 @@ static void mmdb_resolve_start(void) {
mmdb_str_chunk = wmem_map_new(wmem_epan_scope(), wmem_str_hash, g_str_equal);
}
if (!mmdb_ipv6_chunk) {
mmdb_ipv6_chunk = wmem_map_new(wmem_epan_scope(), ipv6_oat_hash, ipv6_equal);
}
if (!mmdb_file_arr) {
MMDB_DEBUG("unexpected mmdb_file_arr == NULL");
return;