mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 06:25:31 +00:00
1394. [func] It is now possible to check if a particular element is
in a acl. Remove duplicate entries from the localnets acl. 1393. [port] Bind to individual IPv6 interfaces if IPV6_IPV6ONLY is not available in the kernel to prevent accidently listening on IPv4 interfaces. developer: jinmei reviewer: marka
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: net.h,v 1.17 2002/08/01 03:56:08 mayer Exp $ */
|
||||
/* $Id: net.h,v 1.18 2002/10/29 04:40:26 marka Exp $ */
|
||||
|
||||
#ifndef ISC_NET_H
|
||||
#define ISC_NET_H 1
|
||||
@@ -247,6 +247,18 @@ isc_net_probeipv6(void);
|
||||
* ISC_R_UNEXPECTED
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_net_probe_ipv6only(void);
|
||||
/*
|
||||
* Check if the system's kernel supports the IPV6_V6ONLY socket option.
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
* ISC_R_SUCCESS the option is supported for both TCP and UDP.
|
||||
* ISC_R_NOTFOUND IPv6 itself or the option is not supported.
|
||||
* ISC_R_UNEXPECTED
|
||||
*/
|
||||
|
||||
#ifdef ISC_PLATFORM_NEEDNTOP
|
||||
const char *
|
||||
isc_net_ntop(int af, const void *src, char *dst, size_t size);
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: net.c,v 1.4 2001/11/21 05:07:25 mayer Exp $ */
|
||||
/* $Id: net.c,v 1.5 2002/10/29 04:40:25 marka Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -35,8 +35,10 @@ const struct in6_addr isc_net_in6addrany = IN6ADDR_ANY_INIT;
|
||||
#endif
|
||||
|
||||
static isc_once_t once = ISC_ONCE_INIT;
|
||||
static isc_once_t once_ipv6only = ISC_ONCE_INIT;
|
||||
static isc_result_t ipv4_result = ISC_R_NOTFOUND;
|
||||
static isc_result_t ipv6_result = ISC_R_NOTFOUND;
|
||||
static isc_result_t ipv6only_result = ISC_R_NOTFOUND;
|
||||
|
||||
static isc_result_t
|
||||
try_proto(int domain) {
|
||||
@@ -140,8 +142,102 @@ isc_net_probeipv4(void) {
|
||||
return (ipv4_result);
|
||||
}
|
||||
|
||||
#ifdef ISC_PLATFORM_HAVEIPV6
|
||||
#ifdef WANT_IPV6
|
||||
isc_result_t
|
||||
isc_net_probeipv6(void) {
|
||||
initialize();
|
||||
return (ipv6_result);
|
||||
}
|
||||
|
||||
static void
|
||||
try_ipv6only(void) {
|
||||
#ifdef IPV6_V6ONLY
|
||||
int s, on;
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
#endif
|
||||
isc_result_t result;
|
||||
|
||||
result = isc_net_probeipv6();
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
ipv6only_result = result;
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef IPV6_V6ONLY
|
||||
ipv6only_result = ISC_R_NOTFOUND;
|
||||
return;
|
||||
#else
|
||||
/* check for TCP sockets */
|
||||
s = socket(PF_INET6, SOCK_STREAM, 0);
|
||||
if (s == -1) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"socket() %s: %s",
|
||||
isc_msgcat_get(isc_msgcat,
|
||||
ISC_MSGSET_GENERAL,
|
||||
ISC_MSG_FAILED,
|
||||
"failed"),
|
||||
strbuf);
|
||||
ipv6only_result = ISC_R_UNEXPECTED;
|
||||
return;
|
||||
}
|
||||
|
||||
on = 1;
|
||||
if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)) < 0) {
|
||||
ipv6only_result = ISC_R_NOTFOUND;
|
||||
goto close;
|
||||
}
|
||||
|
||||
close(s);
|
||||
|
||||
/* check for UDP sockets */
|
||||
s = socket(PF_INET6, SOCK_DGRAM, 0);
|
||||
if (s == -1) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"socket() %s: %s",
|
||||
isc_msgcat_get(isc_msgcat,
|
||||
ISC_MSGSET_GENERAL,
|
||||
ISC_MSG_FAILED,
|
||||
"failed"),
|
||||
strbuf);
|
||||
ipv6only_result = ISC_R_UNEXPECTED;
|
||||
return;
|
||||
}
|
||||
|
||||
on = 1;
|
||||
if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)) < 0) {
|
||||
ipv6only_result = ISC_R_NOTFOUND;
|
||||
goto close;
|
||||
}
|
||||
|
||||
close(s);
|
||||
|
||||
ipv6only_result = ISC_R_SUCCESS;
|
||||
|
||||
close:
|
||||
close(s);
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
initialize_ipv6only(void) {
|
||||
RUNTIME_CHECK(isc_once_do(&once_ipv6only,
|
||||
try_ipv6only) == ISC_R_SUCCESS);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
isc_result_t
|
||||
isc_net_probe_ipv6only(void) {
|
||||
#ifdef ISC_PLATFORM_HAVEIPV6
|
||||
#ifdef WANT_IPV6
|
||||
initialize_ipv6only();
|
||||
#else
|
||||
ipv6only_result = ISC_R_NOTFOUND;
|
||||
#endif
|
||||
#endif
|
||||
return (ipv6only_result);
|
||||
}
|
||||
|
Reference in New Issue
Block a user