aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-08-12 13:57:57 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-08-13 11:23:12 +0100
commita7b2ee81dfc78d0f9b17e93a3ed9ce9fbe220eba (patch)
tree1355ba1f829ad5e5429977d122657d3cf3ceefc7 /src/libutil
parent9056afff7ef9e6f203ec54a957a26e757d8530cb (diff)
downloadrspamd-a7b2ee81dfc78d0f9b17e93a3ed9ce9fbe220eba.tar.gz
rspamd-a7b2ee81dfc78d0f9b17e93a3ed9ce9fbe220eba.zip
[Feature] Print radix duplicate keys as IP addresses
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/radix.c19
1 files changed, 18 insertions, 1 deletions
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 ++;