]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Prevent forwarding loops from netdbClosestParent()
authorwessels <>
Thu, 21 May 1998 06:46:16 +0000 (06:46 +0000)
committerwessels <>
Thu, 21 May 1998 06:46:16 +0000 (06:46 +0000)
src/neighbors.cc
src/net_db.cc
src/peer_select.cc
src/protos.h

index 169a58171fd27668d36af17e9e0fef2c81961ed2..2d3551f7de42fae65a8cc7d2c7b563468e3c8b6d 100644 (file)
@@ -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
 #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))
index ed030a41774a7c7c82c9428542f84df0404ca2c1..951c858e4b44b0bf1000e02a218477dc2bdc64f7 100644 (file)
@@ -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;
index b5e06a1ff27c86182b7baacb19b5868d0bd87f50..f0a62c2e0640f5db064063c63d1788459dc26434 100644 (file)
@@ -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);
index 48565264e200bc848ad501bfa7b7a4f3758e18d9..df525a6cbacfaa85498ea9e58917af7503ace453 100644 (file)
@@ -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);