#endif /* HAVE_SYSCTLBYNAME */
-#ifdef __notyet__
-static isc_once_t once_ipv6pktinfo = ISC_ONCE_INIT;
-#endif /* ifdef __notyet__ */
-
#ifndef ISC_CMSG_IP_TOS
#ifdef __APPLE__
#define ISC_CMSG_IP_TOS 0 /* As of 10.8.2. */
static isc_result_t ipv4_result = ISC_R_SUCCESS;
static isc_result_t ipv6_result = ISC_R_SUCCESS;
-static isc_result_t ipv6pktinfo_result = ISC_R_NOTFOUND;
isc_result_t
isc_net_probeipv4(void) {
return ipv6_result;
}
-#ifdef __notyet__
-static void
-try_ipv6pktinfo(void) {
- int s, on;
- isc_result_t result;
- int optname;
-
- result = isc_net_probeipv6();
- if (result != ISC_R_SUCCESS) {
- ipv6pktinfo_result = result;
- return;
- }
-
- /* we only use this for UDP sockets */
- s = socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP);
- if (s == -1) {
- UNEXPECTED_SYSERROR(errno, "socket()");
- ipv6pktinfo_result = ISC_R_UNEXPECTED;
- return;
- }
-
-#ifdef IPV6_RECVPKTINFO
- optname = IPV6_RECVPKTINFO;
-#else /* ifdef IPV6_RECVPKTINFO */
- optname = IPV6_PKTINFO;
-#endif /* ifdef IPV6_RECVPKTINFO */
- on = 1;
- if (setsockopt(s, IPPROTO_IPV6, optname, &on, sizeof(on)) < 0) {
- ipv6pktinfo_result = ISC_R_NOTFOUND;
- goto close;
- }
-
- ipv6pktinfo_result = ISC_R_SUCCESS;
-
-close:
- close(s);
- return;
-}
-
-static void
-initialize_ipv6pktinfo(void) {
- isc_once_do(&once_ipv6pktinfo, try_ipv6pktinfo);
-}
-#endif /* ifdef __notyet__ */
-
-isc_result_t
-isc_net_probe_ipv6pktinfo(void) {
-/*
- * XXXWPK if pktinfo were supported then we could listen on :: for ipv6 and get
- * the information about the destination address from pktinfo structure passed
- * in recvmsg but this method is not portable and libuv doesn't support it - so
- * we need to listen on all interfaces.
- * We should verify that this doesn't impact performance (we already do it for
- * ipv4) and either remove all the ipv6pktinfo detection code from above
- * or think of fixing libuv.
- */
-#ifdef __notyet__
- initialize_ipv6pktinfo();
-#endif /* ifdef __notyet__ */
- return ipv6pktinfo_result;
-}
-
#if defined(USE_SYSCTL_PORTRANGE)
#if defined(HAVE_SYSCTLBYNAME)
static isc_result_t
isc_interfaceiter_t *iter = NULL;
bool scan_ipv4 = false;
bool scan_ipv6 = false;
- bool ipv6pktinfo = true;
isc_result_t result;
isc_netaddr_t zero_address, zero_address6;
ns_listenelt_t *le = NULL;
- isc_sockaddr_t listen_addr;
ns_interface_t *ifp = NULL;
bool log_explicit = false;
bool dolistenon;
"no IPv4 interfaces found");
}
- /*
- * A special, but typical case; listen-on-v6 { any; }.
- * When we can make the socket IPv6-only, open a single wildcard
- * socket for IPv6 communication. Otherwise, make separate
- * socket for each IPv6 address in order to avoid accepting IPv4
- * packets as the form of mapped addresses unintentionally
- * unless explicitly allowed.
- */
- if (scan_ipv6 && isc_net_probe_ipv6pktinfo() != ISC_R_SUCCESS) {
- ipv6pktinfo = false;
- log_explicit = true;
- }
- if (scan_ipv6 && ipv6pktinfo) {
- for (le = ISC_LIST_HEAD(mgr->listenon6->elts); le != NULL;
- le = ISC_LIST_NEXT(le, link))
- {
- struct in6_addr in6a;
-
- if (!listenon_is_ip6_any(le)) {
- continue;
- }
-
- in6a = in6addr_any;
- isc_sockaddr_fromin6(&listen_addr, &in6a, le->port);
-
- ifp = find_matching_interface(mgr, &listen_addr);
- if (ifp != NULL) {
- bool cont = interface_update_or_shutdown(
- mgr, ifp, le, config);
- if (cont) {
- continue;
- }
- }
-
- isc_log_write(NS_LOGCATEGORY_NETWORK,
- NS_LOGMODULE_INTERFACEMGR, ISC_LOG_INFO,
- "listening on IPv6 "
- "interfaces, port %u",
- le->port);
- result = interface_setup(mgr, &listen_addr, "<any>",
- &ifp, le, NULL);
- if (result == ISC_R_SUCCESS) {
- ifp->flags |= NS_INTERFACEFLAG_ANYADDR;
- } else {
- isc_log_write(NS_LOGCATEGORY_NETWORK,
- NS_LOGMODULE_INTERFACEMGR,
- ISC_LOG_ERROR,
- "listening on all IPv6 "
- "interfaces failed");
- }
- /* Continue. */
- }
- }
-
isc_netaddr_any(&zero_address);
isc_netaddr_any6(&zero_address6);
{
int match;
bool addr_in_use = false;
- bool ipv6_wildcard = false;
isc_sockaddr_t listen_sockaddr;
isc_sockaddr_fromnetaddr(&listen_sockaddr,
dolistenon = false;
}
- /*
- * The case of "any" IPv6 address will require
- * special considerations later, so remember it.
- */
- if (family == AF_INET6 && ipv6pktinfo &&
- listenon_is_ip6_any(le))
- {
- ipv6_wildcard = true;
- }
-
ifp = find_matching_interface(mgr, &listen_sockaddr);
if (ifp != NULL) {
bool cont = interface_update_or_shutdown(
}
}
- if (ipv6_wildcard) {
- continue;
- }
-
if (log_explicit && family == AF_INET6 &&
listenon_is_ip6_any(le))
{