This is an automated email from the ASF dual-hosted git repository.
bcall pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new a92d688 Move the direct self loop check later to
HttpSM::do_http_server_open just before connection upstream. (#7069)
a92d688 is described below
commit a92d688e580aa34f3ed04d02c1eb80bd48518c96
Author: Alan M. Carroll <[email protected]>
AuthorDate: Thu Aug 6 17:48:20 2020 -0500
Move the direct self loop check later to HttpSM::do_http_server_open just
before connection upstream. (#7069)
This closed #7052
(cherry picked from commit 07dad5f1e4308393018314ef61edaa206f724eb4)
---
proxy/http/HttpSM.cc | 6 ++++++
proxy/http/HttpTransact.cc | 22 ++++++++++------------
proxy/http/HttpTransact.h | 2 +-
3 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
index 6ccd88f..698f9c1 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -4898,6 +4898,12 @@ HttpSM::do_http_server_open(bool raw)
}
}
+ // Check for self loop.
+ if (HttpTransact::will_this_request_self_loop(&t_state)) {
+ call_transact_and_set_next_state(HttpTransact::SelfLoop);
+ return;
+ }
+
// If this is not a raw connection, we try to get a session from the
// shared session pool. Raw connections are for SSLs tunnel and
// require a new connection
diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc
index cdb4cf6..64046b0 100644
--- a/proxy/http/HttpTransact.cc
+++ b/proxy/http/HttpTransact.cc
@@ -795,6 +795,16 @@ HttpTransact::Forbidden(State *s)
}
void
+HttpTransact::SelfLoop(State *s)
+{
+ TxnDebug("http_trans", "[Loop]"
+ "Request will selfloop.");
+ bootstrap_state_variables_from_request(s, &s->hdr_info.client_request);
+ build_error_response(s, HTTP_STATUS_BAD_REQUEST, "Direct self loop
detected", "request#cycle_detected");
+ TRANSACT_RETURN(SM_ACTION_SEND_ERROR_CACHE_NOOP, nullptr);
+}
+
+void
HttpTransact::TooEarly(State *s)
{
TxnDebug("http_trans", "[TooEarly]"
@@ -1807,17 +1817,6 @@ HttpTransact::OSDNSLookup(State *s)
TRANSACT_RETURN(SM_ACTION_SEND_ERROR_CACHE_NOOP, nullptr);
}
- // detect whether we are about to self loop. the client may have
- // specified the proxy as the origin server (badness).
- // Check if this procedure is already done - YTS Team, yamsat
- if (!s->request_will_not_selfloop) {
- if (will_this_request_self_loop(s)) {
- TxnDebug("http_trans", "[OSDNSLookup] request will selfloop - bailing
out");
- SET_VIA_STRING(VIA_DETAIL_TUNNEL, VIA_DETAIL_TUNNEL_NO_FORWARD);
- TRANSACT_RETURN(SM_ACTION_SEND_ERROR_CACHE_NOOP, nullptr);
- }
- }
-
if (!s->dns_info.lookup_success) {
// maybe the name can be expanded (e.g cnn -> www.cnn.com)
HostNameExpansionError_t host_name_expansion = try_to_expand_host_name(s);
@@ -6693,7 +6692,6 @@ HttpTransact::will_this_request_self_loop(State *s)
via_field = via_field->m_next_dup;
}
}
- s->request_will_not_selfloop = true;
return false;
}
diff --git a/proxy/http/HttpTransact.h b/proxy/http/HttpTransact.h
index 526ffb0..9ae15e3 100644
--- a/proxy/http/HttpTransact.h
+++ b/proxy/http/HttpTransact.h
@@ -687,7 +687,6 @@ public:
bool force_dns = false;
MgmtByte cache_open_write_fail_action = 0;
bool is_revalidation_necessary = false; // Added to check if
revalidation is necessary - YTS Team, yamsat
- bool request_will_not_selfloop = false; // To determine if process
done - YTS Team, yamsat
ConnectionAttributes client_info;
ConnectionAttributes parent_info;
ConnectionAttributes server_info;
@@ -944,6 +943,7 @@ public:
static void BadRequest(State *s);
static void Forbidden(State *s);
static void TooEarly(State *s);
+ static void SelfLoop(State *s);
static void PostActiveTimeoutResponse(State *s);
static void PostInactiveTimeoutResponse(State *s);
static void DecideCacheLookup(State *s);