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