--------------------- PatchSet 4570 Date: 2007/05/17 13:28:12 Author: amosjeffries Branch: squid3-ipv6 Tag: (none) Log: Roll conversion into some rather important areas of ipcache. Members: src/ACLDestinationDomain.cc:1.7.6.10->1.7.6.11 src/ACLDestinationIP.cc:1.6.6.5->1.6.6.6 src/comm.cc:1.47.2.24->1.47.2.25 src/ipcache.cc:1.9.2.21->1.9.2.22 src/multicast.cc:1.2.10.6->1.2.10.7 src/structs.h:1.66.2.16->1.66.2.17 Index: squid3/src/ACLDestinationDomain.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ACLDestinationDomain.cc,v retrieving revision 1.7.6.10 retrieving revision 1.7.6.11 diff -u -r1.7.6.10 -r1.7.6.11 --- squid3/src/ACLDestinationDomain.cc 10 May 2007 12:57:40 -0000 1.7.6.10 +++ squid3/src/ACLDestinationDomain.cc 17 May 2007 13:28:12 -0000 1.7.6.11 @@ -1,5 +1,5 @@ /* - * $Id: ACLDestinationDomain.cc,v 1.7.6.10 2007/05/10 12:57:40 amosjeffries Exp $ + * $Id: ACLDestinationDomain.cc,v 1.7.6.11 2007/05/17 13:28:12 amosjeffries Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -86,8 +86,7 @@ const char *fqdn = NULL; -/* FIXME INET6 : drop temp conversion */ IPAddress tmp(ia->in_addrs[0]); - fqdn = fqdncache_gethostbyaddr(tmp, FQDN_LOOKUP_IF_MISS); + fqdn = fqdncache_gethostbyaddr(ia->in_addrs[0], FQDN_LOOKUP_IF_MISS); if (fqdn) { return data->match(fqdn); Index: squid3/src/ACLDestinationIP.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ACLDestinationIP.cc,v retrieving revision 1.6.6.5 retrieving revision 1.6.6.6 diff -u -r1.6.6.5 -r1.6.6.6 --- squid3/src/ACLDestinationIP.cc 10 May 2007 12:57:40 -0000 1.6.6.5 +++ squid3/src/ACLDestinationIP.cc 17 May 2007 13:28:12 -0000 1.6.6.6 @@ -1,5 +1,5 @@ /* - * $Id: ACLDestinationIP.cc,v 1.6.6.5 2007/05/10 12:57:40 amosjeffries Exp $ + * $Id: ACLDestinationIP.cc,v 1.6.6.6 2007/05/17 13:28:12 amosjeffries Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -53,8 +53,7 @@ /* Entry in cache found */ for (int k = 0; k < (int) ia->count; k++) { - /* FIXME INET6 : drop temporary conversion */ IPAddress tmp(ia->in_addrs[k]); - if (ACLIP::match(tmp)) + if (ACLIP::match(ia->in_addrs[k])) return 1; } Index: squid3/src/comm.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/comm.cc,v retrieving revision 1.47.2.24 retrieving revision 1.47.2.25 diff -u -r1.47.2.24 -r1.47.2.25 --- squid3/src/comm.cc 17 May 2007 10:51:08 -0000 1.47.2.24 +++ squid3/src/comm.cc 17 May 2007 13:28:12 -0000 1.47.2.25 @@ -1,6 +1,6 @@ /* - * $Id: comm.cc,v 1.47.2.24 2007/05/17 10:51:08 amosjeffries Exp $ + * $Id: comm.cc,v 1.47.2.25 2007/05/17 13:28:12 amosjeffries Exp $ * * DEBUG: section 5 Socket Functions * AUTHOR: Harvest Derived @@ -1019,7 +1019,9 @@ } assert(ia->cur < ia->count); - cs->in_addr = ia->in_addrs[ia->cur]; + +/* FIXME INET6 : drop temp conversion */ struct in_addr tmp; ia->in_addrs[ia->cur].GetInAddr(tmp); + cs->in_addr = tmp; if (Config.onoff.balance_on_multiple_ip) ipcacheCycleAddr(cs->host, NULL); Index: squid3/src/ipcache.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ipcache.cc,v retrieving revision 1.9.2.21 retrieving revision 1.9.2.22 diff -u -r1.9.2.21 -r1.9.2.22 --- squid3/src/ipcache.cc 29 Apr 2007 05:47:33 -0000 1.9.2.21 +++ squid3/src/ipcache.cc 17 May 2007 13:28:12 -0000 1.9.2.22 @@ -1,6 +1,6 @@ /* - * $Id: ipcache.cc,v 1.9.2.21 2007/04/29 05:47:33 amosjeffries Exp $ + * $Id: ipcache.cc,v 1.9.2.22 2007/05/17 13:28:12 amosjeffries Exp $ * * DEBUG: section 14 IP Cache * AUTHOR: Harvest Derived @@ -408,7 +408,7 @@ if (answers[k]._class != RFC1035_CLASS_IN) continue; -#if INET6 +#if USE_IPV6 if (answers[k].type == RFC1035_TYPE_AAAA) { if (answers[k].rdlength != sizeof(struct in6_addr)) { debugs(14, 1, "ipcacheParse: Invalid IPv6 address in response to '" << name << "'"); @@ -421,7 +421,7 @@ if (answers[k].type == RFC1035_TYPE_A) { if (answers[k].rdlength != sizeof(struct in_addr)) { - debug(14, 1)("ipcacheParse: Invalid IPv4 address in response to '%s'\n", name); + debugs(14, 1, "ipcacheParse: Invalid IPv4 address in response to '" << name << "'"); continue; } na++; @@ -435,7 +435,7 @@ return 0; } - i->addrs.in_addrs = (struct IN_ADDR *)xcalloc(na, sizeof(struct IN_ADDR)); + i->addrs.in_addrs = (IPAddress *)xcalloc(na, sizeof(IPAddress)); i->addrs.bad_mask = (unsigned char *)xcalloc(na, sizeof(unsigned char)); for (j = 0, k = 0; k < nr; k++) { @@ -446,22 +446,22 @@ if (answers[k].rdlength != sizeof(struct in_addr)) continue; -#ifdef INET6 - xmemcpy(&i->addr.in_addrs[j], "\0\0\0\0\0\0\0\0\0\0\0xff\0xff", 12); - xmemcpy(((char *)&i->addrs.in_addrs[j++]) + 12, answers[k].rdata, 4); -#else - xmemcpy(&i->addrs.in_addrs[j++], answers[k].rdata, 4); -#endif + struct in_addr temp; + xmemcpy(&temp, &answers[k].rdata, sizeof(struct in_addr)); + i->addrs.in_addrs[j] = temp; - debugs(14, 3, "ipcacheParse: #" << j - 1 << " " << inet_ntoa(i->addrs.in_addrs[j - 1])); -#ifdef INET6 + debugs(14, 3, "ipcacheParse: #" << j - 1 << " " << i->addrs.in_addrs[j - 1] ); + +#if USE_IPV6 } else if (answers[k].type == RFC1035_TYPE_AAAA) { if (answers[k].rdlength != sizeof(struct in6_addr)) continue; - xmemcpy(&i->addrs.in_addrs[j++], answers[k].rdata, sizeof(struct in6_addr)); + struct in6_addr temp; + xmemcpy(&temp, &answers[k].rdata, sizeof(struct in6_addr)); + i->addrs.in_addrs[j] = temp; - debugs(14, 3, "ipcacheParse: #" << j - 1 << " " << inet_ntoa(i->addrs.in_addrs[j - 1])); + debugs(14, 3, "ipcacheParse: #" << j - 1 << " " << i->addrs.in_addrs[j - 1]); #endif } else if (answers[k].type != RFC1035_TYPE_CNAME) continue; @@ -603,7 +603,7 @@ memset(&static_addrs, '\0', sizeof(ipcache_addrs)); - static_addrs.in_addrs = (struct IN_ADDR *)xcalloc(1, sizeof(struct IN_ADDR)); + static_addrs.in_addrs = (IPAddress *)xcalloc(1, sizeof(IPAddress)); static_addrs.bad_mask = (unsigned char *)xcalloc(1, sizeof(unsigned char)); ipcache_high = (long) (((float) Config.ipcache.size * (float) Config.ipcache.high) / (float) 100); @@ -665,6 +665,8 @@ ipcacheStatPrint(ipcache_entry * i, StoreEntry * sentry) { int k; + char buf[MAX_IPSTRLEN]; + storeAppendPrintf(sentry, " %-32.32s %c%c %6d %6d %2d(%2d)", hashKeyStr(&i->hash), i->flags.fromhosts ? 'H' : ' ', @@ -675,8 +677,9 @@ (int) i->addrs.badcount); for (k = 0; k < (int) i->addrs.count; k++) { - storeAppendPrintf(sentry, " %45s-%3s", inet_ntoa(i->addrs.in_addrs[k]), - i->addrs.bad_mask[k] ? "BAD" : "OK "); /* Max. between 15 IPv4 / 45 IPv6 address length */ + storeAppendPrintf(sentry, " %45s-%3s", i->addrs.in_addrs[k].NtoA(buf,MAX_IPSTRLEN), + i->addrs.bad_mask[k] ? "BAD" : "OK "); + /* Max. between 15 IPv4 / 45 IPv6 address length */ } storeAppendPrintf(sentry, "\n"); @@ -830,7 +833,7 @@ ia->cur = 0; } - debugs(14, 3, "ipcacheCycleAddr: " << name << " now at " << inet_ntoa(ia->in_addrs[ia->cur])); + debugs(14, 3, "ipcacheCycleAddr: " << name << " now at " << ia->in_addrs[ia->cur]); } /* @@ -973,7 +976,7 @@ i->addrs.cur = 0; i->addrs.badcount = 0; - i->addrs.in_addrs = (struct IN_ADDR *)xcalloc(1, sizeof(struct IN_ADDR)); + i->addrs.in_addrs = (IPAddress *)xcalloc(1, sizeof(IPAddress)); i->addrs.bad_mask = (unsigned char *)xcalloc(1, sizeof(unsigned char)); i->addrs.in_addrs[0] = ip; i->addrs.bad_mask[0] = FALSE; Index: squid3/src/multicast.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/multicast.cc,v retrieving revision 1.2.10.6 retrieving revision 1.2.10.7 diff -u -r1.2.10.6 -r1.2.10.7 --- squid3/src/multicast.cc 29 Apr 2007 03:01:39 -0000 1.2.10.6 +++ squid3/src/multicast.cc 17 May 2007 13:28:12 -0000 1.2.10.7 @@ -1,6 +1,6 @@ /* - * $Id: multicast.cc,v 1.2.10.6 2007/04/29 03:01:39 amosjeffries Exp $ + * $Id: multicast.cc,v 1.2.10.7 2007/05/17 13:28:12 amosjeffries Exp $ * * DEBUG: section 7 Multicast * AUTHOR: Martin Hamilton @@ -66,14 +66,23 @@ } for (i = 0; i < (int) ia->count; i++) { - debugs(7, 10, "Listening for ICP requests on " << inet_ntoa(*(ia->in_addrs + i))); - mr.imr_multiaddr.s_addr = (ia->in_addrs + i)->s_addr; + debugs(7, 10, "Listening for ICP requests on " << ia->in_addrs[i] ); + +#if USE_IPV6 + if( ! ia->in_addrs[i].IsIPv4() ) { + debugs(7, 10, "ERROR: IPv6 Multicast Listen has not been implemented!"); + continue; + } +#endif + + ia->in_addrs[i].GetInAddr(mr.imr_multiaddr); + mr.imr_interface.s_addr = INADDR_ANY; x = setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *) &mr, sizeof(struct ip_mreq)); if (x < 0) - debugs(7, 1, "comm_join_mcast_groups: FD " << fd << ", [" << inet_ntoa(*(ia->in_addrs + i)) << "]"); + debugs(7, 1, "comm_join_mcast_groups: FD " << fd << ", IP=" << ia->in_addrs[i]); x = setsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP, &c, 1); Index: squid3/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/structs.h,v retrieving revision 1.66.2.16 retrieving revision 1.66.2.17 diff -u -r1.66.2.16 -r1.66.2.17 --- squid3/src/structs.h 16 May 2007 16:04:58 -0000 1.66.2.16 +++ squid3/src/structs.h 17 May 2007 13:28:12 -0000 1.66.2.17 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.66.2.16 2007/05/16 16:04:58 amosjeffries Exp $ + * $Id: structs.h,v 1.66.2.17 2007/05/17 13:28:12 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -935,8 +935,7 @@ struct _ipcache_addrs { - - struct IN_ADDR *in_addrs; + IPAddress *in_addrs; unsigned char *bad_mask; unsigned char count; unsigned char cur;