From 22fa4e3206c2048cabaf75a3ae21132fd5542848 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Fri, 20 Feb 2004 00:52:46 +0000 Subject: [PATCH] 1578. [bug] Don't use CLASS E IPv4 addresses when resolving. [RT #10346] --- CHANGES | 3 ++- lib/dns/resolver.c | 5 ++++- lib/isc/include/isc/netaddr.h | 8 +++++++- lib/isc/include/isc/sockaddr.h | 8 +++++++- lib/isc/netaddr.c | 13 ++++++++++++- lib/isc/sockaddr.c | 13 ++++++++++++- lib/isc/unix/include/isc/net.h | 6 +++++- lib/isc/win32/include/isc/net.h | 6 +++++- 8 files changed, 54 insertions(+), 8 deletions(-) diff --git a/CHANGES b/CHANGES index 5474f9cbb0..e9b68d1a10 100644 --- a/CHANGES +++ b/CHANGES @@ -10,7 +10,8 @@ 1579. [placeholder] rt3746a -1578. [placeholder] rt10346 +1578. [bug] Don't use CLASS E IPv4 addresses when resolving. + [RT #10346] 1577. [placeholder] rt10331 diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index 09e28fc65e..6184ec6cf8 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: resolver.c,v 1.280 2004/02/03 00:59:05 marka Exp $ */ +/* $Id: resolver.c,v 1.281 2004/02/20 00:52:45 marka Exp $ */ #include @@ -2025,6 +2025,9 @@ possibly_mark(fetchctx_t *fctx, dns_adbaddrinfo_t *addr) } else if (isc_sockaddr_ismulticast(sa)) { addr->flags |= FCTX_ADDRINFO_MARK; msg = "ignoring multicast address: "; + } else if (isc_sockaddr_isexperimental(sa)) { + addr->flags |= FCTX_ADDRINFO_MARK; + msg = "ignoring experimental address: "; } else if (sa->type.sa.sa_family != AF_INET6) { return; } else if (IN6_IS_ADDR_V4MAPPED(&sa->type.sin6.sin6_addr)) { diff --git a/lib/isc/include/isc/netaddr.h b/lib/isc/include/isc/netaddr.h index 7057f2336f..5557e3eef1 100644 --- a/lib/isc/include/isc/netaddr.h +++ b/lib/isc/include/isc/netaddr.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: netaddr.h,v 1.23 2002/10/28 02:16:20 marka Exp $ */ +/* $Id: netaddr.h,v 1.24 2004/02/20 00:52:46 marka Exp $ */ #ifndef ISC_NETADDR_H #define ISC_NETADDR_H 1 @@ -119,6 +119,12 @@ isc_netaddr_ismulticast(isc_netaddr_t *na); * Returns ISC_TRUE if the address is a multicast address. */ +isc_boolean_t +isc_netaddr_isexperimental(isc_netaddr_t *na); +/* + * Returns ISC_TRUE if the address is a experimental (CLASS E) address. + */ + isc_boolean_t isc_netaddr_islinklocal(isc_netaddr_t *na); /* diff --git a/lib/isc/include/isc/sockaddr.h b/lib/isc/include/isc/sockaddr.h index 8fbd06ac03..470956b034 100644 --- a/lib/isc/include/isc/sockaddr.h +++ b/lib/isc/include/isc/sockaddr.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: sockaddr.h,v 1.40 2003/07/25 02:22:26 marka Exp $ */ +/* $Id: sockaddr.h,v 1.41 2004/02/20 00:52:46 marka Exp $ */ #ifndef ISC_SOCKADDR_H #define ISC_SOCKADDR_H 1 @@ -173,6 +173,12 @@ isc_sockaddr_ismulticast(isc_sockaddr_t *sa); * Returns ISC_TRUE if the address is a multicast address. */ +isc_boolean_t +isc_sockaddr_isexperimental(isc_sockaddr_t *sa); +/* + * Returns ISC_TRUE if the address is a experimental (CLASS E) address. + */ + isc_boolean_t isc_sockaddr_islinklocal(isc_sockaddr_t *sa); /* diff --git a/lib/isc/netaddr.c b/lib/isc/netaddr.c index f3c8e96835..77599d7438 100644 --- a/lib/isc/netaddr.c +++ b/lib/isc/netaddr.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: netaddr.c,v 1.25 2002/10/28 02:23:53 marka Exp $ */ +/* $Id: netaddr.c,v 1.26 2004/02/20 00:52:45 marka Exp $ */ #include @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -305,6 +306,16 @@ isc_netaddr_ismulticast(isc_netaddr_t *na) { } } +isc_boolean_t +isc_netaddr_isexperimental(isc_netaddr_t *na) { + switch (na->family) { + case AF_INET: + return (ISC_TF(ISC_IPADDR_ISEXPERIMENTAL(na->type.in.s_addr))); + default: + return (ISC_FALSE); /* XXXMLG ? */ + } +} + isc_boolean_t isc_netaddr_islinklocal(isc_netaddr_t *na) { switch (na->family) { diff --git a/lib/isc/sockaddr.c b/lib/isc/sockaddr.c index 9dbc718362..da06ceb045 100644 --- a/lib/isc/sockaddr.c +++ b/lib/isc/sockaddr.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: sockaddr.c,v 1.57 2003/07/25 02:22:26 marka Exp $ */ +/* $Id: sockaddr.c,v 1.58 2004/02/20 00:52:45 marka Exp $ */ #include @@ -421,6 +421,17 @@ isc_sockaddr_ismulticast(isc_sockaddr_t *sockaddr) { return (isc_netaddr_ismulticast(&netaddr)); } +isc_boolean_t +isc_sockaddr_isexperimental(isc_sockaddr_t *sockaddr) { + isc_netaddr_t netaddr; + + if (sockaddr->type.sa.sa_family == AF_INET) { + isc_netaddr_fromsockaddr(&netaddr, sockaddr); + return (isc_netaddr_isexperimental(&netaddr)); + } + return (ISC_FALSE); +} + isc_boolean_t isc_sockaddr_issitelocal(isc_sockaddr_t *sockaddr) { isc_netaddr_t netaddr; diff --git a/lib/isc/unix/include/isc/net.h b/lib/isc/unix/include/isc/net.h index 7d6e3f9ed3..aea8039973 100644 --- a/lib/isc/unix/include/isc/net.h +++ b/lib/isc/unix/include/isc/net.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: net.h,v 1.37 2003/01/16 03:59:27 marka Exp $ */ +/* $Id: net.h,v 1.38 2004/02/20 00:52:46 marka Exp $ */ #ifndef ISC_NET_H #define ISC_NET_H 1 @@ -230,6 +230,10 @@ typedef isc_uint16_t in_port_t; (((isc_uint32_t)(i) & ISC__IPADDR(0xf0000000)) \ == ISC__IPADDR(0xe0000000)) +#define ISC_IPADDR_ISEXPERIMENTAL(i) \ + (((isc_uint32_t)(i) & ISC__IPADDR(0xf0000000)) \ + == ISC__IPADDR(0xf0000000)) + /*** *** Functions. ***/ diff --git a/lib/isc/win32/include/isc/net.h b/lib/isc/win32/include/isc/net.h index ced83e5d79..149c0de422 100644 --- a/lib/isc/win32/include/isc/net.h +++ b/lib/isc/win32/include/isc/net.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: net.h,v 1.19 2003/01/16 03:59:28 marka Exp $ */ +/* $Id: net.h,v 1.20 2004/02/20 00:52:46 marka Exp $ */ #ifndef ISC_NET_H #define ISC_NET_H 1 @@ -139,6 +139,10 @@ typedef isc_uint16_t in_port_t; (((isc_uint32_t)(i) & ISC__IPADDR(0xf0000000)) \ == ISC__IPADDR(0xe0000000)) +#define ISC_IPADDR_ISEXPERIMENTAL(i) \ + (((isc_uint32_t)(i) & ISC__IPADDR(0xf0000000)) \ + == ISC__IPADDR(0xf0000000)) + /* * Fix the FD_SET and FD_CLR Macros to properly cast */