On Aug 1, 2013, at 1:46 PM, [email protected] wrote:
> Updated Branches:
> refs/heads/master cecc082d4 -> 7485e0b5f
>
>
> TS-1255 Add Req/Resp max header size to be overridable
Would it be more robust to use a lookup table for the overridable value types?
static const
struct {
OverridableDataType o_type;
size_t o_offset;
} overridable[] = {
/* TS_CONFIG_URL_REMAP_PRISTINE_HOST_HDR */
{ OVERRIDABLE_TYPE_BYTE, offsetof(OverridableHttpConfigParams,
maintain_pristine_host_hdr},
...
};
void*
_conf_to_memberp(TSOverridableConfigKey conf, HttpSM* sm, OverridableDataType
*typep)
{
*typep = overridable[conf].o_type;
return ((uint8_t *)(sm->t_state.txn_conf)) + overridable[conf].o_offset;
}
>
>
> Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
> Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/b0e7c2ab
> Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/b0e7c2ab
> Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/b0e7c2ab
>
> Branch: refs/heads/master
> Commit: b0e7c2ab4a513ff6c0e3f79f65a0ef523fee7882
> Parents: 2f98469
> Author: Leif Hedstrom <[email protected]>
> Authored: Sun Jul 28 22:50:14 2013 +0200
> Committer: Leif Hedstrom <[email protected]>
> Committed: Thu Aug 1 22:42:48 2013 +0200
>
> ----------------------------------------------------------------------
> proxy/InkAPI.cc | 12 ++++++++++++
> proxy/InkAPITest.cc | 4 +++-
> proxy/api/ts/ts.h.in | 4 +++-
> proxy/http/HttpConfig.cc | 12 ++++++------
> proxy/http/HttpConfig.h | 15 +++++++--------
> proxy/http/HttpSM.cc | 4 ++--
> 6 files changed, 33 insertions(+), 18 deletions(-)
> ----------------------------------------------------------------------
>
>
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b0e7c2ab/proxy/InkAPI.cc
> ----------------------------------------------------------------------
> diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc
> index 1ed9933..99c833d 100644
> --- a/proxy/InkAPI.cc
> +++ b/proxy/InkAPI.cc
> @@ -7577,6 +7577,14 @@ _conf_to_memberp(TSOverridableConfigKey conf, HttpSM*
> sm, OverridableDataType *t
> typ = OVERRIDABLE_TYPE_INT;
> ret = &sm->t_state.txn_conf->default_buffer_water_mark;
> break;
> + case TS_CONFIG_HTTP_REQUEST_HEADER_MAX_SIZE:
> + typ = OVERRIDABLE_TYPE_INT;
> + ret = &sm->t_state.txn_conf->request_hdr_max_size;
> + break;
> + case TS_CONFIG_HTTP_RESPONSE_HEADER_MAX_SIZE:
> + typ = OVERRIDABLE_TYPE_INT;
> + ret = &sm->t_state.txn_conf->response_hdr_max_size;
> + break;
>
> // This helps avoiding compiler warnings, yet detect unhandled enum
> members.
> case TS_CONFIG_NULL:
> @@ -7898,6 +7906,8 @@ TSHttpTxnConfigFind(const char* name, int length,
> TSOverridableConfigKey *conf,
> case 'e':
> if (!strncmp(name, "proxy.config.http.anonymize_remove_cookie", length))
> cnf = TS_CONFIG_HTTP_ANONYMIZE_REMOVE_COOKIE;
> + else if (!strncmp(name, "proxy.config.http.request_header_max_size",
> length))
> + cnf = TS_CONFIG_HTTP_REQUEST_HEADER_MAX_SIZE;
> break;
> case 'r':
> if (!strncmp(name, "proxy.config.http.insert_response_via_str", length))
> @@ -7917,6 +7927,8 @@ TSHttpTxnConfigFind(const char* name, int length,
> TSOverridableConfigKey *conf,
> case 'e':
> if (!strncmp(name, "proxy.config.http.cache.when_to_revalidate",
> length))
> cnf = TS_CONFIG_HTTP_CACHE_WHEN_TO_REVALIDATE;
> + else if (!strncmp(name, "proxy.config.http.response_header_max_size",
> length))
> + cnf = TS_CONFIG_HTTP_RESPONSE_HEADER_MAX_SIZE;
> break;
> case 'r':
> if (!strncmp(name, "proxy.config.http.anonymize_remove_referer",
> length))
>
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b0e7c2ab/proxy/InkAPITest.cc
> ----------------------------------------------------------------------
> diff --git a/proxy/InkAPITest.cc b/proxy/InkAPITest.cc
> index 42de90c..85cc589 100644
> --- a/proxy/InkAPITest.cc
> +++ b/proxy/InkAPITest.cc
> @@ -7399,7 +7399,9 @@ const char
> *SDK_Overridable_Configs[TS_CONFIG_LAST_ENTRY] = {
> "proxy.config.http.cache.range.lookup",
> "proxy.config.http.normalize_ae_gzip",
> "proxy.config.http.default_buffer_size",
> - "proxy.config.http.default_buffer_water_mark"
> + "proxy.config.http.default_buffer_water_mark",
> + "proxy.config.http.request_header_max_size",
> + "proxy.config.http.response_header_max_size"
> };
>
> REGRESSION_TEST(SDK_API_OVERRIDABLE_CONFIGS) (RegressionTest * test, int /*
> atype ATS_UNUSED */, int *pstatus)
>
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b0e7c2ab/proxy/api/ts/ts.h.in
> ----------------------------------------------------------------------
> diff --git a/proxy/api/ts/ts.h.in b/proxy/api/ts/ts.h.in
> index b9cd558..47eeaf6 100644
> --- a/proxy/api/ts/ts.h.in
> +++ b/proxy/api/ts/ts.h.in
> @@ -675,7 +675,9 @@ extern "C"
> TS_CONFIG_HTTP_NORMALIZE_AE_GZIP,
> TS_CONFIG_HTTP_DEFAULT_BUFFER_SIZE,
> TS_CONFIG_HTTP_DEFAULT_BUFFER_WATER_MARK,
> - TS_CONFIG_LAST_ENTRY,
> + TS_CONFIG_HTTP_REQUEST_HEADER_MAX_SIZE,
> + TS_CONFIG_HTTP_RESPONSE_HEADER_MAX_SIZE,
> + TS_CONFIG_LAST_ENTRY
> } TSOverridableConfigKey;
>
> /* The TASK pool of threads is the primary method of off-loading
> continuations from the
>
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b0e7c2ab/proxy/http/HttpConfig.cc
> ----------------------------------------------------------------------
> diff --git a/proxy/http/HttpConfig.cc b/proxy/http/HttpConfig.cc
> index b4db289..c8c0abc 100644
> --- a/proxy/http/HttpConfig.cc
> +++ b/proxy/http/HttpConfig.cc
> @@ -1291,9 +1291,8 @@ HttpConfig::startup()
>
> HttpEstablishStaticConfigStringAlloc(c.connect_ports_string,
> "proxy.config.http.connect_ports");
>
> - HttpEstablishStaticConfigLongLong(c.request_hdr_max_size,
> "proxy.config.http.request_header_max_size");
> -
> - HttpEstablishStaticConfigLongLong(c.response_hdr_max_size,
> "proxy.config.http.response_header_max_size");
> + HttpEstablishStaticConfigLongLong(c.oride.request_hdr_max_size,
> "proxy.config.http.request_header_max_size");
> + HttpEstablishStaticConfigLongLong(c.oride.response_hdr_max_size,
> "proxy.config.http.response_header_max_size");
>
> HttpEstablishStaticConfigByte(c.push_method_enabled,
> "proxy.config.http.push_method_enabled");
>
> @@ -1561,9 +1560,10 @@ HttpConfig::reconfigure()
> params->connect_ports_string = ats_strdup(m_master.connect_ports_string);
> params->connect_ports = parse_ports_list(params->connect_ports_string);
>
> - params->request_hdr_max_size = m_master.request_hdr_max_size;
> - params->response_hdr_max_size = m_master.response_hdr_max_size;
> - params->push_method_enabled = INT_TO_BOOL(m_master.push_method_enabled);
> + params->oride.request_hdr_max_size = m_master.oride.request_hdr_max_size;
> + params->oride.response_hdr_max_size = m_master.oride.response_hdr_max_size;
> +
> +params->push_method_enabled = INT_TO_BOOL(m_master.push_method_enabled);
>
> params->reverse_proxy_enabled = INT_TO_BOOL(m_master.reverse_proxy_enabled);
> params->url_remap_required = INT_TO_BOOL(m_master.url_remap_required);
>
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b0e7c2ab/proxy/http/HttpConfig.h
> ----------------------------------------------------------------------
> diff --git a/proxy/http/HttpConfig.h b/proxy/http/HttpConfig.h
> index 27a96e7..de47b94 100644
> --- a/proxy/http/HttpConfig.h
> +++ b/proxy/http/HttpConfig.h
> @@ -414,6 +414,7 @@ struct OverridableHttpConfigParams {
> negative_caching_lifetime(1800), normalize_ae_gzip(0),
> sock_recv_buffer_size_out(0), sock_send_buffer_size_out(0),
> sock_option_flag_out(0),
> sock_packet_mark_out(0), sock_packet_tos_out(0),
> server_tcp_init_cwnd(0),
> + request_hdr_max_size(131072), response_hdr_max_size(131072),
> cache_heuristic_min_lifetime(3600), cache_heuristic_max_lifetime(86400),
> cache_guaranteed_min_lifetime(0),
> cache_guaranteed_max_lifetime(31536000), cache_max_stale_age(604800),
> keep_alive_no_activity_timeout_in(115),
> keep_alive_no_activity_timeout_out(120),
> @@ -524,6 +525,12 @@ struct OverridableHttpConfigParams {
> ///////////////////////////////
> MgmtInt server_tcp_init_cwnd;
>
> + ///////////////
> + // Hdr Limit //
> + ///////////////
> + MgmtInt request_hdr_max_size;
> + MgmtInt response_hdr_max_size;
> +
> /////////////////////
> // cache variables //
> /////////////////////
> @@ -702,12 +709,6 @@ public:
> char *connect_ports_string;
> HttpConfigPortRange *connect_ports;
>
> - ///////////////
> - // Hdr Limit //
> - ///////////////
> - MgmtInt request_hdr_max_size;
> - MgmtInt response_hdr_max_size;
> -
> //////////
> // Push //
> //////////
> @@ -923,8 +924,6 @@ HttpConfigParams::HttpConfigParams()
> cache_when_to_add_no_cache_to_msie_requests(-1),
> connect_ports_string(NULL),
> connect_ports(NULL),
> - request_hdr_max_size(131072),
> - response_hdr_max_size(131072),
> push_method_enabled(0),
> referer_filter_enabled(0),
> referer_format_redirect(0),
>
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b0e7c2ab/proxy/http/HttpSM.cc
> ----------------------------------------------------------------------
> diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
> index 5647f22..5b879bc 100644
> --- a/proxy/http/HttpSM.cc
> +++ b/proxy/http/HttpSM.cc
> @@ -720,7 +720,7 @@ HttpSM::state_read_client_request_header(int event, void
> *data)
> client_request_hdr_bytes += bytes_used;
>
> // Check to see if we are over the hdr size limit
> - if (client_request_hdr_bytes >
> t_state.http_config_param->request_hdr_max_size) {
> + if (client_request_hdr_bytes > t_state.txn_conf->request_hdr_max_size) {
> DebugSM("http", "client header bytes were over max header size; treating
> as a bad request");
> state = PARSE_ERROR;
> }
> @@ -1776,7 +1776,7 @@ HttpSM::state_read_server_response_header(int event,
> void *data)
> state = PARSE_ERROR;
> }
> // Check to see if we are over the hdr size limit
> - if (server_response_hdr_bytes >
> t_state.http_config_param->response_hdr_max_size) {
> + if (server_response_hdr_bytes > t_state.txn_conf->response_hdr_max_size) {
> state = PARSE_ERROR;
> }
>
>