--------------------- PatchSet 6005 Date: 2007/10/24 02:34:39 Author: amosjeffries Branch: squid3-ipv6 Tag: (none) Log: Drop dead code within ALLOW_SOURCE_PING experiment Members: src/ICMP.h:1.1.2.8->1.1.2.9 src/ICMPSquid.cc:1.1.2.4->1.1.2.5 src/ICMPSquid.h:1.1.2.2->1.1.2.3 src/PeerSelectState.h:1.1.12.5->1.1.12.6 src/icp_v2.cc:1.17.8.21->1.17.8.22 src/icp_v3.cc:1.5.8.8->1.5.8.9 src/neighbors.cc:1.23.4.25->1.23.4.26 src/peer_select.cc:1.9.4.13->1.9.4.14 src/structs.h:1.66.2.34->1.66.2.35 Index: squid3/src/ICMP.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/ICMP.h,v retrieving revision 1.1.2.8 retrieving revision 1.1.2.9 diff -u -r1.1.2.8 -r1.1.2.9 --- squid3/src/ICMP.h 17 Oct 2007 11:25:49 -0000 1.1.2.8 +++ squid3/src/ICMP.h 24 Oct 2007 02:34:39 -0000 1.1.2.9 @@ -1,5 +1,5 @@ /* - * $Id: ICMP.h,v 1.1.2.8 2007/10/17 11:25:49 amosjeffries Exp $ + * $Id: ICMP.h,v 1.1.2.9 2007/10/24 02:34:39 amosjeffries Exp $ * * DEBUG: section 37 ICMP Routines * AUTHOR: Duane Wessels, Amos Jeffries @@ -37,21 +37,11 @@ #include "config.h" #include "IPAddress.h" -#if ALLOW_SOURCE_PING -#define MAX_PKT4_SZ 8192 -#define MAX_PAYLOAD (MAX_PKT_SZ - sizeof(struct icmphdr) - sizeof (char) - sizeof(struct timeval) - 1) -#if USE_IPV6 -#define MAX_PKT6_SZ (MAX_PAYLOAD + sizeof(struct timeval) + sizeof (char) + sizeof(struct icmp6_hdr) + 1) -#endif /* USE_IPV6 */ - -#else /* ! ALLOW_SOURCE_PING */ #define MAX_PAYLOAD SQUIDHOSTNAMELEN #define MAX_PKT4_SZ (MAX_PAYLOAD + sizeof(struct timeval) + sizeof (char) + sizeof(struct icmphdr) + 1) #if USE_IPV6 #define MAX_PKT6_SZ (MAX_PAYLOAD + sizeof(struct timeval) + sizeof (char) + sizeof(struct icmp6_hdr) + 1) -#endif /* USE_IPV6 */ - -#endif /* ALLOW_SOURCE_PING */ +#endif #if USE_ICMP Index: squid3/src/ICMPSquid.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/ICMPSquid.cc,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -u -r1.1.2.4 -r1.1.2.5 --- squid3/src/ICMPSquid.cc 24 Oct 2007 01:52:07 -0000 1.1.2.4 +++ squid3/src/ICMPSquid.cc 24 Oct 2007 02:34:39 -0000 1.1.2.5 @@ -1,5 +1,5 @@ /* - * $Id: ICMPSquid.cc,v 1.1.2.4 2007/10/24 01:52:07 amosjeffries Exp $ + * $Id: ICMPSquid.cc,v 1.1.2.5 2007/10/24 02:34:39 amosjeffries Exp $ * * DEBUG: section 37 ICMP Routines * AUTHOR: Duane Wessels, Amos Jeffries @@ -42,7 +42,7 @@ ICMPSquid icmpEngine; #define S_ICMP_ECHO 1 -#if ALLOW_SOURCE_PING +#if DEAD_CODE #define S_ICMP_ICP 2 #endif #define S_ICMP_DOM 3 @@ -72,6 +72,7 @@ ICMPSquid::SendEcho(IPAddress &to, int opcode, const char *payload, int len) { static pingerEchoData pecho; + int x, slen; if (payload && len == 0) len = strlen(payload); @@ -86,7 +87,23 @@ xmemcpy(pecho.payload, payload, len); - Send(&pecho, sizeof(pingerEchoData) - PINGER_PAYLOAD_SZ + len); + slen = sizeof(pingerEchoData) - PINGER_PAYLOAD_SZ + pecho.psize; + + debugs(37, 2, HERE << "to " << pecho->to << ", opcode " << + (int) pecho->opcode << ", len " << pecho->psize); + + x = comm_udp_send(icmp_sock, (char *) pecho, slen, 0); + + if (x < 0) { + debugs(37, 1, HERE << "send: " << xstrerror()); + + if (errno == ECONNREFUSED || errno == EPIPE) { + Close(); + return; + } + } else if (x != len) { + debugs(37, 1, HERE << "Wrote " << x << " of " << slen << " bytes"); + } } // static Callback to wrap the squid-side ICMP handler. @@ -141,12 +158,6 @@ case S_ICMP_ECHO: break; -#if ALLOW_SOURCE_PING - - case S_ICMP_ICP: - HandleSourcePing(F, preply.payload); - break; -#endif case S_ICMP_DOM: netdbHandlePingReply(F, preply.hops, preply.rtt); @@ -158,92 +169,8 @@ } } -void -ICMPSquid::Send(pingerEchoData * pkt, int len) -{ - int x; - - if (icmp_sock < 0) - return; - - debugs(37, 2, HERE << "to " << pkt->to << ", opcode " << - (int) pkt->opcode << ", len " << pkt->psize); - - x = comm_udp_send(icmp_sock, (char *) pkt, len, 0); - - if (x < 0) { - debugs(37, 1, HERE << "send: " << xstrerror()); - - if (errno == ECONNREFUSED || errno == EPIPE) { - Close(); - return; - } - } else if (x != len) { - debugs(37, 1, HERE << "Wrote " << x << " of " << len << " bytes"); - } -} - -#if ALLOW_SOURCE_PING -void -ICMPSquid::HandleSourcePing(const IPAddress &from, const char *buf) -{ - const cache_key *key; - icp_common_t header; - const char *url; - xmemcpy(&header, buf, sizeof(icp_common_t)); - url = buf + sizeof(icp_common_t); - key = icpGetCacheKey(url, (int) header.reqnum); - debugs(37, 3, HERE << "from " << from << ", key '" << storeKeyText(key) << "'"); - - /* call neighborsUdpAck even if ping_status != PING_WAITING */ - neighborsUdpAck(key, &header, from); -} -#endif - #endif /* USE_ICMP */ -#if ALLOW_SOURCE_PING -/** - \retval 1 SourcePing sent - \retval 0 ICMP not active. - \retval -1 An error occured. - */ -int -ICMPSquid::SourcePing(IPAddress &to, const icp_common_t * header, const char *url) -{ -#if USE_ICMP - char *payload; - int len; - int ulen; - debugs(37, 3, HERE << "'" << url << "'"); - - if(icmp_sock < 0) - return 0; - - if ((ulen = strlen(url)) > MAX_URL) - return -1; - - payload = memAllocate(MEM_8K_BUF); - - len = sizeof(icp_common_t); - - xmemcpy(payload, header, len); - - strcpy(payload + len, url); - - len += ulen + 1; - - SendEcho(to, S_ICMP_ICP, payload, len); - - memFree(payload, MEM_8K_BUF); - -#else - return -1; -#endif -} - -#endif - void ICMPSquid::DomainPing(IPAddress &to, const char *domain) { Index: squid3/src/ICMPSquid.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/ICMPSquid.h,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -r1.1.2.2 -r1.1.2.3 --- squid3/src/ICMPSquid.h 16 Oct 2007 13:35:08 -0000 1.1.2.2 +++ squid3/src/ICMPSquid.h 24 Oct 2007 02:34:39 -0000 1.1.2.3 @@ -1,5 +1,5 @@ /* - * $Id: ICMPSquid.h,v 1.1.2.2 2007/10/16 13:35:08 amosjeffries Exp $ + * $Id: ICMPSquid.h,v 1.1.2.3 2007/10/24 02:34:39 amosjeffries Exp $ * * DEBUG: section 37 ICMP Routines * AUTHOR: Duane Wessels, Amos Jeffries @@ -57,18 +57,9 @@ void DomainPing(IPAddress &to, const char *domain); -#if ALLOW_SOURCE_PING - int SourcePing(IPAddress &to, const icp_common_t * header, const char *url); - void HandleSourcePing(const IPAddress &from, const char *buf); -#endif - #if USE_ICMP virtual void SendEcho(IPAddress &, int, const char*, int); virtual void Recv(void); - -private: - void Send(pingerEchoData* pkt, int len); - #endif }; Index: squid3/src/PeerSelectState.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/PeerSelectState.h,v retrieving revision 1.1.12.5 retrieving revision 1.1.12.6 diff -u -r1.1.12.5 -r1.1.12.6 --- squid3/src/PeerSelectState.h 13 Jun 2007 08:09:44 -0000 1.1.12.5 +++ squid3/src/PeerSelectState.h 24 Oct 2007 02:34:39 -0000 1.1.12.6 @@ -1,6 +1,6 @@ /* - * $Id: PeerSelectState.h,v 1.1.12.5 2007/06/13 08:09:44 amosjeffries Exp $ + * $Id: PeerSelectState.h,v 1.1.12.6 2007/10/24 02:34:39 amosjeffries Exp $ * * AUTHOR: Robert Collins * @@ -66,16 +66,11 @@ IPAddress closest_parent_miss; /* - * ->hit and ->secho can be peer* because they should only be - * accessed during the thread when they are set + * ->hit can be peer* because it should only be + * accessed during the thread when it is set */ peer *hit; peer_t hit_type; -#if ALLOW_SOURCE_PING - - peer *secho; -#endif - ping_data ping; ACLChecklist *acl_checklist; private: Index: squid3/src/icp_v2.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/icp_v2.cc,v retrieving revision 1.17.8.21 retrieving revision 1.17.8.22 diff -u -r1.17.8.21 -r1.17.8.22 --- squid3/src/icp_v2.cc 30 Jul 2007 11:06:49 -0000 1.17.8.21 +++ squid3/src/icp_v2.cc 24 Oct 2007 02:34:39 -0000 1.17.8.22 @@ -1,6 +1,6 @@ /* - * $Id: icp_v2.cc,v 1.17.8.21 2007/07/30 11:06:49 amosjeffries Exp $ + * $Id: icp_v2.cc,v 1.17.8.22 2007/10/24 02:34:39 amosjeffries Exp $ * * DEBUG: section 12 Internet Cache Protocol (ICP) * AUTHOR: Duane Wessels @@ -536,10 +536,6 @@ break; case ICP_HIT: -#if ALLOW_SOURCE_PING - - case ICP_SECHO: -#endif case ICP_DECHO: Index: squid3/src/icp_v3.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/icp_v3.cc,v retrieving revision 1.5.8.8 retrieving revision 1.5.8.9 diff -u -r1.5.8.8 -r1.5.8.9 --- squid3/src/icp_v3.cc 17 May 2007 10:51:15 -0000 1.5.8.8 +++ squid3/src/icp_v3.cc 24 Oct 2007 02:34:39 -0000 1.5.8.9 @@ -1,6 +1,6 @@ /* - * $Id: icp_v3.cc,v 1.5.8.8 2007/05/17 10:51:15 amosjeffries Exp $ + * $Id: icp_v3.cc,v 1.5.8.9 2007/10/24 02:34:39 amosjeffries Exp $ * * DEBUG: section 12 Internet Cache Protocol (ICP) * AUTHOR: Duane Wessels @@ -132,10 +132,6 @@ break; case ICP_HIT: -#if ALLOW_SOURCE_PING - - case ICP_SECHO: -#endif case ICP_DECHO: Index: squid3/src/neighbors.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/neighbors.cc,v retrieving revision 1.23.4.25 retrieving revision 1.23.4.26 diff -u -r1.23.4.25 -r1.23.4.26 --- squid3/src/neighbors.cc 16 Oct 2007 13:35:09 -0000 1.23.4.25 +++ squid3/src/neighbors.cc 24 Oct 2007 02:34:39 -0000 1.23.4.26 @@ -1,6 +1,6 @@ /* - * $Id: neighbors.cc,v 1.23.4.25 2007/10/16 13:35:09 amosjeffries Exp $ + * $Id: neighbors.cc,v 1.23.4.26 2007/10/24 02:34:39 amosjeffries Exp $ * * DEBUG: section 15 Neighbor Routines * AUTHOR: Harvest Derived @@ -696,37 +696,6 @@ if ((first_ping = first_ping->next) == NULL) first_ping = Config.peers; -#if ALLOW_SOURCE_PING - /* only do source_ping if we have neighbors */ - if (Config.npeers) { - const ipcache_addrs *ia = NULL; - - struct sockaddr_in to_addr; - char *host = request->host; - - if (!Config.onoff.source_ping) { - debugs(15, 6, "neighborsUdpPing: Source Ping is disabled."); - } else if ((ia = ipcache_gethostbyname(host, 0))) { - debugs(15, 6, "neighborsUdpPing: Source Ping: to " << host << " for '" << url << "'"); - echo_hdr.reqnum = reqnum; - - if (icmpSourcePing(ia->in_addrs[ia->cur], &echo_hdr, url) <= 0) { - to_addr.sin_family = AF_INET; - to_addr.sin_addr = ia->in_addrs[ia->cur]; - to_addr.sin_port = htons(echo_port); - query = _icp_common_t::createMessage(ICP_SECHO, 0, url, reqnum, 0); - icpUdpSend(theOutIcpConnection, - &to_addr, - query, - LOG_ICP_QUERY, - 0); - } - } else { - debugs(15, 6, "neighborsUdpPing: Source Ping: unknown host: " << host); - } - } - -#endif /* * How many replies to expect? */ @@ -1124,12 +1093,6 @@ if (p) { debugs(15, 1, "Ignoring SECHO from neighbor " << p->host); neighborCountIgnored(p); -#if ALLOW_SOURCE_PING - - } else if (Config.onoff.source_ping) { - mem->ping_reply_callback(NULL, ntype, PROTO_ICP, header, mem->ircb_data); -#endif - } else { debugs(15, 1, "Unsolicited SECHO from " << from); } Index: squid3/src/peer_select.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/peer_select.cc,v retrieving revision 1.9.4.13 retrieving revision 1.9.4.14 diff -u -r1.9.4.13 -r1.9.4.14 --- squid3/src/peer_select.cc 21 Jun 2007 11:06:12 -0000 1.9.4.13 +++ squid3/src/peer_select.cc 24 Oct 2007 02:34:39 -0000 1.9.4.14 @@ -1,6 +1,6 @@ /* - * $Id: peer_select.cc,v 1.9.4.13 2007/06/21 11:06:12 amosjeffries Exp $ + * $Id: peer_select.cc,v 1.9.4.14 2007/10/24 02:34:39 amosjeffries Exp $ * * DEBUG: section 44 Peer Selection Algorithm * AUTHOR: Duane Wessels @@ -459,18 +459,15 @@ if ((p = ps->hit)) { code = ps->hit_type == PEER_PARENT ? PARENT_HIT : SIBLING_HIT; } else -#if ALLOW_SOURCE_PING - if ((p = ps->secho)) { - code = SOURCE_FASTEST; - } else -#endif - if (!ps->closest_parent_miss.IsAnyAddr()) { - p = whichPeer(ps->closest_parent_miss); - code = CLOSEST_PARENT_MISS; - } else if (!ps->first_parent_miss.IsAnyAddr()) { - p = whichPeer(ps->first_parent_miss); - code = FIRST_PARENT_MISS; - } + { + if (!ps->closest_parent_miss.IsAnyAddr()) { + p = whichPeer(ps->closest_parent_miss); + code = CLOSEST_PARENT_MISS; + } else if (!ps->first_parent_miss.IsAnyAddr()) { + p = whichPeer(ps->first_parent_miss); + code = FIRST_PARENT_MISS; + } + } if (p && code != HIER_NONE) { debugs(44, 3, "peerSelect: " << hier_strings[code] << "/" << p->host); peerAddFwdServer(&ps->servers, p, code); @@ -663,14 +660,6 @@ return; } -#if ALLOW_SOURCE_PING - else if (op == ICP_SECHO) { - psstate->secho = p; - peerSelectFoo(psstate); - return; - } - -#endif if (psstate->ping.n_recv < psstate->ping.n_replies_expected) return; @@ -795,10 +784,6 @@ closest_parent_miss(), hit(NULL), hit_type(PEER_NONE), -#if ALLOW_SOURCE_PING - - secho( NULL), -#endif acl_checklist (NULL) { ; // no local defaults. Index: squid3/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/structs.h,v retrieving revision 1.66.2.34 retrieving revision 1.66.2.35 diff -u -r1.66.2.34 -r1.66.2.35 --- squid3/src/structs.h 16 Oct 2007 13:35:09 -0000 1.66.2.34 +++ squid3/src/structs.h 24 Oct 2007 02:34:39 -0000 1.66.2.35 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.66.2.34 2007/10/16 13:35:09 amosjeffries Exp $ + * $Id: structs.h,v 1.66.2.35 2007/10/24 02:34:39 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -494,11 +494,6 @@ int query_icmp; int icp_hit_stale; int buffered_logs; -#if ALLOW_SOURCE_PING - - int source_ping; -#endif - int common_log; int log_mime_hdrs; int log_fqdn;