diff options
author | Florian Obser <florian@cvs.openbsd.org> | 2021-11-19 16:42:02 +0000 |
---|---|---|
committer | Florian Obser <florian@cvs.openbsd.org> | 2021-11-19 16:42:02 +0000 |
commit | d3e06a553c1d6bffc3b651975d93fef5ce495205 (patch) | |
tree | 8a54f42e48ff93a4165ced2ed36b6bcd25f33374 /usr.sbin/unbound/util | |
parent | fe89c9e526b87a3333f755bd24da0dba0a8688cd (diff) |
Allow interface names as scope-id in IPv6 link-local addresses.
For example, this makes
forward-zone:
name: "."
forward-addr: fe80::20d:b9ff:fe46:c7f4%vio0
forward-first: yes
work instead of using fe80::20d:b9ff:fe46:c7f4%1 for the forward-addr.
This has been submitted upstream.
sthen@ is fine with carrying this as a local diff.
Requested by & OK kn
Diffstat (limited to 'usr.sbin/unbound/util')
-rw-r--r-- | usr.sbin/unbound/util/net_help.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/usr.sbin/unbound/util/net_help.c b/usr.sbin/unbound/util/net_help.c index 06bc1f5dd7e..f8b60908fa7 100644 --- a/usr.sbin/unbound/util/net_help.c +++ b/usr.sbin/unbound/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) { |