]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
rrl: log both trigger source address and affected subnet
authorDaniel Salzman <daniel.salzman@nic.cz>
Wed, 9 Oct 2019 14:59:19 +0000 (16:59 +0200)
committerDaniel Salzman <daniel.salzman@nic.cz>
Wed, 9 Oct 2019 15:03:21 +0000 (17:03 +0200)
src/knot/modules/rrl/functions.c

index 527b4555a24cd4cc2966123d140eb38d1301445f..0e52baef7a9cfc4b9ce52bd3472f91cba0093ee6 100644 (file)
@@ -264,20 +264,18 @@ static inline unsigned reduce_dist(rrl_table_t *tbl, unsigned id, unsigned dist,
 
 static void subnet_tostr(char *dst, size_t maxlen, const struct sockaddr_storage *ss)
 {
+       const void *addr;
        const char *suffix;
-       uint8_t addr[16] = { 0 };
 
        if (ss->ss_family == AF_INET6) {
-               struct sockaddr_in6 *ipv6 = (struct sockaddr_in6 *)ss;
-               memcpy(addr, &ipv6->sin6_addr, RRL_V6_PREFIX_LEN);
+               addr = &((struct sockaddr_in6 *)ss)->sin6_addr;
                suffix = "/56";
        } else {
-               struct sockaddr_in *ipv4 = (struct sockaddr_in *)ss;
-               memcpy(addr, &ipv4->sin_addr, RRL_V4_PREFIX_LEN);
+               addr = &((struct sockaddr_in *)ss)->sin_addr;
                suffix = "/24";
        }
 
-       if (inet_ntop(ss->ss_family, &addr, dst, maxlen) != NULL) {
+       if (inet_ntop(ss->ss_family, addr, dst, maxlen) != NULL) {
                strlcat(dst, suffix, maxlen);
        } else {
                dst[0] = '\0';
@@ -299,7 +297,7 @@ static void rrl_log_state(knotd_mod_t *mod, const struct sockaddr_storage *ss,
                what = "enters";
        }
 
-       knotd_mod_log(mod, LOG_NOTICE, "subnet %s, class %s, %s limiting",
+       knotd_mod_log(mod, LOG_NOTICE, "address/subnet %s, class %s, %s limiting",
                      addr_str, rrl_clsstr(cls), what);
 }