FwdState.cc
Go to the documentation of this file.
120FwdState::FwdState(const Comm::ConnectionPointer &client, StoreEntry * e, HttpRequest * r, const AccessLogEntryPointer &alp):
158 AsyncCall::Pointer call = asyncCall(17, 4, "FwdState::Abort", cbdataDialer(&FwdState::HandleStoreAbort, this));
169 const bool isIntercepted = request && !request->flags.redirected && (request->flags.intercepted || request->flags.interceptTproxy);
170 const bool useOriginalDst = Config.onoff.client_dst_passthru || (request && !request->flags.hostVerified);
290 ConnStateData::httpsPeeked, ConnStateData::PinnedIdleContext(Comm::ConnectionPointer(nullptr), request));
341FwdState::Start(const Comm::ConnectionPointer &clientConn, StoreEntry *entry, HttpRequest *request, const AccessLogEntryPointer &al)
412FwdState::fwdStart(const Comm::ConnectionPointer &clientConn, StoreEntry *entry, HttpRequest *request)
454 const auto anErr = new ErrorState(ERR_CANNOT_FORWARD, Http::scInternalServerError, request, al);
465 debugs(17, 3, err_type_str[errorState->type] << " \"" << Http::StatusCodeString(errorState->httpStatus) << "\"\n\t" << entry->url());
560 debugs(17, 3, "server FD " << serverConnection()->fd << " not re-forwarding status " << replyStatus);
775 debugs(17, 3, "re-forwarding (" << n_tries << " tries, " << (squid_curtime - start_t) << " secs)");
821FwdState::advanceDestination(const char *stepDescription, const Comm::ConnectionPointer &conn, const StepStart &startStep)
913 const auto tunneler = new Http::Tunneler(conn, requestPointer, callback, connectingTimeout(conn), al);
943 closePendingConnection(answer.conn, "conn was closed while waiting for tunnelEstablishmentDone");
978 const bool clientFirstBump = request->flags.sslBumped; // client-first (already) bumped connection
983 const bool needTlsToOrigin = !p && request->url.getScheme() == AnyP::PROTO_HTTPS && !clientFirstBump;
1005 connector = new Ssl::PeekingPeerConnector(requestPointer, conn, clientConn, callback, al, sslNegotiationTimeout);
1008 connector = new Security::BlindPeerConnector(requestPointer, conn, callback, al, sslNegotiationTimeout);
1066FwdState::syncWithServerConn(const Comm::ConnectionPointer &conn, const char *host, const bool reused)
1225 clientFde->nfConnmarkFromServer = Ip::Qos::getNfConnmark(serverConnection(), Ip::Qos::dirOpened);
1512 // needs a bit of rework in ACLFilledChecklist to use Comm::Connection instead of ConnStateData
1560 debugs(17, 3, "from " << conn.local << " tos " << int(conn.tos) << " netfilter mark " << conn.nfmark);
RefCount< AsyncCallT< Dialer > > asyncCall(int aDebugSection, int aDebugLevel, const char *aName, const Dialer &aDialer)
Definition: AsyncCall.h:156
#define asyncCallback(dbgSection, dbgLevel, method, object)
Definition: AsyncCallbacks.h:195
UnaryCbdataDialer< Argument1 > cbdataDialer(typename UnaryCbdataDialer< Argument1 >::Handler *handler, Argument1 *arg1)
Definition: AsyncCbdataCalls.h:40
#define CallJobHere(debugSection, debugLevel, job, Class, method)
Definition: AsyncJobCalls.h:58
#define CallJobHere1(debugSection, debugLevel, job, Class, method, arg1)
Definition: AsyncJobCalls.h:63
void NoteOutgoingConnectionSuccess(CachePeer *const peer)
Definition: CachePeer.h:233
ErrorDetail::Pointer MakeNamedErrorDetail(const char *name)
Definition: Detail.cc:54
PconnPool * fwdPconnPool
a collection of previously used persistent Squid-to-peer HTTP(S) connections
Definition: FwdState.cc:78
static int FwdReplyCodes[MAX_FWD_STATS_IDX+1][Http::scInvalidHeader+1]
Definition: FwdState.cc:76
static nfmark_t GetNfmarkToServer(HttpRequest *request, Comm::Connection &conn)
Definition: FwdState.cc:1542
void getOutgoingAddress(HttpRequest *request, const Comm::ConnectionPointer &conn)
Definition: FwdState.cc:1476
Ip::NfMarkConfig aclFindNfMarkConfig(acl_nfmark *head, ACLChecklist *ch)
Checks for a netfilter mark value to apply depending on the ACL.
Definition: FwdState.cc:1465
void ResetMarkingsToServer(HttpRequest *request, Comm::Connection &conn)
Definition: FwdState.cc:1564
tos_t aclMapTOS(acl_tos *head, ACLChecklist *ch)
Checks for a TOS value to apply depending on the ACL.
Definition: FwdState.cc:1453
void GetMarkingsToServer(HttpRequest *request, Comm::Connection &conn)
Definition: FwdState.cc:1555
static tos_t GetTosToServer(HttpRequest *request, Comm::Connection &conn)
Definition: FwdState.cc:1529
static time_t diffOrZero(const time_t larger, const time_t smaller)
Definition: FwdState.cc:421
std::ostream & CurrentException(std::ostream &os)
prints active (i.e., thrown but not yet handled) exception
Definition: TextException.cc:88
void error(char *format,...)
Definition: Checklist.h:27
Definition: FilledChecklist.h:32
AccessLogEntry::Pointer al
info for the future access.log, and external ACL
Definition: FilledChecklist.h:101
void syncAle(HttpRequest *adaptedRequest, const char *logUri) const override
assigns uninitialized adapted_request and url ALE components
Definition: FilledChecklist.cc:121
class AccessLogEntry::CacheDetails cache
void updateError(const Error &)
sets (or updates the already stored) transaction error as needed
Definition: AccessLogEntry.cc:212
Definition: CommCalls.h:128
Definition: Connection.h:73
parameters for the async notePinnedConnectionBecameIdle() call
Definition: client_side.h:183
Definition: client_side.h:84
void httpsPeeked(PinnedIdleContext pic)
called by FwdState when it is done bumping the server
Definition: client_side.cc:3100
static Comm::ConnectionPointer BorrowPinnedConnection(HttpRequest *, const AccessLogEntryPointer &)
Definition: client_side.cc:3905
virtual void notePeerConnection(Comm::ConnectionPointer)
called just before a FwdState-dispatched job starts using connection
Definition: client_side.h:207
Definition: errorpage.h:89
void detailError(const ErrorDetail::Pointer &dCode)
set error type-specific detail code
Definition: errorpage.h:111
Definition: FwdState.h:53
void secureConnectionToPeerIfNeeded(const Comm::ConnectionPointer &)
handles an established TCP connection to peer (including origin servers)
Definition: FwdState.cc:968
Comm::ConnectionPointer clientConn
a possibly open connection to the client.
Definition: FwdState.h:178
void reactToZeroSizeObject()
ERR_ZERO_SIZE_OBJECT requires special adjustments.
Definition: FwdState.cc:481
void noteDestinationsEnd(ErrorState *selectionError) override
Definition: FwdState.cc:621
void connectedToPeer(Security::EncryptorAnswer &answer)
called when all negotiations with the TLS-speaking peer have been completed
Definition: FwdState.cc:1015
void successfullyConnectedToPeer(const Comm::ConnectionPointer &)
called when all negotiations with the peer have been completed
Definition: FwdState.cc:1051
FwdState(const Comm::ConnectionPointer &client, StoreEntry *, HttpRequest *, const AccessLogEntryPointer &alp)
Definition: FwdState.cc:120
JobWait< HappyConnOpener > transportWait
waits for a transport connection to the peer to be established/opened
Definition: FwdState.h:190
static void Start(const Comm::ConnectionPointer &client, StoreEntry *, HttpRequest *, const AccessLogEntryPointer &alp)
Initiates request forwarding to a peer or origin server.
Definition: FwdState.cc:341
void noteDestination(Comm::ConnectionPointer conn) override
called when a new unique destination has been found
Definition: FwdState.cc:592
static void HandleStoreAbort(FwdState *)
called by Store if the entry is no longer usable
Definition: FwdState.cc:83
time_t connectingTimeout(const Comm::ConnectionPointer &conn) const
Definition: FwdState.cc:1439
static bool EnoughTimeToReForward(const time_t fwdStart)
Definition: FwdState.cc:436
void closePendingConnection(const Comm::ConnectionPointer &conn, const char *reason)
get rid of a to-server connection that failed to become serverConn
Definition: FwdState.cc:96
Comm::ConnectionPointer const & serverConnection() const
Definition: FwdState.h:104
Comm::ConnectionPointer serverConn
a successfully opened connection to a server.
Definition: FwdState.h:203
static time_t ForwardTimeout(const time_t fwdStart)
time left to finish the whole forwarding process (which started at fwdStart)
Definition: FwdState.cc:428
void closeServerConnection(const char *reason)
stops monitoring server connection for closure and updates pconn stats
Definition: FwdState.cc:108
JobWait< Security::PeerConnector > encryptionWait
waits for the established transport connection to be secured/encrypted
Definition: FwdState.h:193
void updateAttempts(int)
sets n_tries to the given value (while keeping ALE, if any, in sync)
Definition: FwdState.cc:1096
void usePinned()
send request on an existing connection dedicated to the requesting client
Definition: FwdState.cc:1152
void tunnelEstablishmentDone(Http::TunnelerAnswer &answer)
resumes operations after the (possibly failed) HTTP CONNECT exchange
Definition: FwdState.cc:930
static void logReplyStatus(int tries, const Http::StatusCode status)
Definition: FwdState.cc:1397
static void RegisterWithCacheManager(void)
Definition: FwdState.cc:1391
void updateAleWithFinalError()
updates ALE when we finalize the transaction error (if any)
Definition: FwdState.cc:238
bool exhaustedTries() const
whether we have used up all permitted forwarding attempts
Definition: FwdState.cc:1411
void establishTunnelThruProxy(const Comm::ConnectionPointer &)
Definition: FwdState.cc:909
void stopAndDestroy(const char *reason)
ends forwarding; relies on refcounting so the effect may not be immediate
Definition: FwdState.cc:183
bool checkRetriable()
Whether we may try sending this request again after a failure.
Definition: FwdState.cc:734
void syncWithServerConn(const Comm::ConnectionPointer &server, const char *host, const bool reused)
commits to using the given open to-peer connection
Definition: FwdState.cc:1066
bool waitingForDispatched
whether we are waiting for the last dispatch()ed activity to end
Definition: FwdState.h:200
void notifyConnOpener()
makes sure connection opener knows that the destinations have changed
Definition: FwdState.cc:660
void markStoredReplyAsWhole(const char *whyWeAreSure)
Definition: FwdState.cc:580
void secureConnectionToPeer(const Comm::ConnectionPointer &)
encrypts an established TCP connection to peer (including origin servers)
Definition: FwdState.cc:997
struct FwdState::@67 flags
static void fwdStart(const Comm::ConnectionPointer &client, StoreEntry *, HttpRequest *)
Same as Start() but no master xaction info (AccessLogEntry) available.
Definition: FwdState.cc:412
void syncHierNote(const Comm::ConnectionPointer &server, const char *host)
Definition: FwdState.cc:1086
void advanceDestination(const char *stepDescription, const Comm::ConnectionPointer &conn, const StepStart &startStep)
starts a preparation step for an established connection; retries on failures
Definition: FwdState.cc:821
Final result (an open connection or an error) sent to the job initiator.
Definition: HappyConnOpener.h:76
Definition: HappyConnOpener.h:106
void startPeerClock()
Start recording total time spent communicating with peers.
Definition: access_log.cc:245
void resetPeerNotes(const Comm::ConnectionPointer &server, const char *requestedHost)
Definition: access_log.cc:199
Definition: HttpRequest.h:49
CbcPointer< ConnStateData > clientConnectionManager
Definition: HttpRequest.h:232
void prepForDirect()
get ready to be sent directly to an origin server, excluding originserver
Definition: HttpRequest.cc:456
void prepForPeering(const CachePeer &peer)
get ready to be sent to the given cache_peer, including originserver
Definition: HttpRequest.cc:446
Http::StatusCode status() const
retrieve the status code for this status line
Definition: StatusLine.h:45
Definition: HttpTunnelerAnswer.h:30
SBuf leftovers
peer-generated bytes after a positive answer (or empty)
Definition: HttpTunnelerAnswer.h:42
Definition: HttpTunneler.h:33
void start(const JobPointer &aJob, const AsyncCall::Pointer &aCallback)
starts waiting for the given job to call the given callback
Definition: JobWait.h:69
Definition: LogTags.h:18
Definition: pconn.h:113
bool subscribed
whether noteDestination() and noteDestinationsEnd() calls are allowed
Definition: PeerSelectState.h:46
void startSelectingDestinations(HttpRequest *request, const AccessLogEntry::Pointer &ale, StoreEntry *entry)
Definition: peer_select.cc:335
bool ftpNative
carries a representation of an FTP command [received on ftp_port]
Definition: RequestFlags.h:112
Definition: ResolvedPeers.h:34
void reinstatePath(const PeerConnectionPointer &)
Definition: ResolvedPeers.cc:23
bool notificationPending
whether HappyConnOpener::noteCandidatesChange() is scheduled to fire
Definition: ResolvedPeers.h:85
bool destinationsFinalized
whether all of the available candidate paths received from DNS
Definition: ResolvedPeers.h:82
void addPath(const Comm::ConnectionPointer &)
add a candidate path to try after all the existing paths
Definition: ResolvedPeers.cc:46
A simple PeerConnector for SSL/TLS cache_peers. No SslBump capabilities.
Definition: BlindPeerConnector.h:22
Definition: EncryptorAnswer.h:22
bool tunneled
whether we spliced the connections instead of negotiating encryption
Definition: EncryptorAnswer.h:33
Definition: PeerConnector.h:49
bool noteFwdPconnUse
hack: whether the connection requires fwdPconnPool->noteUses()
Definition: PeerConnector.h:62
struct SquidConfig::@107 accessList
int tproxy_uses_indirect_client
Definition: SquidConfig.h:330
struct SquidConfig::@106 onoff
acl_access * serverPconnForNonretriable
Definition: SquidConfig.h:405
struct SquidConfig::@93 Timeout
A PeerConnector for HTTP origin servers. Capable of SslBumping.
Definition: PeekingPeerConnector.h:20
Definition: Store.h:42
void completeSuccessfully(const char *whyWeAreSureWeStoredTheWholeReply)
Definition: store.cc:1003
void unregisterAbortCallback(const char *reason)
Definition: store.cc:1475
void completeTruncated(const char *whyWeConsiderTheReplyTruncated)
Definition: store.cc:1010
void registerAbortCallback(const AsyncCall::Pointer &)
notify the StoreEntry writer of a 3rd-party initiated StoreEntry abort
Definition: store.cc:1467
Definition: QosConfig.h:45
Definition: QosConfig.h:31
AsyncCall::Pointer comm_add_close_handler(int fd, CLCB *handler, void *data)
Definition: comm.cc:949
void comm_remove_close_handler(int fd, CLCB *handler, void *data)
Definition: comm.cc:978
err_type aclGetDenyInfoPage(AclDenyInfoList **head, const char *name, int redirect_allowed)
Definition: Gadgets.cc:39
void errorAppendEntry(StoreEntry *entry, ErrorState *err)
Definition: errorpage.cc:717
void internalStart(const Comm::ConnectionPointer &clientConn, HttpRequest *request, StoreEntry *entry, const AccessLogEntry::Pointer &ale)
Definition: internal.cc:33
bool IsReforwardableStatus(StatusCode)
whether to send the request to another peer based on the current response status code
Definition: StatusCode.cc:281
const char * StatusCodeString(const Http::StatusCode status)
Definition: StatusCode.cc:15
void getTosFromServer(const Comm::ConnectionPointer &server, fde *clientFde)
Definition: QosConfig.cc:43
int setSockTos(const Comm::ConnectionPointer &conn, tos_t tos)
Definition: QosConfig.cc:570
int setSockNfmark(const Comm::ConnectionPointer &conn, nfmark_t mark)
Definition: QosConfig.cc:602
nfmark_t getNfConnmark(const Comm::ConnectionPointer &conn, const ConnectionDirection connDir)
Definition: QosConfig.cc:146
void RegisterAction(char const *action, char const *desc, OBJH *handler, int pw_req_flag, int atomic)
Definition: Registration.cc:16
void urnStart(HttpRequest *r, StoreEntry *e, const AccessLogEntryPointer &ale)
Definition: urn.cc:204