rpcd-mod-luci: avoid PTR requests for IPv6 link-local and ULA addrs
authorJo-Philipp Wich <jo@mein.io>
Wed, 22 Sep 2021 07:55:07 +0000 (09:55 +0200)
committerJo-Philipp Wich <jo@mein.io>
Wed, 22 Sep 2021 07:56:09 +0000 (09:56 +0200)
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
libs/rpcd-mod-luci/src/luci.c

index b89bca494d42c6eec6ae231dd000989be86c251d..53ffff4fd243adac6c9f615f03d7484853b3fef3 100644 (file)
 
 #include <rpcd/plugin.h>
 
+#ifndef IN6_IS_ADDR_ULA
+#define IN6_IS_ADDR_ULA(a) (((a)->s6_addr[0] & 0xfe) == 0xfc)
+#endif
+
 
 static struct blob_buf blob;
 
@@ -1720,7 +1724,9 @@ rpc_luci_get_host_hints_rrdns(struct reply_context *rctx)
                        }
                }
                avl_for_each_element(&hint->ip6addrs, addr, avl) {
-                       if (!IN6_IS_ADDR_UNSPECIFIED(&addr->addr.in6)) {
+                       if (!IN6_IS_ADDR_UNSPECIFIED(&addr->addr.in6) &&
+                           !IN6_IS_ADDR_LINKLOCAL(&addr->addr.in6) &&
+                           !IN6_IS_ADDR_ULA(&addr>addr.in6)) {
                                inet_ntop(AF_INET6, &addr->addr.in6, buf, sizeof(buf));
                                blobmsg_add_string(&req, NULL, buf);
                                n++;