From: wessels <> Date: Thu, 21 May 1998 06:46:16 +0000 (+0000) Subject: Prevent forwarding loops from netdbClosestParent() X-Git-Tag: SQUID_3_0_PRE1~3300 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8ff4505bd7e7b03693d5d31308414290bf027a8d;p=thirdparty%2Fsquid.git Prevent forwarding loops from netdbClosestParent() --- diff --git a/src/neighbors.cc b/src/neighbors.cc index 169a58171f..2d3551f7de 100644 --- a/src/neighbors.cc +++ b/src/neighbors.cc @@ -1,6 +1,6 @@ /* - * $Id: neighbors.cc,v 1.211 1998/05/15 16:58:33 wessels Exp $ + * $Id: neighbors.cc,v 1.212 1998/05/21 00:46:16 wessels Exp $ * * DEBUG: section 15 Neighbor Routines * AUTHOR: Harvest Derived @@ -110,7 +110,6 @@ #define MCAST_COUNT_RATE 900 static int peerAllowedToUse(const peer *, request_t *); -static int peerHTTPOkay(const peer *, request_t *); static int peerWouldBePinged(const peer *, request_t *); static void neighborRemove(peer *); static peer *whichPeer(const struct sockaddr_in *from); @@ -247,7 +246,7 @@ peerWouldBePinged(const peer * p, request_t * request) } /* Return TRUE if it is okay to send an HTTP request to this peer. */ -static int +int peerHTTPOkay(const peer * p, request_t * request) { if (!peerAllowedToUse(p, request)) diff --git a/src/net_db.cc b/src/net_db.cc index ed030a4177..951c858e4b 100644 --- a/src/net_db.cc +++ b/src/net_db.cc @@ -1,6 +1,6 @@ /* - * $Id: net_db.cc,v 1.103 1998/05/20 21:06:23 wessels Exp $ + * $Id: net_db.cc,v 1.104 1998/05/21 00:46:17 wessels Exp $ * * DEBUG: section 37 Network Measurement Database * AUTHOR: Duane Wessels @@ -1071,7 +1071,7 @@ netdbExchangeStart(void *data) } peer * -netdbClosestParent(const char *host) +netdbClosestParent(const request_t *request) { #if USE_ICMP peer *p = NULL; @@ -1079,10 +1079,10 @@ netdbClosestParent(const char *host) const ipcache_addrs *ia; net_db_peer *h; int i; - n = netdbLookupHost(host); + n = netdbLookupHost(request->host); if (NULL == n) { /* try IP addr */ - ia = ipcache_gethostbyname(host, 0); + ia = ipcache_gethostbyname(request->host, 0); if (NULL != ia) n = netdbLookupAddr(ia->in_addrs[ia->cur]); } @@ -1100,8 +1100,12 @@ netdbClosestParent(const char *host) if (n->rtt > 0) if (n->rtt < h->rtt) break; - if ((p = peerFindByName(h->peername))) - return p; + p = peerFindByName(h->peername); + if (NULL == p) /* not found */ + continue; + if (!peerHTTPOkay(p, request)) /* not allowed */ + continue; + return p; } #endif return NULL; diff --git a/src/peer_select.cc b/src/peer_select.cc index b5e06a1ff2..f0a62c2e06 100644 --- a/src/peer_select.cc +++ b/src/peer_select.cc @@ -1,6 +1,6 @@ /* - * $Id: peer_select.cc,v 1.58 1998/05/15 15:16:30 wessels Exp $ + * $Id: peer_select.cc,v 1.59 1998/05/21 00:46:18 wessels Exp $ * * DEBUG: section 44 Peer Selection Algorithm * AUTHOR: Duane Wessels @@ -291,7 +291,7 @@ peerSelectFoo(ps_state * psstate) peerSelectCallback(psstate, p); return; #endif - } else if ((p = netdbClosestParent(request->host))) { + } else if ((p = netdbClosestParent(request))) { request->hier.alg = PEER_SA_NETDB; code = CLOSEST_PARENT; debug(44, 2) ("peerSelect: %s/%s\n", hier_strings[code], p->host); diff --git a/src/protos.h b/src/protos.h index 48565264e2..df525a6cba 100644 --- a/src/protos.h +++ b/src/protos.h @@ -522,6 +522,7 @@ extern void peerDestroy(peer * e); extern char *neighborTypeStr(const peer * e); extern void peerCheckConnectStart(peer *); extern void dump_peer_options(StoreEntry *, peer *); +extern int peerHTTPOkay(const peer *, request_t *); extern void netdbInit(void); extern void netdbHandlePingReply(const struct sockaddr_in *from, int hops, int rtt); @@ -539,7 +540,7 @@ extern int netdbHostPeerRtt(const char *host, peer * peer); extern void netdbBinaryExchange(StoreEntry *); extern EVH netdbExchangeStart; extern void netdbExchangeUpdatePeer(struct in_addr, peer *, double, double); -extern peer *netdbClosestParent(const char *host); +extern peer *netdbClosestParent(const request_t *); extern void cachemgrStart(int fd, request_t * request, StoreEntry * entry); extern void cachemgrRegister(const char *, const char *, OBJH *, int);