neighbors.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2018 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 /* DEBUG: section 15 Neighbor Routines */
10 
11 #include "squid.h"
12 #include "acl/FilledChecklist.h"
13 #include "anyp/PortCfg.h"
14 #include "base/EnumIterator.h"
15 #include "CacheDigest.h"
16 #include "CachePeer.h"
17 #include "comm/Connection.h"
18 #include "comm/ConnOpener.h"
19 #include "event.h"
20 #include "FwdState.h"
21 #include "globals.h"
22 #include "htcp.h"
23 #include "HttpRequest.h"
24 #include "icmp/net_db.h"
25 #include "ICP.h"
26 #include "int.h"
27 #include "ip/Address.h"
28 #include "ip/tools.h"
29 #include "ipcache.h"
30 #include "MemObject.h"
31 #include "mgr/Registration.h"
32 #include "multicast.h"
33 #include "neighbors.h"
34 #include "NeighborTypeDomainList.h"
35 #include "pconn.h"
36 #include "PeerDigest.h"
37 #include "PeerPoolMgr.h"
38 #include "PeerSelectState.h"
39 #include "RequestFlags.h"
40 #include "SquidConfig.h"
41 #include "SquidMath.h"
42 #include "SquidTime.h"
43 #include "stat.h"
44 #include "Store.h"
45 #include "store_key_md5.h"
46 #include "tools.h"
47 
48 /* count mcast group peers every 15 minutes */
49 #define MCAST_COUNT_RATE 900
50 
51 bool peerAllowedToUse(const CachePeer *, PeerSelector *);
52 static int peerWouldBePinged(const CachePeer *, PeerSelector *);
53 static void neighborRemove(CachePeer *);
54 static void neighborAlive(CachePeer *, const MemObject *, const icp_common_t *);
55 #if USE_HTCP
56 static void neighborAliveHtcp(CachePeer *, const MemObject *, const HtcpReplyData *);
57 #endif
58 static void neighborCountIgnored(CachePeer *);
59 static void peerRefreshDNS(void *);
61 static void peerProbeConnect(CachePeer *, const bool reprobeIfBusy = false);
63 static void peerCountMcastPeersDone(void *data);
64 static void peerCountMcastPeersStart(void *data);
65 static void peerCountMcastPeersSchedule(CachePeer * p, time_t when);
67 
68 static void neighborIgnoreNonPeer(const Ip::Address &, icp_opcode);
71 static void dump_peers(StoreEntry * sentry, CachePeer * peers);
72 
73 static unsigned short echo_port;
74 
75 static int NLateReplies = 0;
76 static CachePeer *first_ping = NULL;
77 
78 const char *
80 {
81  if (p->type == PEER_NONE)
82  return "Non-Peer";
83 
84  if (p->type == PEER_SIBLING)
85  return "Sibling";
86 
87  if (p->type == PEER_MULTICAST)
88  return "Multicast Group";
89 
90  return "Parent";
91 }
92 
93 CachePeer *
94 whichPeer(const Ip::Address &from)
95 {
96  int j;
97 
98  CachePeer *p = NULL;
99  debugs(15, 3, "whichPeer: from " << from);
100 
101  for (p = Config.peers; p; p = p->next) {
102  for (j = 0; j < p->n_addresses; ++j) {
103  if (from == p->addresses[j] && from.port() == p->icp.port) {
104  return p;
105  }
106  }
107  }
108 
109  return NULL;
110 }
111 
112 peer_t
113 neighborType(const CachePeer * p, const AnyP::Uri &url)
114 {
115 
116  const NeighborTypeDomainList *d = NULL;
117 
118  for (d = p->typelist; d; d = d->next) {
119  if (0 == matchDomainName(url.host(), d->domain))
120  if (d->type != PEER_NONE)
121  return d->type;
122  }
123 #if PEER_MULTICAST_SIBLINGS
124  if (p->type == PEER_MULTICAST)
125  if (p->options.mcast_siblings)
126  return PEER_SIBLING;
127 #endif
128 
129  return p->type;
130 }
131 
135 bool
137 {
138  assert(ps);
139  HttpRequest *request = ps->request;
140  assert(request != NULL);
141 
142  if (neighborType(p, request->url) == PEER_SIBLING) {
143 #if PEER_MULTICAST_SIBLINGS
144  if (p->type == PEER_MULTICAST && p->options.mcast_siblings &&
145  (request->flags.noCache || request->flags.refresh || request->flags.loopDetected || request->flags.needValidation))
146  debugs(15, 2, "peerAllowedToUse(" << p->name << ", " << request->url.authority() << ") : multicast-siblings optimization match");
147 #endif
148  if (request->flags.noCache)
149  return false;
150 
151  if (request->flags.refresh)
152  return false;
153 
154  if (request->flags.loopDetected)
155  return false;
156 
157  if (request->flags.needValidation)
158  return false;
159  }
160 
161  // CONNECT requests are proxy requests. Not to be forwarded to origin servers.
162  // Unless the destination port matches, in which case we MAY perform a 'DIRECT' to this CachePeer.
163  if (p->options.originserver && request->method == Http::METHOD_CONNECT && request->url.port() != p->http_port)
164  return false;
165 
166  if (p->access == NULL)
167  return true;
168 
169  ACLFilledChecklist checklist(p->access, request, NULL);
170  checklist.al = ps->al;
171  checklist.syncAle(request, nullptr);
172  return checklist.fastCheck().allowed();
173 }
174 
175 /* Return TRUE if it is okay to send an ICP request to this CachePeer. */
176 static int
178 {
179  assert(ps);
180  HttpRequest *request = ps->request;
181 
182  if (p->icp.port == 0)
183  return 0;
184 
185  if (p->options.no_query)
186  return 0;
187 
188  if (p->options.mcast_responder)
189  return 0;
190 
191  if (p->n_addresses == 0)
192  return 0;
193 
195  return 0;
196 
197  /* the case below seems strange, but can happen if the
198  * URL host is on the other side of a firewall */
199  if (p->type == PEER_SIBLING)
200  if (!request->flags.hierarchical)
201  return 0;
202 
203  if (!peerAllowedToUse(p, ps))
204  return 0;
205 
206  /* Ping dead peers every timeout interval */
208  return 1;
209 
210  if (!neighborUp(p))
211  return 0;
212 
213  return 1;
214 }
215 
216 bool
218 {
219  const int effectiveLimit = p->max_conn <= 0 ? Squid_MaxFD : p->max_conn;
220  const int remaining = effectiveLimit - p->stats.conn_open;
221  debugs(15, 7, remaining << '=' << effectiveLimit << '-' << p->stats.conn_open);
222  return remaining > 0;
223 }
224 
225 bool
227 {
228  // Standby connections can be used without opening new connections.
229  const int standbys = p->standby.pool ? p->standby.pool->count() : 0;
230 
231  // XXX: Some idle pconns can be used without opening new connections.
232  // Complication: Idle pconns cannot be reused for some requests.
233  const int usableIdles = 0;
234 
235  const int available = standbys + usableIdles;
236  debugs(15, 7, available << '=' << standbys << '+' << usableIdles);
237  return available > 0;
238 }
239 
240 void
242 {
243  --p->stats.conn_open;
244  if (p->standby.waitingForClose && peerCanOpenMore(p)) {
245  p->standby.waitingForClose = false;
246  PeerPoolMgr::Checkpoint(p->standby.mgr, "conn closed");
247  }
248 }
249 
250 /* Return TRUE if it is okay to send an HTTP request to this CachePeer. */
251 int
253 {
254  if (!peerCanOpenMore(p) && !peerHasConnAvailable(p))
255  return 0;
256 
257  if (!peerAllowedToUse(p, ps))
258  return 0;
259 
260  if (!neighborUp(p))
261  return 0;
262 
263  return 1;
264 }
265 
266 int
268 {
269  CachePeer *p = NULL;
270  int count = 0;
271 
272  for (p = Config.peers; p; p = p->next)
273  if (peerWouldBePinged(p, ps))
274  ++count;
275 
276  debugs(15, 3, "neighborsCount: " << count);
277 
278  return count;
279 }
280 
281 CachePeer *
283 {
284  assert(ps);
285  HttpRequest *request = ps->request;
286 
287  CachePeer *p = NULL;
288 
289  for (p = Config.peers; p; p = p->next) {
290  if (!neighborUp(p))
291  continue;
292 
293  if (neighborType(p, request->url) != PEER_PARENT)
294  continue;
295 
296  if (!peerHTTPOkay(p, ps))
297  continue;
298 
299  break;
300  }
301 
302  debugs(15, 3, "getFirstUpParent: returning " << (p ? p->host : "NULL"));
303  return p;
304 }
305 
306 CachePeer *
308 {
309  assert(ps);
310  HttpRequest *request = ps->request;
311 
312  CachePeer *p;
313  CachePeer *q = NULL;
314 
315  for (p = Config.peers; p; p = p->next) {
316  if (!p->options.roundrobin)
317  continue;
318 
319  if (neighborType(p, request->url) != PEER_PARENT)
320  continue;
321 
322  if (!peerHTTPOkay(p, ps))
323  continue;
324 
325  if (p->weight == 0)
326  continue;
327 
328  if (q) {
329  if (p->weight == q->weight) {
330  if (q->rr_count < p->rr_count)
331  continue;
332  } else if ( ((double) q->rr_count / q->weight) < ((double) p->rr_count / p->weight)) {
333  continue;
334  }
335  }
336 
337  q = p;
338  }
339 
340  if (q)
341  ++ q->rr_count;
342 
343  debugs(15, 3, HERE << "returning " << (q ? q->host : "NULL"));
344 
345  return q;
346 }
347 
348 CachePeer *
350 {
351  assert(ps);
352  HttpRequest *request = ps->request;
353 
354  CachePeer *p;
355  CachePeer *q = NULL;
356  int weighted_rtt;
357 
358  for (p = Config.peers; p; p = p->next) {
360  continue;
361 
362  if (neighborType(p, request->url) != PEER_PARENT)
363  continue;
364 
365  if (!peerHTTPOkay(p, ps))
366  continue;
367 
368  if (q && q->rr_count < p->rr_count)
369  continue;
370 
371  q = p;
372  }
373 
374  if (q && q->rr_count > 1000000)
375  for (p = Config.peers; p; p = p->next) {
377  continue;
378 
379  if (neighborType(p, request->url) != PEER_PARENT)
380  continue;
381 
382  p->rr_count = 0;
383  }
384 
385  if (q) {
386  weighted_rtt = (q->stats.rtt - q->basetime) / q->weight;
387 
388  if (weighted_rtt < 1)
389  weighted_rtt = 1;
390 
391  q->rr_count += weighted_rtt;
392 
393  debugs(15, 3, "getWeightedRoundRobinParent: weighted_rtt " << weighted_rtt);
394  }
395 
396  debugs(15, 3, "getWeightedRoundRobinParent: returning " << (q ? q->host : "NULL"));
397  return q;
398 }
399 
410 static void
412 {
413  peerClearRR();
414  eventAdd("peerClearRR", peerClearRRLoop, data, 5 * 60.0, 0);
415 }
416 
422 void
424 {
425  static bool event_added = false;
426  if (!event_added) {
428  event_added=true;
429  }
430 }
431 
439 void
441 {
442  CachePeer *p = NULL;
443  for (p = Config.peers; p; p = p->next) {
444  p->rr_count = 1;
445  }
446 }
447 
451 void
453 {
454  if (p->stats.logged_state == PEER_DEAD && p->tcp_up) {
455  debugs(15, DBG_IMPORTANT, "Detected REVIVED " << neighborTypeStr(p) << ": " << p->name);
457  peerClearRR();
458  if (p->standby.mgr.valid())
459  PeerPoolMgr::Checkpoint(p->standby.mgr, "revived peer");
460  }
461 
463  p->stats.probe_start = 0;
464 }
465 
466 CachePeer *
468 {
469  assert(ps);
470  HttpRequest *request = ps->request;
471 
472  CachePeer *p = NULL;
473 
474  for (p = Config.peers; p; p = p->next) {
475  if (neighborType(p, request->url) != PEER_PARENT)
476  continue;
477 
478  if (!p->options.default_parent)
479  continue;
480 
481  if (!peerHTTPOkay(p, ps))
482  continue;
483 
484  debugs(15, 3, "getDefaultParent: returning " << p->host);
485 
486  return p;
487  }
488 
489  debugs(15, 3, "getDefaultParent: returning NULL");
490  return NULL;
491 }
492 
493 CachePeer *
495 {
496  return p->next;
497 }
498 
499 CachePeer *
501 {
502  return Config.peers;
503 }
504 
505 static void
507 {
508  CachePeer *p = NULL;
509  CachePeer **P = NULL;
510  p = Config.peers;
511  P = &Config.peers;
512 
513  while (p) {
514  if (target == p)
515  break;
516 
517  P = &p->next;
518 
519  p = p->next;
520  }
521 
522  if (p) {
523  *P = p->next;
524  p->next = NULL;
525  delete p;
526  --Config.npeers;
527  }
528 
529  first_ping = Config.peers;
530 }
531 
532 static void
534 {
535  Mgr::RegisterAction("server_list",
536  "Peer Cache Statistics",
537  neighborDumpPeers, 0, 1);
538 
540  Mgr::RegisterAction("non_peers",
541  "List of Unknown sites sending ICP messages",
542  neighborDumpNonPeers, 0, 1);
543  }
544 }
545 
546 void
548 {
549  struct servent *sep = NULL;
550  const char *me = getMyHostname();
551  CachePeer *thisPeer = NULL;
552  CachePeer *next = NULL;
553 
555 
557 
558  for (thisPeer = Config.peers; thisPeer; thisPeer = next) {
559  next = thisPeer->next;
560 
561  if (0 != strcmp(thisPeer->host, me))
562  continue;
563 
564  for (AnyP::PortCfgPointer s = HttpPortList; s != NULL; s = s->next) {
565  if (thisPeer->http_port != s->s.port())
566  continue;
567 
568  debugs(15, DBG_IMPORTANT, "WARNING: Peer looks like this host");
569 
570  debugs(15, DBG_IMPORTANT, " Ignoring " <<
571  neighborTypeStr(thisPeer) << " " << thisPeer->host <<
572  "/" << thisPeer->http_port << "/" <<
573  thisPeer->icp.port);
574 
575  neighborRemove(thisPeer);
576  }
577  }
578  }
579 
580  peerRefreshDNS((void *) 1);
581 
582  sep = getservbyname("echo", "udp");
583  echo_port = sep ? ntohs((unsigned short) sep->s_port) : 7;
584 
585  first_ping = Config.peers;
586 }
587 
588 int
590  StoreEntry * entry,
591  IRCB * callback,
592  PeerSelector *ps,
593  int *exprep,
594  int *timeout)
595 {
596  const char *url = entry->url();
597  MemObject *mem = entry->mem_obj;
598  CachePeer *p = NULL;
599  int i;
600  int reqnum = 0;
601  int flags;
602  int queries_sent = 0;
603  int peers_pinged = 0;
604  int parent_timeout = 0, parent_exprep = 0;
605  int sibling_timeout = 0, sibling_exprep = 0;
606  int mcast_timeout = 0, mcast_exprep = 0;
607 
608  if (Config.peers == NULL)
609  return 0;
610 
611  assert(!entry->hasDisk());
612 
613  mem->start_ping = current_time;
614 
616 
617  mem->ircb_data = ps;
618 
619  reqnum = icpSetCacheKey((const cache_key *)entry->key);
620 
621  for (i = 0, p = first_ping; i++ < Config.npeers; p = p->next) {
622  if (p == NULL)
623  p = Config.peers;
624 
625  debugs(15, 5, "neighborsUdpPing: Peer " << p->host);
626 
627  if (!peerWouldBePinged(p, ps))
628  continue; /* next CachePeer */
629 
630  ++peers_pinged;
631 
632  debugs(15, 4, "neighborsUdpPing: pinging peer " << p->host << " for '" << url << "'");
633 
634  debugs(15, 3, "neighborsUdpPing: key = '" << entry->getMD5Text() << "'");
635 
636  debugs(15, 3, "neighborsUdpPing: reqnum = " << reqnum);
637 
638 #if USE_HTCP
639  if (p->options.htcp && !p->options.htcp_only_clr) {
640  if (Config.Port.htcp <= 0) {
641  debugs(15, DBG_CRITICAL, "HTCP is disabled! Cannot send HTCP request to peer.");
642  continue;
643  }
644 
645  debugs(15, 3, "neighborsUdpPing: sending HTCP query");
646  if (htcpQuery(entry, request, p) <= 0)
647  continue; // unable to send.
648  } else
649 #endif
650  {
652  debugs(15, DBG_CRITICAL, "ICP is disabled! Cannot send ICP request to peer.");
653  continue;
654  } else {
655 
656  if (p->type == PEER_MULTICAST)
658 
659  if (p->icp.port == echo_port) {
660  debugs(15, 4, "neighborsUdpPing: Looks like a dumb cache, send DECHO ping");
661  // TODO: Get ALE from callback_data if possible.
662  icpCreateAndSend(ICP_DECHO, 0, url, reqnum, 0,
663  icpOutgoingConn->fd, p->in_addr, nullptr);
664  } else {
665  flags = 0;
666 
667  if (Config.onoff.query_icmp)
668  if (p->icp.version == ICP_VERSION_2)
669  flags |= ICP_FLAG_SRC_RTT;
670 
671  // TODO: Get ALE from callback_data if possible.
672  icpCreateAndSend(ICP_QUERY, flags, url, reqnum, 0,
673  icpOutgoingConn->fd, p->in_addr, nullptr);
674  }
675  }
676  }
677 
678  ++queries_sent;
679 
680  ++ p->stats.pings_sent;
681 
682  if (p->type == PEER_MULTICAST) {
683  mcast_exprep += p->mcast.n_replies_expected;
684  mcast_timeout += (p->stats.rtt * p->mcast.n_replies_expected);
685  } else if (neighborUp(p)) {
686  /* its alive, expect a reply from it */
687 
688  if (neighborType(p, request->url) == PEER_PARENT) {
689  ++parent_exprep;
690  parent_timeout += p->stats.rtt;
691  } else {
692  ++sibling_exprep;
693  sibling_timeout += p->stats.rtt;
694  }
695  } else {
696  /* Neighbor is dead; ping it anyway, but don't expect a reply */
697  /* log it once at the threshold */
698 
699  if (p->stats.logged_state == PEER_ALIVE) {
700  debugs(15, DBG_IMPORTANT, "Detected DEAD " << neighborTypeStr(p) << ": " << p->name);
702  }
703  }
704 
706 
707  /*
708  * keep probe_start == 0 for a multicast CachePeer,
709  * so neighborUp() never says this CachePeer is dead.
710  */
711 
712  if ((p->type != PEER_MULTICAST) && (p->stats.probe_start == 0))
714  }
715 
716  if ((first_ping = first_ping->next) == NULL)
717  first_ping = Config.peers;
718 
719  /*
720  * How many replies to expect?
721  */
722  *exprep = parent_exprep + sibling_exprep + mcast_exprep;
723 
724  /*
725  * If there is a configured timeout, use it
726  */
728  *timeout = Config.Timeout.icp_query;
729  else {
730  if (*exprep > 0) {
731  if (parent_exprep)
732  *timeout = 2 * parent_timeout / parent_exprep;
733  else if (mcast_exprep)
734  *timeout = 2 * mcast_timeout / mcast_exprep;
735  else
736  *timeout = 2 * sibling_timeout / sibling_exprep;
737  } else
738  *timeout = 2000; /* 2 seconds */
739 
741  if (*timeout > Config.Timeout.icp_query_max)
742  *timeout = Config.Timeout.icp_query_max;
743 
744  if (*timeout < Config.Timeout.icp_query_min)
745  *timeout = Config.Timeout.icp_query_min;
746  }
747 
748  return peers_pinged;
749 }
750 
751 /* lookup the digest of a given CachePeer */
752 lookup_t
754 {
755 #if USE_CACHE_DIGESTS
756  assert(ps);
757  HttpRequest *request = ps->request;
758  const cache_key *key = request ? storeKeyPublicByRequest(request) : NULL;
759  assert(p);
760  assert(request);
761  debugs(15, 5, "peerDigestLookup: peer " << p->host);
762  /* does the peeer have a valid digest? */
763 
764  if (!p->digest) {
765  debugs(15, 5, "peerDigestLookup: gone!");
766  return LOOKUP_NONE;
767  } else if (!peerHTTPOkay(p, ps)) {
768  debugs(15, 5, "peerDigestLookup: !peerHTTPOkay");
769  return LOOKUP_NONE;
770  } else if (!p->digest->flags.needed) {
771  debugs(15, 5, "peerDigestLookup: note need");
773  return LOOKUP_NONE;
774  } else if (!p->digest->flags.usable) {
775  debugs(15, 5, "peerDigestLookup: !ready && " << (p->digest->flags.requested ? "" : "!") << "requested");
776  return LOOKUP_NONE;
777  }
778 
779  debugs(15, 5, "peerDigestLookup: OK to lookup peer " << p->host);
780  assert(p->digest->cd);
781  /* does digest predict a hit? */
782 
783  if (!p->digest->cd->contains(key))
784  return LOOKUP_MISS;
785 
786  debugs(15, 5, "peerDigestLookup: peer " << p->host << " says HIT!");
787 
788  return LOOKUP_HIT;
789 
790 #endif
791 
792  return LOOKUP_NONE;
793 }
794 
795 /* select best CachePeer based on cache digests */
796 CachePeer *
798 {
799  CachePeer *best_p = NULL;
800 #if USE_CACHE_DIGESTS
801  assert(ps);
802  HttpRequest *request = ps->request;
803 
804  int best_rtt = 0;
805  int choice_count = 0;
806  int ichoice_count = 0;
807  CachePeer *p;
808  int p_rtt;
809  int i;
810 
811  if (!request->flags.hierarchical)
812  return NULL;
813 
814  storeKeyPublicByRequest(request);
815 
816  for (i = 0, p = first_ping; i++ < Config.npeers; p = p->next) {
817  lookup_t lookup;
818 
819  if (!p)
820  p = Config.peers;
821 
822  if (i == 1)
823  first_ping = p;
824 
825  lookup = peerDigestLookup(p, ps);
826 
827  if (lookup == LOOKUP_NONE)
828  continue;
829 
830  ++choice_count;
831 
832  if (lookup == LOOKUP_MISS)
833  continue;
834 
835  p_rtt = netdbHostRtt(p->host);
836 
837  debugs(15, 5, "neighborsDigestSelect: peer " << p->host << " rtt: " << p_rtt);
838 
839  /* is this CachePeer better than others in terms of rtt ? */
840  if (!best_p || (p_rtt && p_rtt < best_rtt)) {
841  best_p = p;
842  best_rtt = p_rtt;
843 
844  if (p_rtt) /* informative choice (aka educated guess) */
845  ++ichoice_count;
846 
847  debugs(15, 4, "neighborsDigestSelect: peer " << p->host << " leads with rtt " << best_rtt);
848  }
849  }
850 
851  debugs(15, 4, "neighborsDigestSelect: choices: " << choice_count << " (" << ichoice_count << ")");
852  peerNoteDigestLookup(request, best_p,
853  best_p ? LOOKUP_HIT : (choice_count ? LOOKUP_MISS : LOOKUP_NONE));
854  request->hier.n_choices = choice_count;
855  request->hier.n_ichoices = ichoice_count;
856 #endif
857 
858  return best_p;
859 }
860 
861 void
863 {
864 #if USE_CACHE_DIGESTS
865  if (p)
866  strncpy(request->hier.cd_host, p->host, sizeof(request->hier.cd_host)-1);
867  else
868  *request->hier.cd_host = '\0';
869 
870  request->hier.cd_lookup = lookup;
871  debugs(15, 4, "peerNoteDigestLookup: peer " << (p? p->host : "<none>") << ", lookup: " << lookup_t_str[lookup] );
872 #endif
873 }
874 
875 static void
876 neighborAlive(CachePeer * p, const MemObject *, const icp_common_t * header)
877 {
878  peerAlive(p);
879  ++ p->stats.pings_acked;
880 
881  if ((icp_opcode) header->opcode <= ICP_END)
882  ++ p->icp.counts[header->opcode];
883 
884  p->icp.version = (int) header->version;
885 }
886 
887 static void
889 {
890  int rtt, rtt_av_factor;
891 
892  if (!mem)
893  return;
894 
895  if (!mem->start_ping.tv_sec)
896  return;
897 
898  rtt = tvSubMsec(mem->start_ping, current_time);
899 
900  if (rtt < 1 || rtt > 10000)
901  return;
902 
903  rtt_av_factor = RTT_AV_FACTOR;
904 
906  rtt_av_factor = RTT_BACKGROUND_AV_FACTOR;
907 
908  p->stats.rtt = Math::intAverage(p->stats.rtt, rtt, p->stats.pings_acked, rtt_av_factor);
909 }
910 
911 #if USE_HTCP
912 static void
914 {
915  peerAlive(p);
916  ++ p->stats.pings_acked;
917  ++ p->htcp.counts[htcp->hit ? 1 : 0];
918  p->htcp.version = htcp->version;
919 }
920 
921 #endif
922 
923 static void
925 {
926  if (p == NULL)
927  return;
928 
929  ++ p->stats.ignored_replies;
930 
931  ++NLateReplies;
932 }
933 
934 static CachePeer *non_peers = NULL;
935 
936 static void
938 {
939  CachePeer *np;
940 
941  for (np = non_peers; np; np = np->next) {
942  if (np->in_addr != from)
943  continue;
944 
945  if (np->in_addr.port() != from.port())
946  continue;
947 
948  break;
949  }
950 
951  if (np == NULL) {
952  np = new CachePeer;
953  np->in_addr = from;
954  np->icp.port = from.port();
955  np->type = PEER_NONE;
956  np->host = new char[MAX_IPSTRLEN];
957  from.toStr(np->host,MAX_IPSTRLEN);
958  np->next = non_peers;
959  non_peers = np;
960  }
961 
962  ++ np->icp.counts[opcode];
963 
964  if (isPowTen(++np->stats.ignored_replies))
965  debugs(15, DBG_IMPORTANT, "WARNING: Ignored " << np->stats.ignored_replies << " replies from non-peer " << np->host);
966 }
967 
968 /* ignoreMulticastReply
969  *
970  * * We want to ignore replies from multicast peers if the
971  * * cache_host_domain rules would normally prevent the CachePeer
972  * * from being used
973  */
974 static int
976 {
977  if (p == NULL)
978  return 0;
979 
980  if (!p->options.mcast_responder)
981  return 0;
982 
983  if (peerHTTPOkay(p, ps))
984  return 0;
985 
986  return 1;
987 }
988 
996 void
997 neighborsUdpAck(const cache_key * key, icp_common_t * header, const Ip::Address &from)
998 {
999  CachePeer *p = NULL;
1000  StoreEntry *entry;
1001  MemObject *mem = NULL;
1002  peer_t ntype = PEER_NONE;
1003  icp_opcode opcode = (icp_opcode) header->opcode;
1004 
1005  debugs(15, 6, "neighborsUdpAck: opcode " << opcode << " '" << storeKeyText(key) << "'");
1006 
1007  if ((entry = Store::Root().findCallbackXXX(key)))
1008  mem = entry->mem_obj;
1009 
1010  if ((p = whichPeer(from)))
1011  neighborAlive(p, mem, header);
1012 
1013  if (opcode > ICP_END)
1014  return;
1015 
1016  const char *opcode_d = icp_opcode_str[opcode];
1017 
1018  if (p)
1019  neighborUpdateRtt(p, mem);
1020 
1021  /* Does the entry exist? */
1022  if (NULL == entry) {
1023  debugs(12, 3, "neighborsUdpAck: Cache key '" << storeKeyText(key) << "' not found");
1025  return;
1026  }
1027 
1028  /* check if someone is already fetching it */
1029  if (EBIT_TEST(entry->flags, ENTRY_DISPATCHED)) {
1030  debugs(15, 3, "neighborsUdpAck: '" << storeKeyText(key) << "' already being fetched.");
1032  return;
1033  }
1034 
1035  if (mem == NULL) {
1036  debugs(15, 2, "Ignoring " << opcode_d << " for missing mem_obj: " << storeKeyText(key));
1038  return;
1039  }
1040 
1041  if (entry->ping_status != PING_WAITING) {
1042  debugs(15, 2, "neighborsUdpAck: Late " << opcode_d << " for " << storeKeyText(key));
1044  return;
1045  }
1046 
1047  if (!entry->locked()) {
1048  // TODO: many entries are unlocked; why is this reported at level 1?
1049  debugs(12, DBG_IMPORTANT, "neighborsUdpAck: '" << storeKeyText(key) << "' has no locks");
1051  return;
1052  }
1053 
1054  if (!mem->ircb_data) {
1055  debugs(12, DBG_IMPORTANT, "BUG: missing ICP callback data for " << *entry);
1057  return;
1058  }
1059 
1060  debugs(15, 3, "neighborsUdpAck: " << opcode_d << " for '" << storeKeyText(key) << "' from " << (p ? p->host : "source") << " ");
1061 
1062  if (p) {
1063  ntype = neighborType(p, mem->request->url);
1064  }
1065 
1066  if (ignoreMulticastReply(p, mem->ircb_data)) {
1068  } else if (opcode == ICP_MISS) {
1069  if (p == NULL) {
1070  neighborIgnoreNonPeer(from, opcode);
1071  } else {
1072  mem->ping_reply_callback(p, ntype, AnyP::PROTO_ICP, header, mem->ircb_data);
1073  }
1074  } else if (opcode == ICP_HIT) {
1075  if (p == NULL) {
1076  neighborIgnoreNonPeer(from, opcode);
1077  } else {
1078  header->opcode = ICP_HIT;
1079  mem->ping_reply_callback(p, ntype, AnyP::PROTO_ICP, header, mem->ircb_data);
1080  }
1081  } else if (opcode == ICP_DECHO) {
1082  if (p == NULL) {
1083  neighborIgnoreNonPeer(from, opcode);
1084  } else if (ntype == PEER_SIBLING) {
1085  debug_trap("neighborsUdpAck: Found non-ICP cache as SIBLING\n");
1086  debug_trap("neighborsUdpAck: non-ICP neighbors must be a PARENT\n");
1087  } else {
1088  mem->ping_reply_callback(p, ntype, AnyP::PROTO_ICP, header, mem->ircb_data);
1089  }
1090  } else if (opcode == ICP_SECHO) {
1091  if (p) {
1092  debugs(15, DBG_IMPORTANT, "Ignoring SECHO from neighbor " << p->host);
1094  } else {
1095  debugs(15, DBG_IMPORTANT, "Unsolicited SECHO from " << from);
1096  }
1097  } else if (opcode == ICP_DENIED) {
1098  if (p == NULL) {
1099  neighborIgnoreNonPeer(from, opcode);
1100  } else if (p->stats.pings_acked > 100) {
1101  if (100 * p->icp.counts[ICP_DENIED] / p->stats.pings_acked > 95) {
1102  debugs(15, DBG_CRITICAL, "95%% of replies from '" << p->host << "' are UDP_DENIED");
1103  debugs(15, DBG_CRITICAL, "Disabling '" << p->host << "', please check your configuration.");
1104  neighborRemove(p);
1105  p = NULL;
1106  } else {
1108  }
1109  }
1110  } else if (opcode == ICP_MISS_NOFETCH) {
1111  mem->ping_reply_callback(p, ntype, AnyP::PROTO_ICP, header, mem->ircb_data);
1112  } else {
1113  debugs(15, DBG_CRITICAL, "neighborsUdpAck: Unexpected ICP reply: " << opcode_d);
1114  }
1115 }
1116 
1117 CachePeer *
1118 peerFindByName(const char *name)
1119 {
1120  CachePeer *p = NULL;
1121 
1122  for (p = Config.peers; p; p = p->next) {
1123  if (!strcasecmp(name, p->name))
1124  break;
1125  }
1126 
1127  return p;
1128 }
1129 
1130 CachePeer *
1131 peerFindByNameAndPort(const char *name, unsigned short port)
1132 {
1133  CachePeer *p = NULL;
1134 
1135  for (p = Config.peers; p; p = p->next) {
1136  if (strcasecmp(name, p->name))
1137  continue;
1138 
1139  if (port != p->http_port)
1140  continue;
1141 
1142  break;
1143  }
1144 
1145  return p;
1146 }
1147 
1148 int
1150 {
1151  if (!p->tcp_up) {
1152  peerProbeConnect(const_cast<CachePeer*>(p));
1153  return 0;
1154  }
1155 
1156  /*
1157  * The CachePeer can not be UP if we don't have any IP addresses
1158  * for it.
1159  */
1160  if (0 == p->n_addresses) {
1161  debugs(15, 8, "neighborUp: DOWN (no-ip): " << p->host << " (" << p->in_addr << ")");
1162  return 0;
1163  }
1164 
1165  if (p->options.no_query) {
1166  debugs(15, 8, "neighborUp: UP (no-query): " << p->host << " (" << p->in_addr << ")");
1167  return 1;
1168  }
1169 
1170  if (p->stats.probe_start != 0 &&
1172  debugs(15, 8, "neighborUp: DOWN (dead): " << p->host << " (" << p->in_addr << ")");
1173  return 0;
1174  }
1175 
1176  debugs(15, 8, "neighborUp: UP: " << p->host << " (" << p->in_addr << ")");
1177  return 1;
1178 }
1179 
1181 time_t
1183 {
1184  return peer->connect_timeout_raw > 0 ?
1186 }
1187 
1188 time_t
1189 positiveTimeout(const time_t timeout)
1190 {
1191  return max(static_cast<time_t>(1), timeout);
1192 }
1193 
1194 static void
1196 {
1197  // TODO: connections to no-longer valid IP addresses should be
1198  // closed when we can detect such IP addresses.
1199 
1200  CachePeer *p = (CachePeer *)data;
1201 
1202  if (p->n_addresses == 0) {
1203  debugs(15, DBG_IMPORTANT, "Configuring " << neighborTypeStr(p) << " " << p->host << "/" << p->http_port << "/" << p->icp.port);
1204 
1205  if (p->type == PEER_MULTICAST)
1206  debugs(15, DBG_IMPORTANT, " Multicast TTL = " << p->mcast.ttl);
1207  }
1208 
1209  p->n_addresses = 0;
1210 
1211  if (ia == NULL) {
1212  debugs(0, DBG_CRITICAL, "WARNING: DNS lookup for '" << p->host << "' failed!");
1213  return;
1214  }
1215 
1216  if (ia->empty()) {
1217  debugs(0, DBG_CRITICAL, "WARNING: No IP address found for '" << p->host << "'!");
1218  return;
1219  }
1220 
1221  for (const auto &ip: ia->goodAndBad()) { // TODO: Consider using just good().
1222  if (p->n_addresses < PEER_MAX_ADDRESSES) {
1223  const auto idx = p->n_addresses++;
1224  p->addresses[idx] = ip;
1225  debugs(15, 2, "--> IP address #" << idx << ": " << p->addresses[idx]);
1226  } else {
1227  debugs(15, 3, "ignoring remaining " << (ia->size() - p->n_addresses) << " ips");
1228  break;
1229  }
1230  }
1231 
1232  p->in_addr.setEmpty();
1233  p->in_addr = p->addresses[0];
1234  p->in_addr.port(p->icp.port);
1235 
1236  peerProbeConnect(p, true); // detect any died or revived peers ASAP
1237 
1238  if (p->type == PEER_MULTICAST)
1240 
1241 #if USE_ICMP
1242  if (p->type != PEER_MULTICAST && IamWorkerProcess())
1243  if (!p->options.no_netdb_exchange)
1244  eventAddIsh("netdbExchangeStart", netdbExchangeStart, p, 30.0, 1);
1245 #endif
1246 
1247  if (p->standby.mgr.valid())
1248  PeerPoolMgr::Checkpoint(p->standby.mgr, "resolved peer");
1249 }
1250 
1251 static void
1253 {
1254  CachePeer *p = NULL;
1255 
1258 
1259  if (!data && 0 == stat5minClientRequests()) {
1260  /* no recent client traffic, wait a bit */
1261  eventAddIsh("peerRefreshDNS", peerRefreshDNS, NULL, 180.0, 1);
1262  return;
1263  }
1264 
1265  for (p = Config.peers; p; p = p->next)
1267 
1268  /* Reconfigure the peers every hour */
1269  eventAddIsh("peerRefreshDNS", peerRefreshDNS, NULL, 3600.0, 1);
1270 }
1271 
1272 static void
1274 {
1276 
1277  if (!p->tcp_up) {
1278  debugs(15, 2, "TCP connection to " << p->host << "/" << p->http_port <<
1279  " dead");
1280  return;
1281  }
1282 
1283  -- p->tcp_up;
1284 
1285  if (!p->tcp_up) {
1286  debugs(15, DBG_IMPORTANT, "Detected DEAD " << neighborTypeStr(p) << ": " << p->name);
1288  }
1289 }
1290 
1291 void
1293 {
1294  debugs(15, DBG_IMPORTANT, "TCP connection to " << p->host << "/" << p->http_port << " failed");
1296 }
1297 
1298 void
1300 {
1301  if (!p->tcp_up) {
1302  debugs(15, 2, "TCP connection to " << p->host << "/" << p->http_port << " succeeded");
1303  p->tcp_up = p->connect_fail_limit; // NP: so peerAlive(p) works properly.
1304  peerAlive(p);
1305  if (!p->n_addresses)
1307  } else
1308  p->tcp_up = p->connect_fail_limit;
1309 }
1310 
1312 static bool
1314 {
1315  if (p->testing_now > 0) {
1316  debugs(15, 8, "yes, probing " << p);
1317  return true;
1318  }
1319  if (squid_curtime - p->stats.last_connect_probe == 0) {
1320  debugs(15, 8, "yes, just probed " << p);
1321  return true;
1322  }
1323  return false;
1324 }
1325 /*
1326 * peerProbeConnect will be called on dead peers by neighborUp
1327 */
1328 static void
1329 peerProbeConnect(CachePeer *p, const bool reprobeIfBusy)
1330 {
1331  if (peerProbeIsBusy(p)) {
1332  p->reprobe = reprobeIfBusy;
1333  return;
1334  }
1335  p->reprobe = false;
1336 
1337  const time_t ctimeout = peerConnectTimeout(p);
1338  /* for each IP address of this CachePeer. find one that we can connect to and probe it. */
1339  for (int i = 0; i < p->n_addresses; ++i) {
1341  conn->remote = p->addresses[i];
1342  conn->remote.port(p->http_port);
1343  conn->setPeer(p);
1344  getOutgoingAddress(NULL, conn);
1345 
1346  ++ p->testing_now;
1347 
1348  AsyncCall::Pointer call = commCbCall(15,3, "peerProbeConnectDone", CommConnectCbPtrFun(peerProbeConnectDone, p));
1349  Comm::ConnOpener *cs = new Comm::ConnOpener(conn, call, ctimeout);
1350  cs->setHost(p->host);
1351  AsyncJob::Start(cs);
1352  }
1353 
1355 }
1356 
1357 static void
1359 {
1360  CachePeer *p = (CachePeer*)data;
1361 
1362  if (status == Comm::OK) {
1364  } else {
1366  }
1367 
1368  -- p->testing_now;
1369  conn->close();
1370  // TODO: log this traffic.
1371 
1372  if (p->reprobe)
1373  peerProbeConnect(p);
1374 }
1375 
1376 static void
1378 {
1379  if (p->mcast.flags.count_event_pending)
1380  return;
1381 
1382  eventAdd("peerCountMcastPeersStart",
1384  p,
1385  (double) when, 1);
1386 
1387  p->mcast.flags.count_event_pending = true;
1388 }
1389 
1390 static void
1392 {
1393  // XXX: Do not create lots of complex fake objects (while abusing their
1394  // APIs) to pass around a few basic data points like start_ping and ping!
1395  CachePeer *p = (CachePeer *)data;
1396  MemObject *mem;
1397  int reqnum;
1398  // TODO: use class AnyP::Uri instead of constructing and re-parsing a string
1399  LOCAL_ARRAY(char, url, MAX_URL);
1400  assert(p->type == PEER_MULTICAST);
1401  p->mcast.flags.count_event_pending = false;
1402  snprintf(url, MAX_URL, "http://");
1403  p->in_addr.toUrl(url+7, MAX_URL -8 );
1404  strcat(url, "/");
1406  HttpRequest *req = HttpRequest::FromUrl(url, mx);
1407  assert(req != nullptr);
1409  const auto psstate = new PeerSelector(nullptr);
1410  psstate->request = req;
1411  HTTPMSGLOCK(psstate->request);
1412  psstate->entry = fake;
1413  psstate->peerCountMcastPeerXXX = cbdataReference(p);
1414  psstate->ping.start = current_time;
1415  mem = fake->mem_obj;
1416  mem->request = psstate->request;
1417  mem->start_ping = current_time;
1419  mem->ircb_data = psstate;
1421  p->mcast.id = mem->id;
1422  reqnum = icpSetCacheKey((const cache_key *)fake->key);
1423  icpCreateAndSend(ICP_QUERY, 0, url, reqnum, 0,
1424  icpOutgoingConn->fd, p->in_addr, psstate->al);
1425  fake->ping_status = PING_WAITING;
1426  eventAdd("peerCountMcastPeersDone",
1428  psstate,
1429  Config.Timeout.mcast_icp_query / 1000.0, 1);
1430  p->mcast.flags.counting = true;
1432 }
1433 
1434 static void
1436 {
1437  const auto psstate = static_cast<PeerSelector*>(data);
1438  StoreEntry *fake = psstate->entry;
1439 
1440  if (cbdataReferenceValid(psstate->peerCountMcastPeerXXX)) {
1441  CachePeer *p = (CachePeer *)psstate->peerCountMcastPeerXXX;
1442  p->mcast.flags.counting = false;
1443  p->mcast.avg_n_members = Math::doubleAverage(p->mcast.avg_n_members, (double) psstate->ping.n_recv, ++p->mcast.n_times_counted, 10);
1444  debugs(15, DBG_IMPORTANT, "Group " << p->host << ": " << psstate->ping.n_recv <<
1445  " replies, "<< std::setw(4)<< std::setprecision(2) <<
1446  p->mcast.avg_n_members <<" average, RTT " << p->stats.rtt);
1448  }
1449 
1450  cbdataReferenceDone(psstate->peerCountMcastPeerXXX);
1451 
1452  fake->abort(); // sets ENTRY_ABORTED and initiates releated cleanup
1453  fake->mem_obj->request = nullptr;
1454  fake->unlock("peerCountMcastPeersDone");
1455  delete psstate;
1456 }
1457 
1458 static void
1460 {
1461  const auto psstate = static_cast<PeerSelector*>(data);
1462  StoreEntry *fake = psstate->entry;
1463  assert(fake);
1464  MemObject *mem = fake->mem_obj;
1465  assert(mem);
1466  int rtt = tvSubMsec(mem->start_ping, current_time);
1467  assert(proto == AnyP::PROTO_ICP);
1468  ++ psstate->ping.n_recv;
1469  int rtt_av_factor = RTT_AV_FACTOR;
1470 
1472  rtt_av_factor = RTT_BACKGROUND_AV_FACTOR;
1473 
1474  p->stats.rtt = Math::intAverage(p->stats.rtt, rtt, psstate->ping.n_recv, rtt_av_factor);
1475 }
1476 
1477 static void
1479 {
1480  dump_peers(sentry, Config.peers);
1481 }
1482 
1483 static void
1485 {
1486  dump_peers(sentry, non_peers);
1487 }
1488 
1489 void
1491 {
1492  if (p->options.proxy_only)
1493  storeAppendPrintf(sentry, " proxy-only");
1494 
1495  if (p->options.no_query)
1496  storeAppendPrintf(sentry, " no-query");
1497 
1498  if (p->options.background_ping)
1499  storeAppendPrintf(sentry, " background-ping");
1500 
1501  if (p->options.no_digest)
1502  storeAppendPrintf(sentry, " no-digest");
1503 
1504  if (p->options.default_parent)
1505  storeAppendPrintf(sentry, " default");
1506 
1507  if (p->options.roundrobin)
1508  storeAppendPrintf(sentry, " round-robin");
1509 
1510  if (p->options.carp)
1511  storeAppendPrintf(sentry, " carp");
1512 
1513 #if USE_AUTH
1514  if (p->options.userhash)
1515  storeAppendPrintf(sentry, " userhash");
1516 #endif
1517 
1518  if (p->options.sourcehash)
1519  storeAppendPrintf(sentry, " sourcehash");
1520 
1522  storeAppendPrintf(sentry, " weighted-round-robin");
1523 
1524  if (p->options.mcast_responder)
1525  storeAppendPrintf(sentry, " multicast-responder");
1526 
1527 #if PEER_MULTICAST_SIBLINGS
1528  if (p->options.mcast_siblings)
1529  storeAppendPrintf(sentry, " multicast-siblings");
1530 #endif
1531 
1532  if (p->weight != 1)
1533  storeAppendPrintf(sentry, " weight=%d", p->weight);
1534 
1535  if (p->options.closest_only)
1536  storeAppendPrintf(sentry, " closest-only");
1537 
1538 #if USE_HTCP
1539  if (p->options.htcp) {
1540  storeAppendPrintf(sentry, " htcp");
1542  bool doneopts = false;
1543  if (p->options.htcp_oldsquid) {
1544  storeAppendPrintf(sentry, "oldsquid");
1545  doneopts = true;
1546  }
1547  if (p->options.htcp_no_clr) {
1548  storeAppendPrintf(sentry, "%sno-clr",(doneopts?",":"="));
1549  doneopts = true;
1550  }
1551  if (p->options.htcp_no_purge_clr) {
1552  storeAppendPrintf(sentry, "%sno-purge-clr",(doneopts?",":"="));
1553  doneopts = true;
1554  }
1555  if (p->options.htcp_only_clr) {
1556  storeAppendPrintf(sentry, "%sonly-clr",(doneopts?",":"="));
1557  //doneopts = true; // uncomment if more opts are added
1558  }
1559  }
1560  }
1561 #endif
1562 
1563  if (p->options.no_netdb_exchange)
1564  storeAppendPrintf(sentry, " no-netdb-exchange");
1565 
1566 #if USE_DELAY_POOLS
1567  if (p->options.no_delay)
1568  storeAppendPrintf(sentry, " no-delay");
1569 #endif
1570 
1571  if (p->login)
1572  storeAppendPrintf(sentry, " login=%s", p->login);
1573 
1574  if (p->mcast.ttl > 0)
1575  storeAppendPrintf(sentry, " ttl=%d", p->mcast.ttl);
1576 
1577  if (p->connect_timeout_raw > 0)
1578  storeAppendPrintf(sentry, " connect-timeout=%d", (int)p->connect_timeout_raw);
1579 
1581  storeAppendPrintf(sentry, " connect-fail-limit=%d", p->connect_fail_limit);
1582 
1583 #if USE_CACHE_DIGESTS
1584 
1585  if (p->digest_url)
1586  storeAppendPrintf(sentry, " digest-url=%s", p->digest_url);
1587 
1588 #endif
1589 
1590  if (p->options.allow_miss)
1591  storeAppendPrintf(sentry, " allow-miss");
1592 
1593  if (p->options.no_tproxy)
1594  storeAppendPrintf(sentry, " no-tproxy");
1595 
1596  if (p->max_conn > 0)
1597  storeAppendPrintf(sentry, " max-conn=%d", p->max_conn);
1598  if (p->standby.limit > 0)
1599  storeAppendPrintf(sentry, " standby=%d", p->standby.limit);
1600 
1601  if (p->options.originserver)
1602  storeAppendPrintf(sentry, " originserver");
1603 
1604  if (p->domain)
1605  storeAppendPrintf(sentry, " forceddomain=%s", p->domain);
1606 
1607  if (p->connection_auth == 0)
1608  storeAppendPrintf(sentry, " connection-auth=off");
1609  else if (p->connection_auth == 1)
1610  storeAppendPrintf(sentry, " connection-auth=on");
1611  else if (p->connection_auth == 2)
1612  storeAppendPrintf(sentry, " connection-auth=auto");
1613 
1614  p->secure.dumpCfg(sentry,"tls-");
1615  storeAppendPrintf(sentry, "\n");
1616 }
1617 
1618 static void
1619 dump_peers(StoreEntry * sentry, CachePeer * peers)
1620 {
1621  char ntoabuf[MAX_IPSTRLEN];
1622  int i;
1623 
1624  if (peers == NULL)
1625  storeAppendPrintf(sentry, "There are no neighbors installed.\n");
1626 
1627  for (CachePeer *e = peers; e; e = e->next) {
1628  assert(e->host != NULL);
1629  storeAppendPrintf(sentry, "\n%-11.11s: %s\n",
1630  neighborTypeStr(e),
1631  e->name);
1632  storeAppendPrintf(sentry, "Host : %s/%d/%d\n",
1633  e->host,
1634  e->http_port,
1635  e->icp.port);
1636  storeAppendPrintf(sentry, "Flags :");
1637  dump_peer_options(sentry, e);
1638 
1639  for (i = 0; i < e->n_addresses; ++i) {
1640  storeAppendPrintf(sentry, "Address[%d] : %s\n", i,
1641  e->addresses[i].toStr(ntoabuf,MAX_IPSTRLEN) );
1642  }
1643 
1644  storeAppendPrintf(sentry, "Status : %s\n",
1645  neighborUp(e) ? "Up" : "Down");
1646  storeAppendPrintf(sentry, "FETCHES : %d\n", e->stats.fetches);
1647  storeAppendPrintf(sentry, "OPEN CONNS : %d\n", e->stats.conn_open);
1648  storeAppendPrintf(sentry, "AVG RTT : %d msec\n", e->stats.rtt);
1649 
1650  if (!e->options.no_query) {
1651  storeAppendPrintf(sentry, "LAST QUERY : %8d seconds ago\n",
1652  (int) (squid_curtime - e->stats.last_query));
1653 
1654  if (e->stats.last_reply > 0)
1655  storeAppendPrintf(sentry, "LAST REPLY : %8d seconds ago\n",
1656  (int) (squid_curtime - e->stats.last_reply));
1657  else
1658  storeAppendPrintf(sentry, "LAST REPLY : none received\n");
1659 
1660  storeAppendPrintf(sentry, "PINGS SENT : %8d\n", e->stats.pings_sent);
1661 
1662  storeAppendPrintf(sentry, "PINGS ACKED: %8d %3d%%\n",
1663  e->stats.pings_acked,
1664  Math::intPercent(e->stats.pings_acked, e->stats.pings_sent));
1665  }
1666 
1667  storeAppendPrintf(sentry, "IGNORED : %8d %3d%%\n", e->stats.ignored_replies, Math::intPercent(e->stats.ignored_replies, e->stats.pings_acked));
1668 
1669  if (!e->options.no_query) {
1670  storeAppendPrintf(sentry, "Histogram of PINGS ACKED:\n");
1671 #if USE_HTCP
1672 
1673  if (e->options.htcp) {
1674  storeAppendPrintf(sentry, "\tMisses\t%8d %3d%%\n",
1675  e->htcp.counts[0],
1676  Math::intPercent(e->htcp.counts[0], e->stats.pings_acked));
1677  storeAppendPrintf(sentry, "\tHits\t%8d %3d%%\n",
1678  e->htcp.counts[1],
1679  Math::intPercent(e->htcp.counts[1], e->stats.pings_acked));
1680  } else {
1681 #endif
1682 
1683  for (auto op : WholeEnum<icp_opcode>()) {
1684  if (e->icp.counts[op] == 0)
1685  continue;
1686 
1687  storeAppendPrintf(sentry, " %12.12s : %8d %3d%%\n",
1688  icp_opcode_str[op],
1689  e->icp.counts[op],
1690  Math::intPercent(e->icp.counts[op], e->stats.pings_acked));
1691  }
1692 
1693 #if USE_HTCP
1694 
1695  }
1696 
1697 #endif
1698 
1699  }
1700 
1701  if (e->stats.last_connect_failure) {
1702  storeAppendPrintf(sentry, "Last failed connect() at: %s\n",
1703  Time::FormatHttpd(e->stats.last_connect_failure));
1704  }
1705 
1706  storeAppendPrintf(sentry, "keep-alive ratio: %d%%\n", Math::intPercent(e->stats.n_keepalives_recv, e->stats.n_keepalives_sent));
1707  }
1708 }
1709 
1710 #if USE_HTCP
1711 void
1712 neighborsHtcpReply(const cache_key * key, HtcpReplyData * htcp, const Ip::Address &from)
1713 {
1715  MemObject *mem = NULL;
1716  CachePeer *p;
1717  peer_t ntype = PEER_NONE;
1718  debugs(15, 6, "neighborsHtcpReply: " <<
1719  (htcp->hit ? "HIT" : "MISS") << " " <<
1720  storeKeyText(key) );
1721 
1722  if (NULL != e)
1723  mem = e->mem_obj;
1724 
1725  if ((p = whichPeer(from)))
1726  neighborAliveHtcp(p, mem, htcp);
1727 
1728  /* Does the entry exist? */
1729  if (NULL == e) {
1730  debugs(12, 3, "neighyborsHtcpReply: Cache key '" << storeKeyText(key) << "' not found");
1732  return;
1733  }
1734 
1735  /* check if someone is already fetching it */
1736  if (EBIT_TEST(e->flags, ENTRY_DISPATCHED)) {
1737  debugs(15, 3, "neighborsUdpAck: '" << storeKeyText(key) << "' already being fetched.");
1739  return;
1740  }
1741 
1742  if (mem == NULL) {
1743  debugs(15, 2, "Ignoring reply for missing mem_obj: " << storeKeyText(key));
1745  return;
1746  }
1747 
1748  if (e->ping_status != PING_WAITING) {
1749  debugs(15, 2, "neighborsUdpAck: Entry " << storeKeyText(key) << " is not PING_WAITING");
1751  return;
1752  }
1753 
1754  if (!e->locked()) {
1755  // TODO: many entries are unlocked; why is this reported at level 1?
1756  debugs(12, DBG_IMPORTANT, "neighborsUdpAck: '" << storeKeyText(key) << "' has no locks");
1758  return;
1759  }
1760 
1761  if (!mem->ircb_data) {
1762  debugs(12, DBG_IMPORTANT, "BUG: missing HTCP callback data for " << *e);
1764  return;
1765  }
1766 
1767  if (p) {
1768  ntype = neighborType(p, mem->request->url);
1769  neighborUpdateRtt(p, mem);
1770  }
1771 
1772  if (ignoreMulticastReply(p, mem->ircb_data)) {
1774  return;
1775  }
1776 
1777  debugs(15, 3, "neighborsHtcpReply: e = " << e);
1778  mem->ping_reply_callback(p, ntype, AnyP::PROTO_HTCP, htcp, mem->ircb_data);
1779 }
1780 
1781 /*
1782  * Send HTCP CLR messages to all peers configured to receive them.
1783  */
1784 void
1786 {
1787  CachePeer *p;
1788  char buf[128];
1789 
1790  for (p = Config.peers; p; p = p->next) {
1791  if (!p->options.htcp) {
1792  continue;
1793  }
1794  if (p->options.htcp_no_clr) {
1795  continue;
1796  }
1797  if (p->options.htcp_no_purge_clr && reason == HTCP_CLR_PURGE) {
1798  continue;
1799  }
1800  debugs(15, 3, "neighborsHtcpClear: sending CLR to " << p->in_addr.toUrl(buf, 128));
1801  htcpClear(e, uri, req, method, p, reason);
1802  }
1803 }
1804 
1805 #endif
1806 
int n_addresses
Definition: CachePeer.h:152
bool background_ping
Definition: CachePeer.h:85
void getOutgoingAddress(HttpRequest *request, Comm::ConnectionPointer conn)
Definition: FwdState.cc:1295
HierarchyLogEntry hier
Definition: HttpRequest.h:149
bool mcast_responder
Definition: CachePeer.h:90
PeerDigest * digest
Definition: CachePeer.h:143
struct CachePeer::icp_ icp
unsigned short port
Definition: CachePeer.h:67
int intAverage(const int, const int, int, const int)
Definition: SquidMath.cc:40
char * login
Definition: CachePeer.h:175
static IPH peerDNSConfigure
Definition: neighbors.cc:60
static int peerWouldBePinged(const CachePeer *, PeerSelector *)
Definition: neighbors.cc:177
CachePeer * getWeightedRoundRobinParent(PeerSelector *ps)
Definition: neighbors.cc:349
HttpRequest * request
#define assert(EX)
Definition: assert.h:17
bool mcast_siblings
Definition: CachePeer.h:121
time_t deadPeer
Definition: SquidConfig.h:118
static void neighborRemove(CachePeer *)
Definition: neighbors.cc:506
bool htcp_no_clr
Definition: CachePeer.h:95
void const char HLPCB * callback
Definition: stub_helper.cc:16
int matchDomainName(const char *h, const char *d, uint flags)
Definition: Uri.cc:660
int Squid_MaxFD
#define PEER_TCP_MAGIC_COUNT
Definition: defines.h:192
bool hierarchical
Definition: RequestFlags.h:34
bool waitingForClose
a conn must close before we open a standby conn
Definition: CachePeer.h:185
#define cbdataReferenceDone(var)
Definition: cbdata.h:350
Comm::ConnectionPointer icpIncomingConn
Definition: icp_v2.cc:102
htcp_clr_reason
Definition: enums.h:233
int unlock(const char *context)
Definition: store.cc:457
CachePeer * next
Definition: CachePeer.h:154
static void peerProbeConnect(CachePeer *, const bool reprobeIfBusy=false)
Definition: neighbors.cc:1329
bool loopDetected
Definition: RequestFlags.h:36
void netdbExchangeStart(void *data)
Definition: net_db.cc:1270
char * domain
Forced domain.
Definition: CachePeer.h:188
int mcastSetTtl(int fd, int mcast_ttl)
Definition: multicast.cc:20
unsigned char cache_key
Store key.
Definition: forward.h:29
static void peerCountMcastPeersStart(void *data)
Definition: neighbors.cc:1391
static void neighborCountIgnored(CachePeer *)
Definition: neighbors.cc:924
HttpRequestMethod method
Definition: HttpRequest.h:106
time_t peerConnectTimeout(const CachePeer *peer)
Definition: neighbors.cc:1182
void setHost(const char *)
set the hostname note for this connection
Definition: ConnOpener.cc:89
CachePeer * peers
Definition: SquidConfig.h:247
struct _request * request(char *urlin)
Definition: tcp-banger2.c:291
int i
Definition: membanger.c:49
CachePeer * getDefaultParent(PeerSelector *ps)
Definition: neighbors.cc:467
struct CachePeer::@30 htcp
unsigned char version
Definition: ICP.h:40
#define MCAST_COUNT_RATE
Definition: neighbors.cc:49
struct CachePeer::@29 stats
bool htcp_oldsquid
Definition: CachePeer.h:94
const char * storeKeyText(const cache_key *key)
Definition: Flag.h:16
AccessLogEntry::Pointer al
info for the future access.log, and external ACL
bool hasDisk(const sdirno dirn=-1, const sfileno filen=-1) const
Definition: store.cc:1997
CachePeer * peerFindByNameAndPort(const char *name, unsigned short port)
Definition: neighbors.cc:1131
encapsulates DNS lookup results
Definition: LookupDetails.h:20
void HTTPMSGLOCK(Http::Message *a)
Definition: Message.h:157
static CachePeer * non_peers
Definition: neighbors.cc:934
int hit
Definition: htcp.h:29
char * name
Definition: CachePeer.h:40
time_t last_connect_probe
Definition: CachePeer.h:58
time_t probe_start
Definition: CachePeer.h:54
int netdbHostRtt(const char *host)
Definition: net_db.cc:1052
void eventAddIsh(const char *name, EVH *func, void *arg, double delta_ish, int weight)
Definition: event.cc:116
int pings_sent
Definition: CachePeer.h:47
virtual void dumpCfg(Packable *, const char *pfx) const
output squid.conf syntax with 'pfx' prefix on parameters for the stored settings
Definition: PeerOptions.cc:102
#define PEER_DEAD
Definition: defines.h:125
void peerDigestNeeded(PeerDigest *pd)
Definition: peer_digest.cc:177
#define DBG_CRITICAL
Definition: Debug.h:45
static void Checkpoint(const Pointer &mgr, const char *reason)
Definition: PeerPoolMgr.cc:261
char * p
Definition: membanger.c:43
void OBJH(StoreEntry *)
Definition: forward.h:44
int conn
the current server connection FD
Definition: Transport.cc:26
representation of a neighbor_type_domain configuration directive. A POD
static void peerCountMcastPeersSchedule(CachePeer *p, time_t when)
Definition: neighbors.cc:1377
AnyP::PortCfgPointer HttpPortList
list of Squid http(s)_port configured
Definition: PortCfg.cc:21
CacheDigest * cd
Definition: PeerDigest.h:83
Controller & Root()
safely access controller singleton
Definition: Controller.cc:877
int neighborsUdpPing(HttpRequest *request, StoreEntry *entry, IRCB *callback, PeerSelector *ps, int *exprep, int *timeout)
Definition: neighbors.cc:589
struct timeval start_ping
Definition: MemObject.h:157
const char * getMyHostname(void)
Definition: tools.cc:412
struct timeval current_time
Definition: stub_time.cc:15
A const & max(A const &lhs, A const &rhs)
struct PeerDigest::@90 flags
void count(int uses)
CachePeer * getRoundRobinParent(PeerSelector *ps)
Definition: neighbors.cc:307
size_t size() const noexcept
all cached IPs
Definition: ipcache.h:62
bool IamWorkerProcess()
whether the current process handles HTTP transactions and such
Definition: stub_tools.cc:49
time_t squid_curtime
Definition: stub_time.cc:17
#define RTT_BACKGROUND_AV_FACTOR
Definition: defines.h:123
int icpSetCacheKey(const cache_key *key)
Definition: icp_v2.cc:873
bool peerAllowedToUse(const CachePeer *, PeerSelector *)
Definition: neighbors.cc:136
void neighborsUdpAck(const cache_key *key, icp_common_t *header, const Ip::Address &from)
Definition: neighbors.cc:997
int mcast_icp_query
Definition: SquidConfig.h:123
void peerClearRR()
Definition: neighbors.cc:440
CbcPointer< PeerPoolMgr > mgr
pool manager
Definition: CachePeer.h:183
int conn_open
current opened connections
Definition: CachePeer.h:60
static void peerConnectFailedSilent(CachePeer *p)
Definition: neighbors.cc:1273
int ignored_replies
Definition: CachePeer.h:51
#define ICP_VERSION_2
Definition: defines.h:76
unsigned short htcp
Definition: SquidConfig.h:138
int rr_count
Definition: CachePeer.h:153
NeighborTypeDomainList * typelist
Definition: CachePeer.h:79
void peerConnectSucceded(CachePeer *p)
Definition: neighbors.cc:1299
static Pointer Start(AsyncJob *job)
starts a freshly created job (i.e., makes the job asynchronous)
Definition: AsyncJob.cc:23
int locked() const
Definition: store.cc:1249
struct CachePeer::@36 standby
optional "cache_peer standby=limit" feature
int tvSubMsec(struct timeval, struct timeval)
Definition: stub_time.cc:20
bool sourcehash
Definition: CachePeer.h:117
bool IsConnOpen(const Comm::ConnectionPointer &conn)
Definition: Connection.cc:24
#define RTT_AV_FACTOR
Definition: defines.h:122
ping_status_t ping_status
Definition: Store.h:218
void const char HLPCB void * data
Definition: stub_helper.cc:16
void peerConnClosed(CachePeer *p)
Notifies peer of an associated connection closure.
Definition: neighbors.cc:241
bool htcp_no_purge_clr
Definition: CachePeer.h:96
struct servent * getservbyname()
time_t last_query
Definition: CachePeer.h:55
static CNCB peerProbeConnectDone
Definition: neighbors.cc:62
static OBJH neighborDumpPeers
Definition: neighbors.cc:69
bool weighted_roundrobin
Definition: CachePeer.h:89
void peerConnectFailed(CachePeer *p)
Definition: neighbors.cc:1292
CachePeer * getFirstUpParent(PeerSelector *ps)
Definition: neighbors.cc:282
void port(unsigned short p)
Definition: Uri.h:83
peer_t neighborType(const CachePeer *p, const AnyP::Uri &url)
Definition: neighbors.cc:113
acl_access * access
Definition: CachePeer.h:80
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Debug.h:124
#define cbdataReference(var)
Definition: cbdata.h:341
int eventFind(EVH *func, void *arg)
Definition: event.cc:155
StoreEntry * storeCreateEntry(const char *url, const char *logUrl, const RequestFlags &flags, const HttpRequestMethod &method)
Definition: store.cc:776
bool default_parent
Definition: CachePeer.h:87
#define DBG_IMPORTANT
Definition: Debug.h:46
double avg_n_members
Definition: CachePeer.h:130
void RegisterAction(char const *action, char const *desc, OBJH *handler, int pw_req_flag, int atomic)
Definition: Registration.cc:16
void abort()
Definition: store.cc:1107
struct SquidConfig::@99 Port
bool needed
Definition: PeerDigest.h:88
double doubleAverage(const double, const double, int, const int)
Definition: SquidMath.cc:31
static OBJH neighborDumpNonPeers
Definition: neighbors.cc:70
int max_conn
Definition: CachePeer.h:178
bool peerCanOpenMore(const CachePeer *p)
Whether we can open new connections to the peer (e.g., despite max-conn)
Definition: neighbors.cc:217
int icp_query_min
Definition: SquidConfig.h:122
CachePeer * getNextPeer(CachePeer *p)
Definition: neighbors.cc:494
unsigned char opcode
Definition: ICP.h:38
PconnPool * pool
idle connection pool for this peer
Definition: CachePeer.h:182
static void neighborIgnoreNonPeer(const Ip::Address &, icp_opcode)
Definition: neighbors.cc:937
Cbc * valid() const
was set and is valid
Definition: CbcPointer.h:41
Security::PeerOptions secure
security settings for peer connection
Definition: CachePeer.h:191
int counts[2]
Definition: CachePeer.h:73
static void peerRefreshDNS(void *)
Definition: neighbors.cc:1252
int pings_acked
Definition: CachePeer.h:48
unsigned short icp
Definition: SquidConfig.h:135
char * toUrl(char *buf, unsigned int len) const
Definition: Address.cc:877
double version
Definition: htcp.h:32
AnyP::Uri url
the request URI
Definition: HttpRequest.h:107
Ip::Address in_addr
Definition: CachePeer.h:44
PeerSelector * ircb_data
Definition: MemObject.h:159
bool allowed() const
Definition: Acl.h:141
int n_replies_expected
Definition: CachePeer.h:132
bool allow_miss
Definition: CachePeer.h:104
peer_t type
Definition: CachePeer.h:42
uint16_t flags
Definition: Store.h:208
icp_opcode
Definition: icp_opcode.h:13
static void peerCountMcastPeersDone(void *data)
Definition: neighbors.cc:1435
Comm::ConnectionPointer icpOutgoingConn
Definition: icp_v2.cc:104
bool no_digest
Definition: CachePeer.h:86
bool usable
Definition: PeerDigest.h:89
bool userhash
Definition: CachePeer.h:115
void ipcache_nbgethostbyname(const char *name, IPH *handler, void *handlerData)
Definition: ipcache.cc:600
NeighborTypeDomainList * next
void setEmpty()
Fast reset of the stored content to what would be after default constructor.
Definition: Address.cc:177
void host(const char *src)
Definition: Uri.cc:47
const char * neighborTypeStr(const CachePeer *p)
Definition: neighbors.cc:79
static int port
Definition: ldap_backend.cc:69
MemObject * mem_obj
Definition: Store.h:197
#define LOCAL_ARRAY(type, name, size)
Definition: leakcheck.h:18
int connection_auth
0 - off, 1 - on, 2 - auto
Definition: CachePeer.h:196
const char * lookup_t_str[]
const char * url() const
Definition: store.cc:1600
static HttpRequest * FromUrl(const char *url, const MasterXaction::Pointer &, const HttpRequestMethod &method=Http::METHOD_GET)
Definition: HttpRequest.cc:523
void IRCB(CachePeer *, peer_t, AnyP::ProtocolType, void *, void *data)
Definition: typedefs.h:22
void const char * buf
Definition: stub_helper.cc:16
bool htcp_only_clr
Definition: CachePeer.h:97
struct CachePeer::@32::@38 flags
std::ostream & HERE(std::ostream &s)
Definition: Debug.h:153
void icpCreateAndSend(icp_opcode, int flags, char const *url, int reqnum, int pad, int fd, const Ip::Address &from, AccessLogEntryPointer)
Definition: icp_v2.cc:442
struct SquidConfig::@112 onoff
void eventDelete(EVH *func, void *arg)
Definition: event.cc:131
unsigned short port() const
Definition: Address.cc:771
CachePeer * whichPeer(const Ip::Address &from)
Definition: neighbors.cc:94
int icp_query_max
Definition: SquidConfig.h:121
static void neighborsRegisterWithCacheManager()
Definition: neighbors.cc:533
Flag
Definition: Flag.h:15
time_t positiveTimeout(const time_t timeout)
Definition: neighbors.cc:1189
int htcpQuery(StoreEntry *e, HttpRequest *req, CachePeer *p)
Definition: htcp.cc:1479
Ip::Address addresses[10]
Definition: CachePeer.h:151
static IRCB peerCountHandleIcpReply
Definition: neighbors.cc:66
int tcp_up
Definition: CachePeer.h:147
bool SIGHDLR int STUB void int
Definition: stub_tools.cc:68
time_t last_reply
Definition: CachePeer.h:56
int isPowTen(int count)
Definition: int.cc:16
bool no_query
Definition: CachePeer.h:84
void eventAdd(const char *name, EVH *func, void *arg, double when, int weight, bool cbdata)
Definition: event.cc:109
static unsigned short echo_port
Definition: neighbors.cc:73
void dump_peer_options(StoreEntry *sentry, CachePeer *p)
Definition: neighbors.cc:1490
const char * getMD5Text() const
Definition: store.cc:184
RequestFlags flags
Definition: HttpRequest.h:133
char cd_host[SQUIDHOSTNAMELEN]
StoreEntry * findCallbackXXX(const cache_key *)
Definition: Controller.cc:362
char * digest_url
Definition: CachePeer.h:144
void neighborsHtcpClear(StoreEntry *e, const char *uri, HttpRequest *req, const HttpRequestMethod &method, htcp_clr_reason reason)
Definition: neighbors.cc:1785
int counts[ICP_END+1]
Definition: CachePeer.h:66
bool reprobe
whether to do another TCP probe after current TCP probes
Definition: CachePeer.h:149
AccessLogEntry::Pointer al
info for the future access.log entry
void setPeer(CachePeer *p)
Definition: Connection.cc:107
time_t connect_timeout_raw
connect_timeout; use peerConnectTimeout() instead!
Definition: CachePeer.h:176
static bool peerProbeIsBusy(const CachePeer *p)
whether new TCP probes are currently banned
Definition: neighbors.cc:1313
bool peerHasConnAvailable(const CachePeer *p)
Whether the peer has idle or standby connections that can be used now.
Definition: neighbors.cc:226
Ip::Address remote
Definition: Connection.h:138
allow_t const & fastCheck()
Definition: Checklist.cc:336
int n_times_counted
Definition: CachePeer.h:131
Definition: Uri.h:30
static void neighborUpdateRtt(CachePeer *p, MemObject *mem)
Definition: neighbors.cc:888
void neighborsHtcpReply(const cache_key *key, HtcpReplyData *htcp, const Ip::Address &from)
Definition: neighbors.cc:1712
#define PEER_ALIVE
Definition: defines.h:126
bool no_delay
Definition: CachePeer.h:102
void htcpClear(StoreEntry *e, const char *uri, HttpRequest *req, const HttpRequestMethod &, CachePeer *p, htcp_clr_reason reason)
Definition: htcp.cc:1528
static void peerClearRRLoop(void *data)
Definition: neighbors.cc:411
static void dump_peers(StoreEntry *sentry, CachePeer *peers)
Definition: neighbors.cc:1619
static int NLateReplies
Definition: neighbors.cc:75
bool requested
Definition: PeerDigest.h:90
int peerHTTPOkay(const CachePeer *p, PeerSelector *ps)
Definition: neighbors.cc:252
const char * FormatHttpd(time_t t)
Definition: stub_time.cc:25
int limit
the limit itself
Definition: CachePeer.h:184
int intPercent(const int a, const int b)
Definition: SquidMath.cc:13
bool contains(const cache_key *key) const
Definition: CacheDigest.cc:93
CachePeer * neighborsDigestSelect(PeerSelector *ps)
Definition: neighbors.cc:797
size_t HttpReply *STUB StoreEntry const KeyScope scope const HttpRequestMethod & method
Definition: stub_store.cc:122
lookup_t peerDigestLookup(CachePeer *p, PeerSelector *ps)
Definition: neighbors.cc:753
int weight
Definition: CachePeer.h:126
peer_t
Definition: enums.h:27
ProtocolType
Definition: ProtocolType.h:22
void CNCB(const Comm::ConnectionPointer &conn, Comm::Flag status, int xerrno, void *data)
Definition: CommCalls.h:35
struct CachePeer::@31 options
double version
Definition: CachePeer.h:72
struct SquidConfig::@98 Timeout
unsigned short http_port
Definition: CachePeer.h:78
bool closest_only
Definition: CachePeer.h:91
#define ICP_FLAG_SRC_RTT
Definition: defines.h:73
CommCbFunPtrCallT< Dialer > * commCbCall(int debugSection, int debugLevel, const char *callName, const Dialer &dialer)
Definition: CommCalls.h:342
int cbdataReferenceValid(const void *p)
Definition: cbdata.cc:412
void IPH(const ipcache_addrs *, const Dns::LookupDetails &details, void *)
Definition: ipcache.h:219
int rtt
Definition: CachePeer.h:50
bool no_tproxy
Definition: CachePeer.h:119
#define MAX_IPSTRLEN
Length of buffer that needs to be allocated to old a null-terminated IP-string.
Definition: forward.h:23
const cache_key * storeKeyPublicByRequest(HttpRequest *request, const KeyScope keyScope)
#define MAX_URL
Definition: defines.h:118
int connect_fail_limit
Definition: CachePeer.h:177
#define PEER_MAX_ADDRESSES
Definition: defines.h:121
bool carp
Definition: CachePeer.h:105
int neighborUp(const CachePeer *p)
Definition: neighbors.cc:1149
char * toStr(char *buf, const unsigned int blen, int force=AF_UNSPEC) const
Definition: Address.cc:795
CachePeer * getFirstPeer(void)
Definition: neighbors.cc:500
int neighborsCount(PeerSelector *ps)
Definition: neighbors.cc:267
static void neighborAlive(CachePeer *, const MemObject *, const icp_common_t *)
Definition: neighbors.cc:876
time_t peer_connect
Definition: SquidConfig.h:111
SBuf & authority(bool requirePort=false) const
Definition: Uri.cc:470
void peerNoteDigestLookup(HttpRequest *request, CachePeer *p, lookup_t lookup)
Definition: neighbors.cc:862
static int ignoreMulticastReply(CachePeer *p, PeerSelector *ps)
Definition: neighbors.cc:975
void debug_trap(const char *message)
Definition: tools.cc:403
void peerClearRRStart(void)
Definition: neighbors.cc:423
struct CachePeer::@32 mcast
lookup_t
Definition: lookup_t.h:12
CachePeer * peerFindByName(const char *name)
Definition: neighbors.cc:1118
IRCB * ping_reply_callback
Definition: MemObject.h:158
void peerAlive(CachePeer *p)
Definition: neighbors.cc:452
void storeAppendPrintf(StoreEntry *e, const char *fmt,...)
Definition: store.cc:875
time_t last_connect_failure
Definition: CachePeer.h:57
IpsSelector< IpsIterator > goodAndBad() const
all IPs
Definition: ipcache.h:249
int stat5minClientRequests(void)
Definition: stat.cc:1691
bool originserver
Definition: CachePeer.h:118
int testing_now
Definition: CachePeer.h:155
HttpRequestPointer request
Definition: MemObject.h:155
#define EBIT_TEST(flag, bit)
Definition: defines.h:107
class SquidConfig Config
Definition: SquidConfig.cc:12
#define NULL
Definition: types.h:166
bool needValidation
Definition: RequestFlags.h:48
void neighbors_init(void)
Definition: neighbors.cc:547
bool roundrobin
Definition: CachePeer.h:88
int logged_state
so we can print dead/revived msgs
Definition: CachePeer.h:59
static void neighborAliveHtcp(CachePeer *, const MemObject *, const HtcpReplyData *)
Definition: neighbors.cc:913
char * host
Definition: CachePeer.h:41
virtual void syncAle(HttpRequest *adaptedRequest, const char *logUri) const
assigns uninitialized adapted_request and url ALE components
time_t backgroundPingRate
Definition: SquidConfig.h:102
int basetime
Definition: CachePeer.h:127
bool no_netdb_exchange
Definition: CachePeer.h:100
bool proxy_only
Definition: CachePeer.h:83
bool empty() const noexcept
whether we cached no IPs at all
Definition: ipcache.h:61
const char * icp_opcode_str[]

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors