summaryrefslogtreecommitdiff
path: root/sbin/unwind/libunbound
diff options
context:
space:
mode:
authorFlorian Obser <florian@cvs.openbsd.org>2021-11-19 16:49:33 +0000
committerFlorian Obser <florian@cvs.openbsd.org>2021-11-19 16:49:33 +0000
commit69cc9de9addd253f6f04af335b6e762610ace9c2 (patch)
tree1a31aea317c56bb97cfbbd33f7a21892350cab18 /sbin/unwind/libunbound
parentd3e06a553c1d6bffc3b651975d93fef5ce495205 (diff)
Sync to unbound to allow interface names as scope-id in IPv6
link-local addresses. With this dns proposals from slaacd with link-local addresses from slaacd(8) are wroking. Requested by & OK kn
Diffstat (limited to 'sbin/unwind/libunbound')
-rw-r--r--sbin/unwind/libunbound/config.h3
-rw-r--r--sbin/unwind/libunbound/util/net_help.c11
2 files changed, 13 insertions, 1 deletions
diff --git a/sbin/unwind/libunbound/config.h b/sbin/unwind/libunbound/config.h
index 435139a9ee4..695945c89b4 100644
--- a/sbin/unwind/libunbound/config.h
+++ b/sbin/unwind/libunbound/config.h
@@ -316,6 +316,9 @@
/* Define to 1 if you have the <ifaddrs.h> header file. */
#define HAVE_IFADDRS_H 1
+/* Define to 1 if you have the `if_nametoindex' function. */
+#define HAVE_IF_NAMETOINDEX 1
+
/* Define to 1 if you have the `inet_aton' function. */
#define HAVE_INET_ATON 1
diff --git a/sbin/unwind/libunbound/util/net_help.c b/sbin/unwind/libunbound/util/net_help.c
index 06bc1f5dd7e..f8b60908fa7 100644
--- a/sbin/unwind/libunbound/util/net_help.c
+++ b/sbin/unwind/libunbound/util/net_help.c
@@ -38,6 +38,12 @@
*/
#include "config.h"
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_NET_IF_H
+#include <net/if.h>
+#endif
#include "util/net_help.h"
#include "util/log.h"
#include "util/data/dname.h"
@@ -266,7 +272,10 @@ ipstrtoaddr(const char* ip, int port, struct sockaddr_storage* addr,
return 0;
(void)strlcpy(buf, ip, sizeof(buf));
buf[s-ip]=0;
- sa->sin6_scope_id = (uint32_t)atoi(s+1);
+#ifdef HAVE_IF_NAMETOINDEX
+ if (!(sa->sin6_scope_id = if_nametoindex(s+1)))
+#endif /* HAVE_IF_NAMETOINDEX */
+ sa->sin6_scope_id = (uint32_t)atoi(s+1);
ip = buf;
}
if(inet_pton((int)sa->sin6_family, ip, &sa->sin6_addr) <= 0) {