--------------------- PatchSet 1644 Date: 2001/02/24 12:20:39 Author: rvenning Branch: ipv6 Tag: (none) Log: Well, it actually has been tested and works now. Requires that you configure with --enableipv6 --disable-internal-dns --disable-wccp, and it also still uses a deprecated API for name resolution. Tested to work on Redhat7.0 box, upgraded to 2.4.1 kernel. Will serve IPv4 content to IPv6 clients, and IPv6 content to IPv6 (and presumably IPv4) clients. ACLs are still an issue. Members: acconfig.h:1.3->1.3.6.1 include/config.h.in:1.3->1.3.6.1 include/rfc1035.h:1.3->1.3.6.1 include/util.h:1.4.4.1->1.4.4.2 lib/rfc1035.c:1.4->1.4.6.1 lib/safe_inet_addr.c:1.2.6.1->1.2.6.2 src/cache_cf.c:1.4.2.1->1.4.2.2 src/defines.h:1.3.6.1->1.3.6.2 src/dnsserver.c:1.3.6.1->1.3.6.2 src/ipcache.c:1.4.6.1->1.4.6.2 src/main.c:1.5.4.1->1.5.4.2 src/tools.c:1.4.2.1->1.4.2.2 Index: squid/acconfig.h =================================================================== RCS file: /cvsroot/squid-sf//squid/Attic/acconfig.h,v retrieving revision 1.3 retrieving revision 1.3.6.1 diff -u -r1.3 -r1.3.6.1 --- squid/acconfig.h 23 Oct 2000 15:04:16 -0000 1.3 +++ squid/acconfig.h 24 Feb 2001 12:20:39 -0000 1.3.6.1 @@ -20,7 +20,7 @@ * */ @ TOP @ -/* $Id: acconfig.h,v 1.3 2000/10/23 15:04:16 hno Exp $ */ +/* $Id: acconfig.h,v 1.3.6.1 2001/02/24 12:20:39 rvenning Exp $ */ /********************************* * START OF CONFIGURABLE OPTIONS * @@ -286,3 +286,9 @@ */ #undef USE_UNLINKD +/* + * Define if you want IPv6 aware squid. Requires that + * the host has IPv6 support, even if squid is only accessing + * and accessed by IPv4 hosts. + */ +#undef INET6 Index: squid/include/config.h.in =================================================================== RCS file: /cvsroot/squid-sf//squid/include/Attic/config.h.in,v retrieving revision 1.3 retrieving revision 1.3.6.1 diff -u -r1.3 -r1.3.6.1 --- squid/include/config.h.in 23 Oct 2000 15:04:18 -0000 1.3 +++ squid/include/config.h.in 24 Feb 2001 12:20:40 -0000 1.3.6.1 @@ -1,5 +1,5 @@ /* - * $Id: config.h.in,v 1.3 2000/10/23 15:04:18 hno Exp $ + * $Id: config.h.in,v 1.3.6.1 2001/02/24 12:20:40 rvenning Exp $ * * AUTHOR: Duane Wessels * @@ -97,15 +97,9 @@ #elif defined(__NetBSD__) #define _SQUID_NETBSD_ -#elif defined(__CYGWIN32__) || defined(__CYGWIN__) -#define _SQUID_CYGWIN_ - -#elif defined(WIN32) || defined(WINNT) || defined(__WIN32__) || defined(__WIN32) +#elif defined(__CYGWIN32__) || defined(WIN32) || defined(WINNT) || defined(__WIN32__) || defined(__WIN32) #define _SQUID_MSWIN_ -#elif defined(__APPLE__) -#define _SQUID_APPLE_ - #elif defined(sony_news) && defined(__svr4) #define _SQUID_NEWSOS6_ @@ -125,11 +119,11 @@ #endif #if !defined(CACHE_HTTP_PORT) -#define CACHE_HTTP_PORT @CACHE_HTTP_PORT@ +#define CACHE_HTTP_PORT 3128 #endif #if !defined(CACHE_ICP_PORT) -#define CACHE_ICP_PORT @CACHE_ICP_PORT@ +#define CACHE_ICP_PORT 3130 #endif #if !defined(CACHEMGR_HOSTNAME) @@ -192,4 +186,18 @@ #endif #define NUM32LEN sizeof(num32) /* this should always be 4 */ +/* Async-IO tuning */ +#if USE_ASYNC_IO +#ifdef _SQUID_LINUX_ +#define USE_ASYNC_IO_CLOSE 0 +#else +#define USE_ASYNC_IO_CLOSE 1 +#endif +#define USE_ASYNC_IO_OPEN 1 +#define USE_ASYNC_IO_UNLINK 0 +#define USE_ASYNC_IO_READ 1 +#define USE_ASYNC_IO_WRITE 1 +#define USE_ASYNC_IO_STAT 1 +#endif + #endif /* _CONFIG_H_ */ Index: squid/include/rfc1035.h =================================================================== RCS file: /cvsroot/squid-sf//squid/include/rfc1035.h,v retrieving revision 1.3 retrieving revision 1.3.6.1 diff -u -r1.3 -r1.3.6.1 --- squid/include/rfc1035.h 23 Oct 2000 15:04:18 -0000 1.3 +++ squid/include/rfc1035.h 24 Feb 2001 12:20:40 -0000 1.3.6.1 @@ -1,5 +1,5 @@ /* - * $Id: rfc1035.h,v 1.3 2000/10/23 15:04:18 hno Exp $ + * $Id: rfc1035.h,v 1.3.6.1 2001/02/24 12:20:40 rvenning Exp $ * * AUTHOR: Duane Wessels * @@ -55,6 +55,9 @@ extern unsigned short rfc1035BuildAQuery(const char *hostname, char *buf, size_t * szp); +extern unsigned short rfc1035BuildAAAAQuery(const char *hostname, + char *buf, + size_t * szp); extern unsigned short rfc1035BuildPTRQuery(const struct in_addr, char *buf, size_t * szp); @@ -70,5 +73,6 @@ #define RFC1035_TYPE_A 1 #define RFC1035_TYPE_PTR 12 #define RFC1035_CLASS_IN 1 +#define RFC1886_TYPE_AAAA 28 #endif /* ndef _RFC1035_H_ */ Index: squid/include/util.h =================================================================== RCS file: /cvsroot/squid-sf//squid/include/util.h,v retrieving revision 1.4.4.1 retrieving revision 1.4.4.2 diff -u -r1.4.4.1 -r1.4.4.2 --- squid/include/util.h 7 Dec 2000 13:58:10 -0000 1.4.4.1 +++ squid/include/util.h 24 Feb 2001 12:20:40 -0000 1.4.4.2 @@ -1,5 +1,5 @@ /* - * $Id: util.h,v 1.4.4.1 2000/12/07 13:58:10 rvenning Exp $ + * $Id: util.h,v 1.4.4.2 2001/02/24 12:20:40 rvenning Exp $ * * AUTHOR: Harvest Derived * @@ -113,7 +113,8 @@ extern int safe_inet_addr(const char *, SIA *); #if INET6 -const char * inet6_ntoa(const struct in6_addr in); +extern const char * inet6_ntoa(const struct in6_addr in); +extern int safe_inet_addr6(const char *, struct in6_addr *) #endif Index: squid/lib/rfc1035.c =================================================================== RCS file: /cvsroot/squid-sf//squid/lib/rfc1035.c,v retrieving revision 1.4 retrieving revision 1.4.6.1 diff -u -r1.4 -r1.4.6.1 --- squid/lib/rfc1035.c 3 Nov 2000 21:04:27 -0000 1.4 +++ squid/lib/rfc1035.c 24 Feb 2001 12:20:40 -0000 1.4.6.1 @@ -1,6 +1,6 @@ /* - * $Id: rfc1035.c,v 1.4 2000/11/03 21:04:27 hno Exp $ + * $Id: rfc1035.c,v 1.4.6.1 2001/02/24 12:20:40 rvenning Exp $ * * Low level DNS protocol routines * AUTHOR: Duane Wessels @@ -351,6 +351,7 @@ RR->rdlength = strlen(RR->rdata); break; case RFC1035_TYPE_A: + case RFC1886_TYPE_AAAA: default: RR->rdlength = ntohs(s); RR->rdata = malloc(RR->rdlength); @@ -468,18 +469,7 @@ return nr; } -/* - * rfc1035BuildAQuery() - * - * Builds a message buffer with a QUESTION to lookup A records - * for a hostname. Caller must allocate 'buf' which should - * probably be at least 512 octets. The 'szp' initially - * specifies the size of the buffer, on return it contains - * the size of the message (i.e. how much to write). - * Return value is the query ID. - */ -unsigned short -rfc1035BuildAQuery(const char *hostname, char *buf, size_t * szp) +int rfc1035BuildAddrQuery(const char *hostname, char * buf, size_t * szp, unsigned short addrType) { static rfc1035_header h; off_t offset = 0; @@ -499,12 +489,40 @@ offset += rfc1035QuestionPack(buf + offset, sz - offset, hostname, - RFC1035_TYPE_A, + addrType, RFC1035_CLASS_IN); assert(offset <= sz); *szp = (size_t) offset; return h.id; } + +/* + * rfc1035BuildAQuery() + * + * Builds a message buffer with a QUESTION to lookup A records + * for a hostname. Caller must allocate 'buf' which should + * probably be at least 512 octets. The 'szp' initially + * specifies the size of the buffer, on return it contains + * the size of the message (i.e. how much to write). + * Return value is the query ID. + */ +unsigned short +rfc1035BuildAQuery(const char *hostname, char *buf, size_t * szp) +{ + return rfc1035BuildAddrQuery(hostname, buf, szp, RFC1035_TYPE_A); +} + +/* + * rfc1035BuildAAAAQuery() + * + * exactly as rfc1035BuildAQuery(), but looks for AAAA records + */ +unsigned short +rfc1035BuildAAAAQuery(const char *hostname, char *buf, size_t * szp) +{ + return rfc1035BuildAddrQuery(hostname, buf, szp, RFC1886_TYPE_AAAA); +} + /* * rfc1035BuildPTRQuery() Index: squid/lib/safe_inet_addr.c =================================================================== RCS file: /cvsroot/squid-sf//squid/lib/safe_inet_addr.c,v retrieving revision 1.2.6.1 retrieving revision 1.2.6.2 diff -u -r1.2.6.1 -r1.2.6.2 --- squid/lib/safe_inet_addr.c 7 Dec 2000 13:58:10 -0000 1.2.6.1 +++ squid/lib/safe_inet_addr.c 24 Feb 2001 12:20:40 -0000 1.2.6.2 @@ -1,6 +1,6 @@ /* - * $Id: safe_inet_addr.c,v 1.2.6.1 2000/12/07 13:58:10 rvenning Exp $ + * $Id: safe_inet_addr.c,v 1.2.6.2 2001/02/24 12:20:40 rvenning Exp $ */ #include "config.h" @@ -85,6 +85,24 @@ #if INET6 +int +safe_inet_addr6(const char *buf, struct in_addr *addr) +{ + static char addrbuf[128]; + /* try IPv4 dotted quad first */ + if (safe_inet_addr(buf, addr) == 1) { + /* we need to convert to IPv6 mapped IPv4 address */ + xmemcpy(addrbuf, "::FFFF:", 7); + xmemcpy(&addrbuf[7], buf, strlen(buf) + 1); + return inet_pton(AF_INET6, addrbuf, addr); + } + + /* else try IPv6 */ + return inet_pton(AF_INET6, buf, addr); +} + + + const char * inet6_ntoa(const struct in6_addr in) { static char buff[INET6_ADDRSTRLEN]; Index: squid/src/cache_cf.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/cache_cf.c,v retrieving revision 1.4.2.1 retrieving revision 1.4.2.2 diff -u -r1.4.2.1 -r1.4.2.2 --- squid/src/cache_cf.c 7 Dec 2000 13:58:11 -0000 1.4.2.1 +++ squid/src/cache_cf.c 24 Feb 2001 12:20:40 -0000 1.4.2.2 @@ -1,6 +1,6 @@ /* - * $Id: cache_cf.c,v 1.4.2.1 2000/12/07 13:58:11 rvenning Exp $ + * $Id: cache_cf.c,v 1.4.2.2 2001/02/24 12:20:40 rvenning Exp $ * * DEBUG: section 3 Configuration File Parsing * AUTHOR: Harvest Derived @@ -589,12 +589,13 @@ if (token == NULL) self_destruct(); - if (SAFE_INET_ADDR(token, addr) == 1) - (void) 0; - else if ((hp = gethostbyname(token))) /* dont use ipcache */ - *addr = inaddrFromHostent(hp); + if (SAFE_INET_ADDR(token, addr)) + (void) 0; + else if ((hp = GETHOSTBYNAME(token))) { /* dont use ipcache */ + *addr = inaddrFromHostent(hp); + } else - self_destruct(); + self_destruct(); } static void @@ -1814,8 +1815,8 @@ ADDR_FROM_SA(s->s) = INADDR_ANY_ASSIGN; else if (1 == SAFE_INET_ADDR(host, &ADDR_FROM_SA(s->s))) (void) 0; - else if ((hp = gethostbyname(host))) /* dont use ipcache */ - ADDR_FROM_SA(s->s) = inaddrFromHostent(hp); + else if ((hp = GETHOSTBYNAME(host))) /* dont use ipcache */ + ADDR_FROM_SA(s->s) = inaddrFromHostent(hp); else self_destruct(); while (*head) Index: squid/src/defines.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/defines.h,v retrieving revision 1.3.6.1 retrieving revision 1.3.6.2 diff -u -r1.3.6.1 -r1.3.6.2 --- squid/src/defines.h 7 Dec 2000 13:58:11 -0000 1.3.6.1 +++ squid/src/defines.h 24 Feb 2001 12:20:40 -0000 1.3.6.2 @@ -1,6 +1,6 @@ /* - * $Id: defines.h,v 1.3.6.1 2000/12/07 13:58:11 rvenning Exp $ + * $Id: defines.h,v 1.3.6.2 2001/02/24 12:20:40 rvenning Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -31,6 +31,7 @@ * */ +#include #ifndef TRUE #define TRUE 1 #endif @@ -320,7 +321,10 @@ ((s).sin6_family) #define SAFE_INET_ADDR(host, addr) \ - inet_pton(AF_INET, host, addr) + safe_inet_addr6(host,addr) + +#define GETHOSTBYNAME(name) \ + gethostbyname2(name, AF_INET6) #else #define SOCKADDR_IN sockaddr_in @@ -361,6 +365,10 @@ #define SAFE_INET_ADDR(host, addr) \ safe_inet_addr(host,addr) +#define GETHOSTBYNAME(name) \ + gethostbyname(name) + + #endif Index: squid/src/dnsserver.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/dnsserver.c,v retrieving revision 1.3.6.1 retrieving revision 1.3.6.2 diff -u -r1.3.6.1 -r1.3.6.2 --- squid/src/dnsserver.c 7 Dec 2000 13:58:11 -0000 1.3.6.1 +++ squid/src/dnsserver.c 24 Feb 2001 12:20:40 -0000 1.3.6.2 @@ -1,6 +1,6 @@ /* - * $Id: dnsserver.c,v 1.3.6.1 2000/12/07 13:58:11 rvenning Exp $ + * $Id: dnsserver.c,v 1.3.6.2 2001/02/24 12:20:40 rvenning Exp $ * * DEBUG: section 0 DNS Resolver * AUTHOR: Harvest Derived @@ -138,6 +138,7 @@ #include "util.h" #include "snprintf.h" +#include "defines.h" #if !defined(_SQUID_AIX_) extern int h_errno; @@ -202,7 +203,7 @@ reverse = 1; result = gethostbyaddr((char *) &addr, sizeof(addr), AF_FAMILY); } else { - result = gethostbyname(buf); + result = GETHOSTBYNAME(buf); } if (NULL != result) break; @@ -310,10 +311,10 @@ } #if HAVE_RES_NSADDR_LIST _res.nsaddr_list[_res.nscount] = _res.nsaddr_list[0]; - SAFE_INET_ADDR(optarg, &ADDR_FROM_SA(_res.nsaddr_list[_res.nscount++])); + SAFE_INET_ADDR(optarg, &_res.nsaddr_list[_res.nscount++]); #elif HAVE_RES_NS_LIST _res.ns_list[_res.nscount] = _res.ns_list[0]; - SAFE_INET_ADDR(optarg, &ADDR_FROM_SA(_res.ns_list[_res.nscount++].addr)); + SAFE_INET_ADDR(optarg, &_res.ns_list[_res.nscount++].addr); #else /* Unknown NS list format */ fprintf(stderr, "-s is not supported on this resolver\n"); #endif Index: squid/src/ipcache.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/ipcache.c,v retrieving revision 1.4.6.1 retrieving revision 1.4.6.2 diff -u -r1.4.6.1 -r1.4.6.2 --- squid/src/ipcache.c 7 Dec 2000 13:58:11 -0000 1.4.6.1 +++ squid/src/ipcache.c 24 Feb 2001 12:20:40 -0000 1.4.6.2 @@ -1,6 +1,6 @@ /* - * $Id: ipcache.c,v 1.4.6.1 2000/12/07 13:58:11 rvenning Exp $ + * $Id: ipcache.c,v 1.4.6.2 2001/02/24 12:20:40 rvenning Exp $ * * DEBUG: section 14 IP Cache * AUTHOR: Harvest Derived @@ -270,7 +270,7 @@ i.addrs.bad_mask = xcalloc(ipcount, sizeof(unsigned char)); } for (j = 0, k = 0; k < ipcount; k++) { - if (safe_inet_addr(A[k], &i.addrs.in_addrs[j])) + if (safe_inet_addr(A[k], &(i.addrs.in_addrs[j]))) j++; else debug(14, 1) ("ipcacheParse: Invalid IP address '%s'\n", A[k]); Index: squid/src/main.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/main.c,v retrieving revision 1.5.4.1 retrieving revision 1.5.4.2 diff -u -r1.5.4.1 -r1.5.4.2 --- squid/src/main.c 7 Dec 2000 13:58:11 -0000 1.5.4.1 +++ squid/src/main.c 24 Feb 2001 12:20:40 -0000 1.5.4.2 @@ -1,6 +1,6 @@ /* - * $Id: main.c,v 1.5.4.1 2000/12/07 13:58:11 rvenning Exp $ + * $Id: main.c,v 1.5.4.2 2001/02/24 12:20:40 rvenning Exp $ * * DEBUG: section 1 Startup and Main Loop * AUTHOR: Harvest Derived @@ -613,6 +613,7 @@ memset(&local_addr, '\0', sizeof(local_addr)); SAFE_INET_ADDR(localhost, &local_addr); + debug(0,0) ("Local addr is %s\n", INET_NTOA(local_addr)); memset(&no_addr, '\xFF', sizeof(no_addr)); memset(&any_addr, '\0', sizeof(any_addr)); squid_srandom(time(NULL)); Index: squid/src/tools.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/tools.c,v retrieving revision 1.4.2.1 retrieving revision 1.4.2.2 diff -u -r1.4.2.1 -r1.4.2.2 --- squid/src/tools.c 7 Dec 2000 13:58:12 -0000 1.4.2.1 +++ squid/src/tools.c 24 Feb 2001 12:20:40 -0000 1.4.2.2 @@ -1,6 +1,6 @@ /* - * $Id: tools.c,v 1.4.2.1 2000/12/07 13:58:12 rvenning Exp $ + * $Id: tools.c,v 1.4.2.2 2001/02/24 12:20:40 rvenning Exp $ * * DEBUG: section 21 Misc Functions * AUTHOR: Harvest Derived @@ -721,6 +721,8 @@ { struct IN_ADDR s; xmemcpy(&s, hp->h_addr, sizeof(s)); + if (hp->h_length != sizeof(s)) + fatal("Error: address size in hostent is not the correct length\n"); return s; }