Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ proxy/config/records.config.default
proxy/config/storage.config.default
proxy/hdrs/test_mime
proxy/http2/test_Huffmancode
proxy/http2/test_Http2DependencyTree

plugins/header_rewrite/header_rewrite_test
plugins/experimental/esi/*_test
Expand Down
5 changes: 5 additions & 0 deletions doc/admin-guide/files/records.config.en.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3057,6 +3057,11 @@ HTTP/2 Configuration
that the sender is prepared to accept blocks. The default value, which is
the unsigned int maximum value in Traffic Server, implies unlimited size.

.. ts:cv:: CONFIG proxy.config.http2.stream_priority_enabled INT 0
:reloadable:

Enable the experimental HTTP/2 Stream Priority feature.

SPDY Configuration
==================

Expand Down
4 changes: 3 additions & 1 deletion mgmt/RecordsConfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1974,7 +1974,9 @@ static const RecordElement RecordsConfig[] =
//# HTTP/2 global configuration.
//#
//############
{RECT_CONFIG, "proxy.config.http2.enabled", RECD_INT, "0", RECU_RESTART_TM, RR_NULL, RECC_INT, "[0-1]", RECA_NULL}
{RECT_CONFIG, "proxy.config.http2.enabled", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_INT, "[0-1]", RECA_NULL}
,
{RECT_CONFIG, "proxy.config.http2.stream_priority_enabled", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_INT, "[0-1]", RECA_NULL}
,
{RECT_CONFIG, "proxy.config.http2.max_concurrent_streams_in", RECD_INT, "100", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL}
,
Expand Down
12 changes: 9 additions & 3 deletions proxy/http2/HTTP2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -335,15 +335,19 @@ http2_parse_headers_parameter(IOVec iov, Http2HeadersParameter &params)
}

bool
http2_parse_priority_parameter(IOVec iov, Http2Priority &params)
http2_parse_priority_parameter(IOVec iov, Http2Priority &priority)
{
byte_pointer ptr(iov.iov_base);
byte_addressable_value<uint32_t> dependency;

memcpy_and_advance(dependency.bytes, ptr);
memcpy_and_advance(params.weight, ptr);

params.stream_dependency = ntohl(dependency.value);
priority.exclusive_flag = dependency.bytes[0] & 0x80;

dependency.bytes[0] &= 0x7f; // Clear the highest bit for exclusive flag
priority.stream_dependency = ntohl(dependency.value);

memcpy_and_advance(priority.weight, ptr);

return true;
}
Expand Down Expand Up @@ -666,6 +670,7 @@ uint32_t Http2::max_concurrent_streams_in = 100;
uint32_t Http2::min_concurrent_streams_in = 10;
uint32_t Http2::max_active_streams_in = 0;
bool Http2::throttling = false;
uint32_t Http2::stream_priority_enabled = 0;
uint32_t Http2::initial_window_size = 1048576;
uint32_t Http2::max_frame_size = 16384;
uint32_t Http2::header_table_size = 4096;
Expand All @@ -681,6 +686,7 @@ Http2::init()
REC_EstablishStaticConfigInt32U(max_concurrent_streams_in, "proxy.config.http2.max_concurrent_streams_in");
REC_EstablishStaticConfigInt32U(min_concurrent_streams_in, "proxy.config.http2.min_concurrent_streams_in");
REC_EstablishStaticConfigInt32U(max_active_streams_in, "proxy.config.http2.max_active_streams_in");
REC_EstablishStaticConfigInt32U(stream_priority_enabled, "proxy.config.http2.stream_priority_enabled");
REC_EstablishStaticConfigInt32U(initial_window_size, "proxy.config.http2.initial_window_size_in");
REC_EstablishStaticConfigInt32U(max_frame_size, "proxy.config.http2.max_frame_size");
REC_EstablishStaticConfigInt32U(header_table_size, "proxy.config.http2.header_table_size");
Expand Down
16 changes: 14 additions & 2 deletions proxy/http2/HTTP2.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ const uint32_t HTTP2_MAX_FRAME_SIZE = 16384;
const uint32_t HTTP2_HEADER_TABLE_SIZE = 4096;
const uint32_t HTTP2_MAX_HEADER_LIST_SIZE = UINT_MAX;

// [RFC 7540] 5.3.5 Default Priorities
// The RFC says weight value is 1 to 256, but the value in TS is between 0 to 255
// to use uint8_t. So the default weight is 16 minus 1.
const uint32_t HTTP2_PRIORITY_DEFAULT_STREAM_DEPENDENCY = 0;
const uint8_t HTTP2_PRIORITY_DEFAULT_WEIGHT = 15;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you referenced the RFC here:

"In both cases, streams are assigned a default weight of 16".

So, why is it 15? :)

Copy link
Contributor Author

@masaori335 masaori335 May 12, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The RFC says below in 6.2 HEADERS and 6.3 PRIORITY

Weight: An unsigned 8-bit integer representing a priority weight for the stream (see Section 5.3). Add one to the value to obtain a weight between 1 and 256.

We're not plus 1 to use uint8_t, so the default value become 16 - 1.
I'll add comments to describe this.


// Statistics
enum {
HTTP2_STAT_CURRENT_CLIENT_SESSION_COUNT, // Current # of active HTTP2
Expand Down Expand Up @@ -253,9 +259,14 @@ struct Http2SettingsParameter {

// [RFC 7540] 6.3 PRIORITY Format
struct Http2Priority {
Http2Priority() : stream_dependency(0), weight(15) {}
uint32_t stream_dependency;
Http2Priority()
: exclusive_flag(false), weight(HTTP2_PRIORITY_DEFAULT_WEIGHT), stream_dependency(HTTP2_PRIORITY_DEFAULT_STREAM_DEPENDENCY)
{
}

bool exclusive_flag;
uint8_t weight;
uint32_t stream_dependency;
};

// [RFC 7540] 6.2 HEADERS Format
Expand Down Expand Up @@ -348,6 +359,7 @@ class Http2
static uint32_t min_concurrent_streams_in;
static uint32_t max_active_streams_in;
static bool throttling;
static uint32_t stream_priority_enabled;
static uint32_t initial_window_size;
static uint32_t max_frame_size;
static uint32_t header_table_size;
Expand Down
Loading