You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by am...@apache.org on 2010/10/21 07:30:51 UTC
svn commit: r1025832 - in /trafficserver/traffic/branches/wccp/proxy:
ControlMatcher.cc hdrs/HTTP.cc hdrs/HTTP.h http2/HttpSM.cc
http2/HttpTransact.cc
Author: amc
Date: Thu Oct 21 05:30:51 2010
New Revision: 1025832
URL: http://svn.apache.org/viewvc?rev=1025832&view=rev
Log:
Further fixes for DNS avoidance on transparent connections.
Modified:
trafficserver/traffic/branches/wccp/proxy/ControlMatcher.cc
trafficserver/traffic/branches/wccp/proxy/hdrs/HTTP.cc
trafficserver/traffic/branches/wccp/proxy/hdrs/HTTP.h
trafficserver/traffic/branches/wccp/proxy/http2/HttpSM.cc
trafficserver/traffic/branches/wccp/proxy/http2/HttpTransact.cc
Modified: trafficserver/traffic/branches/wccp/proxy/ControlMatcher.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/wccp/proxy/ControlMatcher.cc?rev=1025832&r1=1025831&r2=1025832&view=diff
==============================================================================
--- trafficserver/traffic/branches/wccp/proxy/ControlMatcher.cc (original)
+++ trafficserver/traffic/branches/wccp/proxy/ControlMatcher.cc Thu Oct 21 05:30:51 2010
@@ -57,7 +57,7 @@
char *
HttpRequestData::get_string()
{
- char *str = hdr->url_get()->string_get(NULL);
+ char *str = hdr->url_string_get();
unescapifyStr(str);
return str;
}
@@ -369,12 +369,12 @@ template<class Data, class Result> void
for (int i = 0; i < num_el; i++) {
r = pcre_exec(re_array[i], NULL, url_str, strlen(url_str), 0, 0, NULL, 0);
- if (r != -1) {
+ if (r > -1) {
Debug("matcher", "%s Matched %s with regex at line %d", matcher_name, url_str, data_array[i].line_num);
data_array[i].UpdateMatch(result, rdata);
- } else {
+ } else if (r < -1) {
// An error has occured
- Warning("error matching regex at line %d", data_array[i].line_num);
+ Warning("Error [%d] matching regex at line %d.", r, data_array[i].line_num);
}
}
Modified: trafficserver/traffic/branches/wccp/proxy/hdrs/HTTP.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/wccp/proxy/hdrs/HTTP.cc?rev=1025832&r1=1025831&r2=1025832&view=diff
==============================================================================
--- trafficserver/traffic/branches/wccp/proxy/hdrs/HTTP.cc (original)
+++ trafficserver/traffic/branches/wccp/proxy/hdrs/HTTP.cc Thu Oct 21 05:30:51 2010
@@ -1516,6 +1516,53 @@ HTTPHdr::set_url_target_from_host_field(
}
}
+// Very ugly, but a proper implementation will require
+// rewriting the URL class and all of its clients so that
+// clients access the URL through the HTTP header instance
+// unless they really need low level access. The header would
+// need to either keep two versions of the URL (pristine
+// and effective) or URl would have to provide access to
+// the URL printer.
+char*
+HTTPHdr::url_string_get(Arena* arena, int* length) {
+ char *zret = 0;
+
+ if (m_url_cached.valid()) {
+ URLImpl* ui = m_url_cached.m_url_impl;
+ bool should_reset_host = false;
+ bool should_reset_port = false;
+ char port_buff[10];
+
+ this->_test_and_fill_target_cache();
+
+ /* Get dirty. We reach in to the URL implementation to
+ set the host and port if
+ 1) They are not already set and
+ 2) The values were in a HTTP header field.
+ */
+
+ if (!m_target_in_url && m_host_length) {
+ assert(0 == ui->m_ptr_host); // shouldn't be non-zero if not in URL.
+ ui->m_ptr_host = m_host;
+ ui->m_len_host = m_host_length;
+ should_reset_host = true;
+ }
+
+ if (0 == m_url_cached.port_get_raw() && m_port_in_header) {
+ assert(0 == ui->m_ptr_port); // shouldn't be set if not in URL.
+ ui->m_ptr_port = port_buff;
+ ui->m_len_port = sprintf(port_buff, "%.5d", m_port);
+ should_reset_port = true;
+ }
+
+ zret = m_url_cached.string_get(arena, length);
+ if (should_reset_host) { ui->m_ptr_host = 0; ui->m_len_host = 0; }
+ if (should_reset_port) { ui->m_ptr_port = 0; ui->m_len_port = 0; }
+ }
+
+ return zret;
+}
+
/***********************************************************************
* *
* M A R S H A L I N G *
Modified: trafficserver/traffic/branches/wccp/proxy/hdrs/HTTP.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/wccp/proxy/hdrs/HTTP.h?rev=1025832&r1=1025831&r2=1025832&view=diff
==============================================================================
--- trafficserver/traffic/branches/wccp/proxy/hdrs/HTTP.h (original)
+++ trafficserver/traffic/branches/wccp/proxy/hdrs/HTTP.h Thu Oct 21 05:30:51 2010
@@ -572,6 +572,18 @@ public:
URL *url_get() const;
URL *url_get(URL * url);
+ /** Get a string with the effective URL in it.
+ If @a length is not @c NULL then the length of the string
+ is stored in pointed to @c int.
+
+ Note that this can be different from getting the @c URL
+ and invoking @c URL::string_get if the host is in a header
+ field and not explicitly in the URL.
+ */
+ char* url_string_get(
+ Arena* arena = 0, ///< Arena to use, or @c malloc if NULL.
+ int* length = 0 ///< Store string length here.
+ );
void url_set(URL * url);
void url_set_as_server_url(URL * url);
Modified: trafficserver/traffic/branches/wccp/proxy/http2/HttpSM.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/wccp/proxy/http2/HttpSM.cc?rev=1025832&r1=1025831&r2=1025832&view=diff
==============================================================================
--- trafficserver/traffic/branches/wccp/proxy/http2/HttpSM.cc (original)
+++ trafficserver/traffic/branches/wccp/proxy/http2/HttpSM.cc Thu Oct 21 05:30:51 2010
@@ -3843,11 +3843,10 @@ HttpSM::do_hostdb_lookup()
}
*/
- milestones.dns_lookup_begin = ink_get_hrtime();
-
ink_assert(t_state.dns_info.lookup_name != NULL);
ink_assert(pending_action == NULL);
+ milestones.dns_lookup_begin = ink_get_hrtime();
bool use_srv_records = HttpConfig::m_master.srv_enabled;
if (use_srv_records) {
@@ -6690,6 +6689,7 @@ HttpSM::set_next_state()
case HttpTransact::DNS_LOOKUP:
{
+ uint32 addr;
if (url_remap_mode == 2 && t_state.first_dns_lookup) {
Debug("cdn", "Skipping DNS Lookup");
@@ -6698,6 +6698,21 @@ HttpSM::set_next_state()
t_state.first_dns_lookup = false;
call_transact_and_set_next_state(HttpTransact::HandleFiltering);
break;
+ } else if (t_state.http_config_param->use_client_target_addr
+ && !t_state.url_remap_success
+ && t_state.client_info.is_transparent
+ && 0 != (addr = t_state.state_machine->ua_session->get_netvc()->get_local_ip())
+ ) {
+ /* If the connection is client side transparent and the URL
+ was not remapped, we can use the client destination IP
+ address instead of doing a DNS lookup. This is controlled
+ by the 'use_client_target_addr' configuration parameter.
+ */
+ Debug("dns", "[HttpTransact::HandleRequest] Skipping DNS lookup for client supplied target %u.%u.%u.%u.\n", PRINT_IP(addr));
+ t_state.host_db_info.ip() = addr;
+ t_state.dns_info.lookup_success = true;
+ call_transact_and_set_next_state(NULL);
+ break;
}
HTTP_SM_SET_DEFAULT_HANDLER(&HttpSM::state_hostdb_lookup);
Modified: trafficserver/traffic/branches/wccp/proxy/http2/HttpTransact.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/wccp/proxy/http2/HttpTransact.cc?rev=1025832&r1=1025831&r2=1025832&view=diff
==============================================================================
--- trafficserver/traffic/branches/wccp/proxy/http2/HttpTransact.cc (original)
+++ trafficserver/traffic/branches/wccp/proxy/http2/HttpTransact.cc Thu Oct 21 05:30:51 2010
@@ -1178,21 +1178,8 @@ HttpTransact::HandleRequest(State * s)
if (handle_trace_and_options_requests(s, &s->hdr_info.client_request)) {
TRANSACT_RETURN(PROXY_INTERNAL_CACHE_NOOP, NULL);
}
- /* If the connection is client side transparent and the URL was not
- remapped, we can use the client destination IP address instead of
- doing a DNS lookup. This is controlled by the 'use_client_target_addr'
- configuration parameter.
- */
- if (s->http_config_param->use_client_target_addr
- && !s->url_remap_success
- && s->client_info.is_transparent
- ) {
- uint32 addr = s->state_machine->ua_session->get_netvc()->get_local_ip();
- Debug("http_trans", "[HttpTransact::HandleRequest] Skipping DNS lookup for client supplied target %u.%u.%u.%u.\n", PRINT_IP(addr));
- s->request_data.dest_ip = addr;
- s->server_info.ip = addr;
- s->force_dns = 0;
- } else if (s->http_config_param->no_dns_forward_to_parent
+
+ if (s->http_config_param->no_dns_forward_to_parent
&& s->scheme != URL_WKSIDX_HTTPS
&& strcmp(s->server_info.name, "127.0.0.1") != 0
) {