From: Vsevolod Stakhov Date: Fri, 12 Aug 2016 12:57:57 +0000 (+0100) Subject: [Feature] Print radix duplicate keys as IP addresses X-Git-Tag: 1.3.3~19 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a7b2ee81dfc78d0f9b17e93a3ed9ce9fbe220eba;p=rspamd.git [Feature] Print radix duplicate keys as IP addresses --- diff --git a/src/libutil/radix.c b/src/libutil/radix.c index b165401f7..7827d41ac 100644 --- a/src/libutil/radix.c +++ b/src/libutil/radix.c @@ -67,6 +67,7 @@ radix_insert_compressed (radix_compressed_t * tree, { guint keybits = keylen * NBBY; uintptr_t old; + gchar ip_str[INET6_ADDRSTRLEN + 1]; int ret; g_assert (tree != NULL); @@ -81,8 +82,24 @@ radix_insert_compressed (radix_compressed_t * tree, (gconstpointer)value); if (ret != BTRIE_OKAY) { - msg_err_radix ("cannot insert %p with mask %z, key: %*xs, duplicate value", + memset (ip_str, 0, sizeof (ip_str)); + + if (keybits == 32) { + msg_err_radix ("cannot insert %p, key: %s/%d, duplicate value", + (gpointer)value, + inet_ntop (AF_INET, key, ip_str, sizeof (ip_str) - 1), + keybits - masklen); + } + else if (keybits == 128) { + msg_err_radix ("cannot insert %p, key: [%s]/%d, duplicate value", + (gpointer)value, + inet_ntop (AF_INET6, key, ip_str, sizeof (ip_str) - 1), + keybits - masklen); + } + else { + msg_err_radix ("cannot insert %p with mask %z, key: %*xs, duplicate value", (gpointer)value, keybits - masklen, (int)keylen, key); + } } else { tree->size ++;