icp_v2.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 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 12 Internet Cache Protocol (ICP) */
10
16#include "squid.h"
17#include "AccessLogEntry.h"
18#include "acl/Acl.h"
19#include "acl/FilledChecklist.h"
20#include "base/AsyncCallbacks.h"
21#include "client_db.h"
22#include "comm.h"
23#include "comm/Connection.h"
24#include "comm/Loops.h"
25#include "fd.h"
26#include "HttpRequest.h"
27#include "icmp/net_db.h"
28#include "ICP.h"
29#include "ip/Address.h"
30#include "ip/tools.h"
31#include "ipc/StartListening.h"
32#include "ipcache.h"
33#include "md5.h"
34#include "multicast.h"
35#include "neighbors.h"
36#include "refresh.h"
37#include "rfc1738.h"
38#include "SquidConfig.h"
39#include "StatCounters.h"
40#include "Store.h"
41#include "store_key_md5.h"
42#include "tools.h"
43#include "wordlist.h"
44
45#include <cerrno>
46
49public:
51 icp_common_t *msg = nullptr;
52 DelayedUdpSend *next = nullptr;
54 struct timeval queue_time = {};
55};
56
58
60static void icpLogIcp(const Ip::Address &, const LogTags_ot, int, const char *, const int, AccessLogEntryPointer &);
61
63static void icpHandleIcpV2(int, Ip::Address &, char *, int);
64
66static void icpCount(void *, int, size_t, int);
67
69
70static int icpUdpSend(int fd, const Ip::Address &to, icp_common_t * msg, int delay, AccessLogEntryPointer al);
71
72static void
73icpSyncAle(AccessLogEntryPointer &al, const Ip::Address &caddr, const char *url, int len, int delay)
74{
75 if (!al)
76 al = new AccessLogEntry();
77 al->icp.opcode = ICP_QUERY;
78 al->cache.caddr = caddr;
79 al->url = url;
81 // XXX: move to use icp.clientReply instead
84 al->cache.start_time.tv_sec -= delay;
85 al->cache.trTime.tv_sec = delay;
86 al->cache.trTime.tv_usec = 0;
87}
88
94static DelayedUdpSend *IcpQueueHead = nullptr;
96static DelayedUdpSend *IcpQueueTail = nullptr;
97
102
103/* icp_common_t */
105 opcode(ICP_INVALID), version(0), length(0), reqnum(0),
106 flags(0), pad(0), shostid(0)
107{}
108
109icp_common_t::icp_common_t(char *buf, unsigned int len) :
110 opcode(ICP_INVALID), version(0), reqnum(0), flags(0), pad(0), shostid(0)
111{
112 if (len < sizeof(icp_common_t)) {
113 /* mark as invalid */
114 length = len + 1;
115 return;
116 }
117
118 memcpy(this, buf, sizeof(icp_common_t));
119 /*
120 * Convert network order sensitive fields
121 */
122 length = ntohs(length);
123 reqnum = ntohl(reqnum);
124 flags = ntohl(flags);
125 pad = ntohl(pad);
126}
127
130{
131 if (opcode > static_cast<char>(icp_opcode::ICP_END))
132 return ICP_INVALID;
133
134 return static_cast<icp_opcode>(opcode);
135}
136
137/* ICPState */
138
140 header(aHeader),
141 request(aRequest),
142 fd(-1),
143 url(nullptr)
144{
146}
147
149{
150 safe_free(url);
152}
153
154bool
156{
157 const auto e = storeGetPublic(url, Http::METHOD_GET);
158
159 const auto hit = e && confirmAndPrepHit(*e);
160
161 if (e)
162 e->abandon(__FUNCTION__);
163
164 return hit;
165}
166
167bool
169{
170 if (!e.validToSend())
171 return false;
172
174 return false;
175
176 if (e.hittingRequiresCollapsing() && !startCollapsingOn(e, false))
177 return false;
178
179 return true;
180}
181
182LogTags *
184{
185 // calling icpSyncAle(LOG_TAG_NONE) here would not change cache.code
186 if (!al)
187 al = new AccessLogEntry();
188 return &al->cache.code;
189}
190
191void
193{
194 checklist.setRequest(request);
195 icpSyncAle(al, from, url, 0, 0);
196 checklist.al = al;
197}
198
199/* End ICPState */
200
201/* ICP2State */
202
204class ICP2State: public ICPState
205{
206
207public:
208 ICP2State(icp_common_t & aHeader, HttpRequest *aRequest):
209 ICPState(aHeader, aRequest),rtt(0),src_rtt(0),flags(0) {}
210
211 ~ICP2State() override;
212
213 int rtt;
215 uint32_t flags;
216};
217
219{}
220
221/* End ICP2State */
222
224static void
225icpLogIcp(const Ip::Address &caddr, const LogTags_ot logcode, const int len, const char *url, int delay, AccessLogEntry::Pointer &al)
226{
227 assert(logcode != LOG_TAG_NONE);
228
229 // Optimization: No premature (ALE creation in) icpSyncAle().
230 if (al) {
231 icpSyncAle(al, caddr, url, len, delay);
232 al->cache.code.update(logcode);
233 }
234
235 if (logcode == LOG_ICP_QUERY)
236 return; // we never log queries
237
238 if (!Config.onoff.log_udp) {
239 clientdbUpdate(caddr, al ? al->cache.code : LogTags(logcode), AnyP::PROTO_ICP, len);
240 return;
241 }
242
243 if (!al) {
244 // The above attempt to optimize ALE creation has failed. We do need it.
245 icpSyncAle(al, caddr, url, len, delay);
246 al->cache.code.update(logcode);
247 }
248 clientdbUpdate(caddr, al->cache.code, AnyP::PROTO_ICP, len);
249 accessLogLog(al, nullptr);
250}
251
253static void
254icpUdpSendQueue(int fd, void *)
255{
257
258 while ((q = IcpQueueHead) != nullptr) {
259 int delay = tvSubUsec(q->queue_time, current_time);
260 /* increment delay to prevent looping */
261 const int x = icpUdpSend(fd, q->address, q->msg, ++delay, q->ale);
262 IcpQueueHead = q->next;
263 delete q;
264
265 if (x < 0)
266 break;
267 }
268}
269
272 icp_opcode opcode,
273 int flags,
274 const char *url,
275 int reqnum,
276 int pad)
277{
278 char *buf = nullptr;
279 icp_common_t *headerp = nullptr;
280 char *urloffset = nullptr;
281 int buf_len;
282 buf_len = sizeof(icp_common_t) + strlen(url) + 1;
283
284 if (opcode == ICP_QUERY)
285 buf_len += sizeof(uint32_t);
286
287 buf = (char *) xcalloc(buf_len, 1);
288
289 headerp = (icp_common_t *) (void *) buf;
290
291 headerp->opcode = (char) opcode;
292
293 headerp->version = ICP_VERSION_CURRENT;
294
295 headerp->length = (uint16_t) htons(buf_len);
296
297 headerp->reqnum = htonl(reqnum);
298
299 headerp->flags = htonl(flags);
300
301 headerp->pad = htonl(pad);
302
303 headerp->shostid = 0;
304
305 urloffset = buf + sizeof(icp_common_t);
306
307 if (opcode == ICP_QUERY)
308 urloffset += sizeof(uint32_t);
309
310 memcpy(urloffset, url, strlen(url));
311
312 return (icp_common_t *)buf;
313}
314
315// TODO: Move retries to icpCreateAndSend(); the other caller does not retry.
318static int
320 const Ip::Address &to,
321 icp_common_t * msg,
322 int delay,
324{
325 int x;
326 int len;
327 len = (int) ntohs(msg->length);
328 debugs(12, 5, "icpUdpSend: FD " << fd << " sending " <<
329 icp_opcode_str[msg->opcode] << ", " << len << " bytes to " << to);
330
331 x = comm_udp_sendto(fd, to, msg, len);
332
333 if (x >= 0) {
334 /* successfully written */
335 const auto logcode = icpLogFromICPCode(static_cast<icp_opcode>(msg->opcode));
336 icpLogIcp(to, logcode, len, (char *) (msg + 1), delay, al);
337 icpCount(msg, SENT, (size_t) len, delay);
338 safe_free(msg);
339 } else if (0 == delay) {
340 /* send failed, but queue it */
341 const auto queue = new DelayedUdpSend();
342 queue->address = to;
343 queue->msg = msg;
344 queue->queue_time = current_time;
345 queue->ale = al;
346
347 if (IcpQueueHead == nullptr) {
348 IcpQueueHead = queue;
349 IcpQueueTail = queue;
350 } else if (IcpQueueTail == IcpQueueHead) {
351 IcpQueueTail = queue;
352 IcpQueueHead->next = queue;
353 } else {
354 IcpQueueTail->next = queue;
355 IcpQueueTail = queue;
356 }
357
360 } else {
361 /* don't queue it */
362 // XXX: safe_free(msg)
364 }
365
366 return x;
367}
368
377{
378 /* if store is rebuilding, return a UDP_MISS_NOFETCH */
379
382 return ICP_MISS_NOFETCH;
383 }
384
385 return ICP_ERR;
386}
387
388static LogTags_ot
390{
391 if (opcode == ICP_ERR)
392 return LOG_UDP_INVALID;
393
394 if (opcode == ICP_DENIED)
395 return LOG_UDP_DENIED;
396
397 if (opcode == ICP_HIT)
398 return LOG_UDP_HIT;
399
400 if (opcode == ICP_MISS)
401 return LOG_UDP_MISS;
402
403 if (opcode == ICP_MISS_NOFETCH)
405
406 if (opcode == ICP_DECHO)
407 return LOG_ICP_QUERY;
408
409 if (opcode == ICP_QUERY)
410 return LOG_ICP_QUERY;
411
412 fatal("expected ICP opcode\n");
413
414 return LOG_UDP_INVALID;
415}
416
417void
418icpCreateAndSend(icp_opcode opcode, int flags, char const *url, int reqnum, int pad, int fd, const Ip::Address &from, AccessLogEntry::Pointer al)
419{
420 // update potentially shared ALE ASAP; the ICP query itself may be delayed
421 if (al)
422 al->cache.code.update(icpLogFromICPCode(opcode));
423 icp_common_t *reply = icp_common_t::CreateMessage(opcode, flags, url, reqnum, pad);
424 icpUdpSend(fd, from, reply, 0, al);
425}
426
427void
428icpDenyAccess(Ip::Address &from, char *url, int reqnum, int fd)
429{
430 debugs(12, 2, "icpDenyAccess: Access Denied for " << from << " by " << AclMatchedName << ".");
431
432 if (clientdbCutoffDenied(from)) {
433 /*
434 * count this DENIED query in the clientdb, even though
435 * we're not sending an ICP reply...
436 */
438 } else {
439 icpCreateAndSend(ICP_DENIED, 0, url, reqnum, 0, fd, from, nullptr);
440 }
441}
442
443bool
445{
446 /* absent any explicit rules, we deny all */
447 if (!Config.accessList.icp)
448 return false;
449
450 ACLFilledChecklist checklist(Config.accessList.icp, icp_request, nullptr);
451 checklist.src_addr = from;
452 checklist.my_addr.setNoAddr();
453 return checklist.fastCheck().allowed();
454}
455
457icpGetRequest(char *url, int reqnum, int fd, Ip::Address &from)
458{
459 if (strpbrk(url, w_space)) {
460 url = rfc1738_escape(url);
461 icpCreateAndSend(ICP_ERR, 0, rfc1738_escape(url), reqnum, 0, fd, from, nullptr);
462 return nullptr;
463 }
464
465 const auto mx = MasterXaction::MakePortless<XactionInitiator::initIcp>();
466 auto *result = HttpRequest::FromUrlXXX(url, mx);
467 if (!result)
468 icpCreateAndSend(ICP_ERR, 0, url, reqnum, 0, fd, from, nullptr);
469
470 return result;
471
472}
473
474static void
475doV2Query(int fd, Ip::Address &from, char *buf, icp_common_t header)
476{
477 int rtt = 0;
478 int src_rtt = 0;
479 uint32_t flags = 0;
480 /* We have a valid packet */
481 char *url = buf + sizeof(icp_common_t) + sizeof(uint32_t);
482 HttpRequest *icp_request = icpGetRequest(url, header.reqnum, fd, from);
483
484 if (!icp_request)
485 return;
486
487 HTTPMSGLOCK(icp_request);
488
489 if (!icpAccessAllowed(from, icp_request)) {
490 icpDenyAccess(from, url, header.reqnum, fd);
491 HTTPMSGUNLOCK(icp_request);
492 return;
493 }
494#if USE_ICMP
495 if (header.flags & ICP_FLAG_SRC_RTT) {
496 rtt = netdbHostRtt(icp_request->url.host());
497 int hops = netdbHostHops(icp_request->url.host());
498 src_rtt = ((hops & 0xFFFF) << 16) | (rtt & 0xFFFF);
499
500 if (rtt)
501 flags |= ICP_FLAG_SRC_RTT;
502 }
503#endif /* USE_ICMP */
504
505 /* The peer is allowed to use this cache */
506 ICP2State state(header, icp_request);
507 state.fd = fd;
508 state.from = from;
509 state.url = xstrdup(url);
510 state.flags = flags;
511 state.rtt = rtt;
512 state.src_rtt = src_rtt;
513
514 icp_opcode codeToSend;
515
516 if (state.isHit()) {
517 codeToSend = ICP_HIT;
518 } else {
519#if USE_ICMP
520 if (Config.onoff.test_reachability && state.rtt == 0) {
521 if ((state.rtt = netdbHostRtt(state.request->url.host())) == 0)
522 netdbPingSite(state.request->url.host());
523 }
524#endif /* USE_ICMP */
525
527 codeToSend = icpGetCommonOpcode();
528 else if (Config.onoff.test_reachability && rtt == 0)
529 codeToSend = ICP_MISS_NOFETCH;
530 else
531 codeToSend = ICP_MISS;
532 }
533
534 icpCreateAndSend(codeToSend, flags, url, header.reqnum, src_rtt, fd, from, state.al);
535
536 HTTPMSGUNLOCK(icp_request);
537}
538
539void
541{
542 if (neighbors_do_private_keys && reqnum == 0) {
543 debugs(12, DBG_CRITICAL, "icpHandleIcpV2: Neighbor " << from << " returned reqnum = 0");
544 debugs(12, DBG_CRITICAL, "icpHandleIcpV2: Disabling use of private keys");
546 }
547
548 char *url = buf + sizeof(icp_common_t);
549 debugs(12, 3, "icpHandleIcpV2: " << icp_opcode_str[opcode] << " from " << from << " for '" << url << "'");
550
551 const cache_key *key = icpGetCacheKey(url, (int) reqnum);
552 /* call neighborsUdpAck even if ping_status != PING_WAITING */
553 neighborsUdpAck(key, this, from);
554}
555
556static void
557icpHandleIcpV2(int fd, Ip::Address &from, char *buf, int len)
558{
559 if (len <= 0) {
560 debugs(12, 3, "icpHandleIcpV2: ICP message is too small");
561 return;
562 }
563
564 icp_common_t header(buf, len);
565 /*
566 * Length field should match the number of bytes read
567 */
568
569 if (len != header.length) {
570 debugs(12, 3, "icpHandleIcpV2: ICP message is too small");
571 return;
572 }
573
574 debugs(12, 5, "OPCODE " << icp_opcode_str[header.getOpCode()] << '=' << uint8_t(header.opcode));
575
576 switch (header.opcode) {
577
578 case ICP_QUERY:
579 /* We have a valid packet */
580 doV2Query(fd, from, buf, header);
581 break;
582
583 case ICP_HIT:
584
585 case ICP_DECHO:
586
587 case ICP_MISS:
588
589 case ICP_DENIED:
590
591 case ICP_MISS_NOFETCH:
592 header.handleReply(buf, from);
593 break;
594
595 case ICP_INVALID:
596
597 case ICP_ERR:
598 break;
599
600 default:
601 debugs(12, DBG_CRITICAL, "ERROR: icpHandleIcpV2: Unknown opcode: " << header.opcode << " from " << from);
602
603 break;
604 }
605}
606
607#ifdef ICP_PKT_DUMP
608static void
609icpPktDump(icp_common_t * pkt)
610{
611 Ip::Address a;
612
613 debugs(12, 9, "opcode: " << std::setw(3) << pkt->opcode << " " << icp_opcode_str[pkt->opcode]);
614 debugs(12, 9, "version: "<< std::left << std::setw(8) << pkt->version);
615 debugs(12, 9, "length: "<< std::left << std::setw(8) << ntohs(pkt->length));
616 debugs(12, 9, "reqnum: "<< std::left << std::setw(8) << ntohl(pkt->reqnum));
617 debugs(12, 9, "flags: "<< std::left << std::hex << std::setw(8) << ntohl(pkt->flags));
618 a = (struct in_addr)pkt->shostid;
619 debugs(12, 9, "shostid: " << a );
620 debugs(12, 9, "payload: " << (char *) pkt + sizeof(icp_common_t));
621}
622
623#endif
624
625void
626icpHandleUdp(int sock, void *)
627{
629
630 Ip::Address from;
632 int len;
633 int icp_version;
634 int max = INCOMING_UDP_MAX;
636
637 while (max) {
638 --max;
639 len = comm_udp_recvfrom(sock,
640 buf,
642 0,
643 from);
644
645 if (len == 0)
646 break;
647
648 if (len < 0) {
649 int xerrno = errno;
650 if (ignoreErrno(xerrno))
651 break;
652
653#if _SQUID_LINUX_
654 /* Some Linux systems seem to set the FD for reading and then
655 * return ECONNREFUSED when sendto() fails and generates an ICMP
656 * port unreachable message. */
657 /* or maybe an EHOSTUNREACH "No route to host" message */
658 if (xerrno != ECONNREFUSED && xerrno != EHOSTUNREACH)
659#endif
660 debugs(50, DBG_IMPORTANT, "icpHandleUdp: FD " << sock << " recvfrom: " << xstrerr(xerrno));
661
662 break;
663 }
664
665 ++(*N);
666 icpCount(buf, RECV, (size_t) len, 0);
667 buf[len] = '\0';
668 debugs(12, 4, "icpHandleUdp: FD " << sock << ": received " <<
669 (unsigned long int)len << " bytes from " << from);
670
671#ifdef ICP_PACKET_DUMP
672
673 icpPktDump(buf);
674#endif
675
676 if ((size_t) len < sizeof(icp_common_t)) {
677 debugs(12, 4, "icpHandleUdp: Ignoring too-small UDP packet");
678 break;
679 }
680
681 icp_version = (int) buf[1]; /* cheat! */
682
683 if (icpOutgoingConn->local == from)
684 // ignore ICP packets which loop back (multicast usually)
685 debugs(12, 4, "icpHandleUdp: Ignoring UDP packet sent by myself");
686 else if (icp_version == ICP_VERSION_2)
687 icpHandleIcpV2(sock, from, buf, len);
688 else if (icp_version == ICP_VERSION_3)
689 icpHandleIcpV3(sock, from, buf, len);
690 else
691 debugs(12, DBG_IMPORTANT, "WARNING: Unused ICP version " << icp_version <<
692 " received from " << from);
693 }
694}
695
696void
698{
699 uint16_t port;
700
701 if ((port = Config.Port.icp) <= 0)
702 return;
703
707
709 debugs(12, DBG_CRITICAL, "ERROR: IPv6 is disabled. " << icpIncomingConn->local << " is not an IPv4 address.");
710 fatal("ICP port cannot be opened.");
711 }
712 /* split-stack for now requires default IPv4-only ICP */
715 }
716
718 Ipc::StartListening(SOCK_DGRAM,
719 IPPROTO_UDP,
721 Ipc::fdnInIcpSocket, call);
722
727
729 debugs(49, DBG_CRITICAL, "ERROR: IPv6 is disabled. " << icpOutgoingConn->local << " is not an IPv4 address.");
730 fatal("ICP port cannot be opened.");
731 }
732 /* split-stack for now requires default IPv4-only ICP */
735 }
736
737 enter_suid();
738 comm_open_listener(SOCK_DGRAM, IPPROTO_UDP, icpOutgoingConn, "Outgoing ICP Port");
739 leave_suid();
740
742 fatal("Cannot open Outgoing ICP Port");
743
744 debugs(12, DBG_CRITICAL, "Sending ICP messages from " << icpOutgoingConn->local);
745
747 fd_note(icpOutgoingConn->fd, "Outgoing ICP socket");
748 }
749}
750
751static void
753{
754 const auto &conn = answer.conn;
755
757 fatal("Cannot open ICP Port");
758
760
761 for (const wordlist *s = Config.mcast_group_list; s; s = s->next)
762 ipcache_nbgethostbyname(s->key, mcastJoinGroups, nullptr); // XXX: pass the conn for mcastJoinGroups usage.
763
764 debugs(12, DBG_IMPORTANT, "Accepting ICP messages on " << conn->local);
765
766 fd_note(conn->fd, "Incoming ICP port");
767
770 debugs(12, DBG_IMPORTANT, "Sending ICP messages from " << icpOutgoingConn->local);
771 }
772}
773
778void
780{
782 return;
783
784 debugs(12, DBG_IMPORTANT, "Stop receiving ICP on " << icpIncomingConn->local);
785
790 icpIncomingConn = nullptr;
791
799
800 Comm::SetSelect(icpOutgoingConn->fd, COMM_SELECT_READ, nullptr, nullptr, 0);
801}
802
803void
805{
807
808 if (icpOutgoingConn != nullptr) {
809 debugs(12, DBG_IMPORTANT, "Stop sending ICP from " << icpOutgoingConn->local);
810 icpOutgoingConn = nullptr;
811 }
812}
813
814static void
815icpCount(void *buf, int which, size_t len, int delay)
816{
817 icp_common_t *icp = (icp_common_t *) buf;
818
819 if (len < sizeof(*icp))
820 return;
821
822 if (SENT == which) {
825
826 if (ICP_QUERY == icp->opcode) {
829 } else {
832 /* this is the sent-reply service time */
834 }
835
836 if (ICP_HIT == icp->opcode)
838 } else if (RECV == which) {
841
842 if (ICP_QUERY == icp->opcode) {
845 } else {
848 /* statCounter.icp.querySvcTime set in clientUpdateCounters */
849 }
850
851 if (ICP_HIT == icp->opcode)
853 }
854}
855
856#define N_QUERIED_KEYS 8192
857#define N_QUERIED_KEYS_MASK 8191
859
860int
862{
863 static int reqnum = 0;
864
865 if (++reqnum < 0)
866 reqnum = 1;
867
869
870 return reqnum;
871}
872
873const cache_key *
874icpGetCacheKey(const char *url, int reqnum)
875{
876 if (neighbors_do_private_keys && reqnum)
877 return queried_keys[reqnum & N_QUERIED_KEYS_MASK];
878
879 return storeKeyPublic(url, Http::METHOD_GET);
880}
881
void accessLogLog(const AccessLogEntryPointer &, ACLChecklist *)
Definition: access_log.cc:136
#define asyncCallbackFun(dbgSection, dbgLevel, function)
AsyncCall for calling back a function.
LogTags_ot
Definition: LogTags.h:37
@ LOG_UDP_MISS_NOFETCH
Definition: LogTags.h:61
@ LOG_UDP_DENIED
Definition: LogTags.h:59
@ LOG_UDP_HIT
Definition: LogTags.h:57
@ LOG_ICP_QUERY
Definition: LogTags.h:62
@ LOG_TAG_NONE
Definition: LogTags.h:38
@ LOG_UDP_MISS
Definition: LogTags.h:58
@ LOG_UDP_INVALID
Definition: LogTags.h:60
#define INCOMING_UDP_MAX
Definition: Loops.h:50
time_t squid_curtime
Definition: stub_libtime.cc:20
class SquidConfig Config
Definition: SquidConfig.cc:12
StatCounters statCounter
Definition: StatCounters.cc:12
int conn
the current server connection FD
Definition: Transport.cc:26
#define assert(EX)
Definition: assert.h:17
static int version
Acl::Answer const & fastCheck()
Definition: Checklist.cc:332
void setRequest(HttpRequest *)
configure client request-related fields for the first time
Ip::Address src_addr
AccessLogEntry::Pointer al
info for the future access.log, and external ACL
struct timeval start_time
The time the master transaction started.
struct timeval trTime
The response time.
MessageSizes clientReplySz
counters for the response sent to client
class AccessLogEntry::CacheDetails cache
class AccessLogEntry::HttpDetails http
void setVirginUrlForMissingRequest(const SBuf &vu)
Remember Client URI (or equivalent) when there is no HttpRequest.
class AccessLogEntry::IcpDetails icp
bool allowed() const
Definition: Acl.h:156
void host(const char *src)
Definition: Uri.cc:100
Ip::Address local
Definition: Connection.h:146
a delayed icpUdpSend() call
Definition: icp_v2.cc:48
AccessLogEntryPointer ale
sender's master transaction summary
Definition: icp_v2.cc:53
icp_common_t * msg
ICP message with network byte order fields.
Definition: icp_v2.cc:51
Ip::Address address
remote peer (which may not be a cache_peer)
Definition: icp_v2.cc:50
DelayedUdpSend * next
invasive FIFO queue of delayed ICP messages
Definition: icp_v2.cc:52
struct timeval queue_time
queuing timestamp
Definition: icp_v2.cc:54
static HttpRequest * FromUrlXXX(const char *url, const MasterXaction::Pointer &, const HttpRequestMethod &method=Http::METHOD_GET)
Definition: HttpRequest.cc:528
AnyP::Uri url
the request URI
Definition: HttpRequest.h:115
ICP2State(icp_common_t &aHeader, HttpRequest *aRequest)
Definition: icp_v2.cc:208
~ICP2State() override
Definition: icp_v2.cc:218
int src_rtt
Definition: icp_v2.cc:214
uint32_t flags
Definition: icp_v2.cc:215
int rtt
Definition: icp_v2.cc:213
Definition: ICP.h:62
LogTags * loggingTags() const override
Definition: icp_v2.cc:183
bool isHit() const
whether the cache contains the requested entry
Definition: icp_v2.cc:155
AccessLogEntryPointer al
Definition: ICP.h:77
Ip::Address from
Definition: ICP.h:75
HttpRequest * request
Definition: ICP.h:72
char * url
Definition: ICP.h:76
int fd
Definition: ICP.h:73
void fillChecklist(ACLFilledChecklist &) const override
configure the given checklist (to reflect the current transaction state)
Definition: icp_v2.cc:192
~ICPState() override
Definition: icp_v2.cc:148
ICPState(icp_common_t &aHeader, HttpRequest *aRequest)
Definition: icp_v2.cc:139
bool confirmAndPrepHit(const StoreEntry &) const
either confirms and starts processing a cache hit or returns false
Definition: icp_v2.cc:168
bool setIPv4()
Definition: Address.cc:224
bool isNoAddr() const
Definition: Address.cc:284
bool isAnyAddr() const
Definition: Address.cc:170
void setNoAddr()
Definition: Address.cc:292
unsigned short port() const
Definition: Address.cc:778
StartListening() result.
Comm::ConnectionPointer conn
opened listening socket
void update(const LogTags_ot t)
Definition: LogTags.cc:54
uint64_t payloadData
total size of payload block(s) excluding transfer encoding overheads
Definition: MessageSizes.h:24
struct SquidConfig::@94 Port
Ip::Address udp_outgoing
Definition: SquidConfig.h:236
struct SquidConfig::@107 accessList
struct SquidConfig::@106 onoff
Ip::Address udp_incoming
Definition: SquidConfig.h:235
int test_reachability
Definition: SquidConfig.h:288
struct SquidConfig::@101 Addrs
unsigned short icp
Definition: SquidConfig.h:141
wordlist * mcast_group_list
Definition: SquidConfig.h:246
int icp_hit_stale
Definition: SquidConfig.h:283
ByteCounter kbytes_sent
Definition: StatCounters.h:76
StatHist replySvcTime
Definition: StatCounters.h:83
int replies_dropped
Definition: StatCounters.h:75
ByteCounter r_kbytes_sent
Definition: StatCounters.h:78
ByteCounter kbytes_recv
Definition: StatCounters.h:79
ByteCounter q_kbytes_sent
Definition: StatCounters.h:77
ByteCounter q_kbytes_recv
Definition: StatCounters.h:80
struct StatCounters::@124 icp
ByteCounter r_kbytes_recv
Definition: StatCounters.h:81
int replies_queued
Definition: StatCounters.h:74
void count(double val)
Definition: StatHist.cc:55
bool startCollapsingOn(const StoreEntry &, const bool doingRevalidation) const
Definition: store_client.cc:66
bool hittingRequiresCollapsing() const
whether this entry can feed collapsed requests and only them
Definition: Store.h:216
int validToSend() const
Definition: store.cc:1333
static int store_dirs_rebuilding
the number of cache_dirs being rebuilt; TODO: move to Disks::Rebuilding
Definition: Controller.h:134
uint32_t flags
Definition: ICP.h:45
void handleReply(char *buf, Ip::Address &from)
Definition: icp_v2.cc:540
uint32_t shostid
Definition: ICP.h:48
unsigned char version
Definition: ICP.h:40
icp_common_t()
Definition: icp_v2.cc:104
icp_opcode getOpCode() const
Definition: icp_v2.cc:129
static icp_common_t * CreateMessage(icp_opcode opcode, int flags, const char *url, int reqnum, int pad)
Definition: icp_v2.cc:271
uint32_t reqnum
Definition: ICP.h:44
uint32_t pad
Definition: ICP.h:46
unsigned char opcode
Definition: ICP.h:38
unsigned short length
Definition: ICP.h:42
wordlist * next
Definition: wordlist.h:33
void clientdbUpdate(const Ip::Address &addr, const LogTags &ltype, AnyP::ProtocolType p, size_t size)
Definition: client_db.cc:138
int clientdbCutoffDenied(const Ip::Address &addr)
Definition: client_db.cc:209
int ignoreErrno(int ierrno)
Definition: comm.cc:1440
int comm_udp_sendto(int fd, const Ip::Address &to_addr, const void *buf, int len)
Definition: comm.cc:918
void comm_open_listener(int sock_type, int proto, Comm::ConnectionPointer &conn, const char *note)
Definition: comm.cc:256
int comm_udp_recvfrom(int fd, void *buf, size_t len, int flags, Ip::Address &from)
Definition: comm.cc:125
A const & max(A const &lhs, A const &rhs)
#define w_space
#define DBG_IMPORTANT
Definition: Stream.h:38
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Stream.h:194
#define DBG_CRITICAL
Definition: Stream.h:37
#define COMM_SELECT_READ
Definition: defines.h:24
#define COMM_SELECT_WRITE
Definition: defines.h:25
#define ICP_VERSION_CURRENT
Definition: defines.h:46
#define ICP_FLAG_SRC_RTT
Definition: defines.h:41
#define ICP_VERSION_2
Definition: defines.h:44
#define ICP_VERSION_3
Definition: defines.h:45
static int port
Definition: ldap_backend.cc:70
@ RECV
Definition: enums.h:176
@ SENT
Definition: enums.h:175
void fatal(const char *message)
Definition: fatal.cc:28
void fd_note(int fd, const char *s)
Definition: fd.cc:216
int opt_reload_hit_only
int neighbors_do_private_keys
time_t hit_only_mode_until
int incoming_sockets_accepted
const char * AclMatchedName
Definition: Acl.cc:29
void ipcache_nbgethostbyname(const char *name, IPH *handler, void *handlerData)
Definition: ipcache.cc:608
icp_opcode icpGetCommonOpcode()
Definition: icp_v2.cc:376
int icpSetCacheKey(const cache_key *key)
Definition: icp_v2.cc:861
void icpCreateAndSend(icp_opcode opcode, int flags, char const *url, int reqnum, int pad, int fd, const Ip::Address &from, AccessLogEntry::Pointer al)
Definition: icp_v2.cc:418
icp_opcode
Definition: icp_opcode.h:13
void icpConnectionShutdown(void)
Definition: icp_v2.cc:779
void icpHandleIcpV3(int, Ip::Address &, char *, int)
Definition: icp_v3.cc:71
void icpOpenPorts(void)
Definition: icp_v2.cc:697
void icpClosePorts(void)
Definition: icp_v2.cc:804
bool icpAccessAllowed(Ip::Address &from, HttpRequest *icp_request)
Definition: icp_v2.cc:444
const cache_key * icpGetCacheKey(const char *url, int reqnum)
Definition: icp_v2.cc:874
void icpDenyAccess(Ip::Address &from, char *url, int reqnum, int fd)
Definition: icp_v2.cc:428
HttpRequest * icpGetRequest(char *url, int reqnum, int fd, Ip::Address &from)
Definition: icp_v2.cc:457
@ ICP_DECHO
Definition: icp_opcode.h:26
@ ICP_INVALID
Definition: icp_opcode.h:15
@ ICP_QUERY
Definition: icp_opcode.h:16
@ ICP_MISS_NOFETCH
Definition: icp_opcode.h:36
@ ICP_END
Definition: icp_opcode.h:39
@ ICP_DENIED
Definition: icp_opcode.h:37
@ ICP_ERR
Definition: icp_opcode.h:19
@ ICP_MISS
Definition: icp_opcode.h:18
@ ICP_HIT
Definition: icp_opcode.h:17
static void icpHandleIcpV2(int, Ip::Address &, char *, int)
Definition: icp_v2.cc:557
Comm::ConnectionPointer icpOutgoingConn
Definition: icp_v2.cc:101
static void icpCount(void *, int, size_t, int)
Definition: icp_v2.cc:815
Comm::ConnectionPointer icpIncomingConn
Definition: icp_v2.cc:99
static void icpLogIcp(const Ip::Address &, const LogTags_ot, int, const char *, const int, AccessLogEntryPointer &)
updates ALE (if any) and logs the transaction (if needed)
Definition: icp_v2.cc:225
static DelayedUdpSend * IcpQueueTail
Definition: icp_v2.cc:96
static DelayedUdpSend * IcpQueueHead
Definition: icp_v2.cc:94
static void icpUdpSendQueue(int fd, void *)
Definition: icp_v2.cc:254
void HTTPMSGUNLOCK(M *&a)
Definition: Message.h:150
void HTTPMSGLOCK(Http::Message *a)
Definition: Message.h:161
const char * icp_opcode_str[]
static void icpIncomingConnectionOpened(Ipc::StartListeningAnswer &)
Definition: icp_v2.cc:752
#define N_QUERIED_KEYS_MASK
Definition: icp_v2.cc:857
#define N_QUERIED_KEYS
Definition: icp_v2.cc:856
static cache_key queried_keys[N_QUERIED_KEYS][SQUID_MD5_DIGEST_LENGTH]
Definition: icp_v2.cc:858
static int icpUdpSend(int fd, const Ip::Address &to, icp_common_t *msg, int delay, AccessLogEntryPointer al)
Definition: icp_v2.cc:319
static void doV2Query(int fd, Ip::Address &from, char *buf, icp_common_t header)
Definition: icp_v2.cc:475
void icpHandleUdp(int sock, void *)
Definition: icp_v2.cc:626
static LogTags_ot icpLogFromICPCode(icp_opcode)
Definition: icp_v2.cc:389
static void icpSyncAle(AccessLogEntryPointer &al, const Ip::Address &caddr, const char *url, int len, int delay)
Definition: icp_v2.cc:73
#define IPV6_SPECIAL_SPLITSTACK
Definition: tools.h:22
#define SQUID_MD5_DIGEST_LENGTH
Definition: md5.h:66
IPH mcastJoinGroups
@ PROTO_ICP
Definition: ProtocolType.h:31
bool IsConnOpen(const Comm::ConnectionPointer &conn)
Definition: Connection.cc:27
void SetSelect(int, unsigned int, PF *, void *, time_t)
Mark an FD to be watched for its IO status.
Definition: ModDevPoll.cc:223
@ METHOD_GET
Definition: MethodType.h:25
@ fdnInIcpSocket
Definition: FdNotes.h:24
void StartListening(int sock_type, int proto, const Comm::ConnectionPointer &listenConn, FdNoteId, StartListeningCallback &)
SSL Connection
Definition: Session.h:45
#define xstrdup
void neighborsUdpAck(const cache_key *key, icp_common_t *header, const Ip::Address &from)
Definition: neighbors.cc:929
void netdbPingSite(const char *hostname)
Definition: net_db.cc:827
int netdbHostHops(const char *host)
Definition: net_db.cc:944
int netdbHostRtt(const char *host)
Definition: net_db.cc:960
int refreshCheckICP(const StoreEntry *entry, HttpRequest *request)
Definition: refresh.cc:587
#define rfc1738_escape(x)
Definition: rfc1738.h:52
#define LOCAL_ARRAY(type, name, size)
Definition: squid.h:68
#define SQUID_UDP_SO_RCVBUF
Definition: squid.h:55
unsigned char cache_key
Store key.
Definition: forward.h:29
StoreEntry * storeGetPublic(const char *uri, const HttpRequestMethod &method)
Definition: store.cc:490
cache_key * storeKeyCopy(cache_key *dst, const cache_key *src)
const cache_key * storeKeyPublic(const char *url, const HttpRequestMethod &method, const KeyScope keyScope)
int EnableIpv6
Whether IPv6 is supported and type of support.
Definition: tools.h:25
int unsigned int
Definition: stub_fd.cc:19
int tvSubUsec(struct timeval t1, struct timeval t2)
Definition: gadgets.cc:37
struct timeval current_time
the current UNIX time in timeval {seconds, microseconds} format
Definition: gadgets.cc:17
void leave_suid(void)
Definition: tools.cc:559
void enter_suid(void)
Definition: tools.cc:623
void * xcalloc(size_t n, size_t sz)
Definition: xalloc.cc:71
#define safe_free(x)
Definition: xalloc.h:73
const char * xstrerr(int error)
Definition: xstrerror.cc:83

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors