From: Christos Tsantilas Date: Wed, 27 Jul 2011 13:38:06 +0000 (+0300) Subject: icp clean-up and ipv6/ipv4 related fixes X-Git-Tag: take08~55^2~29 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9ca56f05f8b0a3508b688de96114091db08d3d51;p=thirdparty%2Fsquid.git icp clean-up and ipv6/ipv4 related fixes - The "Sender Host Address" field of the ICP messages header it is a 32bit integer so it can be only an ipv4 ip address. Moreover according the ICP RFC: "Sender Host Address The IPv4 address of the host sending the ICP message. This field should probably not be trusted over what is provided by getpeer- name(), accept(), and recvfrom(). There is some ambiguity over the original purpose of this field. In practice it is not used." This patch set the "Sender Host Address" field always to 0. - Remove the echo_hdr static variable from neighbors.cc file and the theIcpPublicHostID variables from the icp_v2.cc file. They are part of the old "source_ping" squid feature code which does not exist any more. - Remove the theIcpPrivateHostID variable from the icp_v2.cc file. It was used only to set the "Sender Host Address" icp message header field. --- diff --git a/src/icp_v2.cc b/src/icp_v2.cc index 1cfbd070ad..e6437ee831 100644 --- a/src/icp_v2.cc +++ b/src/icp_v2.cc @@ -83,9 +83,6 @@ static void icpHandleIcpV2(int, Ip::Address &, char *, int); /// \ingroup ServerProtocolICPInternal2 static void icpCount(void *, int, size_t, int); -/// \ingroup ServerProtocolICPInternal2 -static void icpGetOutgoingIpAddress(); - /** \ingroup ServerProtocolICPInternal2 * IcpQueueHead is global so comm_incoming() knows whether or not @@ -100,21 +97,6 @@ Comm::ConnectionPointer icpIncomingConn = NULL; /// \ingroup ServerProtocolICPInternal2 Comm::ConnectionPointer icpOutgoingConn = NULL; -/** \ingroup ServerProtocolICPInternal2 - * ICP v2 uses the outgoing address as host ID. - * NP: this *may* be identical to icpOutgoingConn->local - * but when IN/OUT sockets are shared we can't guarantee that - * so a separate variable is used for now. - * - * We have one for private use (sent only by this local cache) - * and one for public use (for external caches to contact us) - */ -Ip::Address theIcpPrivateHostID; - -/// \see theIcpPrivateHostID -Ip::Address theIcpPublicHostID; - - /* icp_common_t */ _icp_common_t::_icp_common_t() : opcode(ICP_INVALID), version(0), length(0), reqnum(0), flags(0), pad(0), shostid(0) {} @@ -299,7 +281,7 @@ _icp_common_t::createMessage( headerp->pad = htonl(pad); - theIcpPrivateHostID.GetInAddr( *((struct in_addr*)&headerp->shostid) ); + headerp->shostid = 0; urloffset = buf + sizeof(icp_common_t); @@ -745,26 +727,9 @@ icpConnectionsOpen(void) Comm::SetSelect(icpOutgoingConn->fd, COMM_SELECT_READ, icpHandleUdp, NULL, 0); fd_note(icpOutgoingConn->fd, "Outgoing ICP socket"); - icpGetOutgoingIpAddress(); } } -// Ensure that we have the IP address(es) to use for Host ID. -// The outgoing address is used as 'private' host ID used only on packets we send -static void -icpGetOutgoingIpAddress() -{ - struct addrinfo *xai = NULL; - theIcpPrivateHostID.SetEmpty(); - theIcpPrivateHostID.InitAddrInfo(xai); - if (getsockname(icpOutgoingConn->fd, xai->ai_addr, &xai->ai_addrlen) < 0) - debugs(50, DBG_IMPORTANT, "ERROR: Unable to identify ICP host ID to use for " << icpOutgoingConn - << ": getsockname: " << xstrerror()); - else - theIcpPrivateHostID = *xai; - theIcpPrivateHostID.FreeAddrInfo(xai); -} - static void icpIncomingConnectionOpened(int errNo) { @@ -783,19 +748,7 @@ icpIncomingConnectionOpened(int errNo) if (Config.Addrs.udp_outgoing.IsNoAddr()) { icpOutgoingConn = icpIncomingConn; debugs(12, DBG_IMPORTANT, "Sending ICP messages from " << icpOutgoingConn->local); - icpGetOutgoingIpAddress(); } - - // Ensure that we have the IP address(es) to use for Host ID. - // The listening address is used as 'public' host ID which can be used to contact us - struct addrinfo *xai = NULL; - theIcpPublicHostID.InitAddrInfo(xai); // reset xai - if (getsockname(icpIncomingConn->fd, xai->ai_addr, &xai->ai_addrlen) < 0) - debugs(50, DBG_IMPORTANT, "ERROR: Unable to identify ICP host ID to use for " << icpIncomingConn - << ": getsockname: " << xstrerror()); - else - theIcpPublicHostID = *xai; - theIcpPublicHostID.FreeAddrInfo(xai); } /** diff --git a/src/neighbors.cc b/src/neighbors.cc index ae4d6e18b1..2c32190e47 100644 --- a/src/neighbors.cc +++ b/src/neighbors.cc @@ -77,7 +77,6 @@ static OBJH neighborDumpPeers; static OBJH neighborDumpNonPeers; static void dump_peers(StoreEntry * sentry, peer * peers); -static icp_common_t echo_hdr; static u_short echo_port; static int NLateReplies = 0; @@ -565,17 +564,8 @@ neighbors_init(void) peerRefreshDNS((void *) 1); - if (echo_hdr.opcode == ICP_INVALID) { - echo_hdr.opcode = ICP_SECHO; - echo_hdr.version = ICP_VERSION_CURRENT; - echo_hdr.length = 0; - echo_hdr.reqnum = 0; - echo_hdr.flags = 0; - echo_hdr.pad = 0; - theIcpPublicHostID.GetInAddr( *((struct in_addr*)&echo_hdr.shostid) ); - sep = getservbyname("echo", "udp"); - echo_port = sep ? ntohs((u_short) sep->s_port) : 7; - } + sep = getservbyname("echo", "udp"); + echo_port = sep ? ntohs((u_short) sep->s_port) : 7; first_ping = Config.peers; } @@ -653,7 +643,6 @@ neighborsUdpPing(HttpRequest * request, if (p->icp.port == echo_port) { debugs(15, 4, "neighborsUdpPing: Looks like a dumb cache, send DECHO ping"); - echo_hdr.reqnum = reqnum; query = _icp_common_t::createMessage(ICP_DECHO, 0, url, reqnum, 0); icpUdpSend(icpOutgoingConn->fd, p->in_addr, query, LOG_ICP_QUERY, 0); } else {