summaryrefslogtreecommitdiffstats
path: root/net/spdy/spdy_framer.cc
diff options
context:
space:
mode:
authorbnc <bnc@chromium.org>2014-10-24 11:40:01 -0700
committerCommit bot <commit-bot@chromium.org>2014-10-24 18:40:55 +0000
commit0e2deda3f0c59c8fc18323ede48a552bef341c24 (patch)
treed93fbc8d74a43e737e0794f3b96b8ec642d66ca5 /net/spdy/spdy_framer.cc
parent74ebb86d7d2db716e905a67a161fa3e59b3445bd (diff)
downloadchromium_src-0e2deda3f0c59c8fc18323ede48a552bef341c24.zip
chromium_src-0e2deda3f0c59c8fc18323ede48a552bef341c24.tar.gz
chromium_src-0e2deda3f0c59c8fc18323ede48a552bef341c24.tar.bz2
Code cleanup of control frame size enforcement.
Introduce kMaxControlFrameSize global const for fragmenting outgoing frames. Get rid of GetControlFrameBufferMaxSize() and GetHeaderFragmentMaxSize() inline members. Motivation is to converge with server side code. Only functional change is to decrease control frame fragment size to 1 kB for SPDY. Since frame headers are tiny, this causes little overhead. Also, incoming control frame size limit is now properly enforced (there was an incorrect offset by frame header size before). This CL lands server change 78267288 among other modifications. Review URL: https://codereview.chromium.org/675863002 Cr-Commit-Position: refs/heads/master@{#301154}
Diffstat (limited to 'net/spdy/spdy_framer.cc')
-rw-r--r--net/spdy/spdy_framer.cc16
1 files changed, 10 insertions, 6 deletions
diff --git a/net/spdy/spdy_framer.cc b/net/spdy/spdy_framer.cc
index fae97e8..70a6494 100644
--- a/net/spdy/spdy_framer.cc
+++ b/net/spdy/spdy_framer.cc
@@ -77,6 +77,8 @@ const size_t kPadLengthFieldSize = 1;
const SpdyStreamId SpdyFramer::kInvalidStream = static_cast<SpdyStreamId>(-1);
const size_t SpdyFramer::kHeaderDataChunkMaxSize = 1024;
+// We fragment sent control frames at smaller payload boundaries.
+const size_t SpdyFramer::kMaxControlFrameSize = 1024;
// The size of the control frame buffer. Must be >= the minimum size of the
// largest control frame, which is SYN_STREAM. See GetSynStreamMinimumSize() for
// calculation details.
@@ -163,6 +165,9 @@ SpdyFramer::SpdyFramer(SpdyMajorVersion version)
end_stream_when_done_(false) {
DCHECK_GE(spdy_version_, SPDY_MIN_VERSION);
DCHECK_LE(spdy_version_, SPDY_MAX_VERSION);
+ DCHECK_LE(kMaxControlFrameSize,
+ SpdyConstants::GetFrameMaximumSize(spdy_version_) +
+ SpdyConstants::GetControlFrameHeaderSize(spdy_version_));
Reset();
}
@@ -1049,7 +1054,9 @@ void SpdyFramer::ProcessControlFrameHeader(uint16 control_frame_type_field) {
return;
}
- if (current_frame_length_ > GetControlFrameBufferMaxSize()) {
+ if (current_frame_length_ >
+ SpdyConstants::GetFrameMaximumSize(protocol_version()) +
+ SpdyConstants::GetControlFrameHeaderSize(protocol_version())) {
DLOG(WARNING) << "Received control frame with way too big of a payload: "
<< current_frame_length_;
set_error(SPDY_CONTROL_PAYLOAD_TOO_LARGE);
@@ -2659,7 +2666,7 @@ SpdySerializedFrame* SpdyFramer::SerializeHeaders(
headers.name_value_block(), &hpack_encoding);
}
size += hpack_encoding.size();
- if (size > GetHeaderFragmentMaxSize()) {
+ if (size > kMaxControlFrameSize) {
size += GetNumberRequiredContinuationFrames(size) *
GetContinuationMinimumSize();
flags &= ~HEADERS_FLAG_END_HEADERS;
@@ -2767,7 +2774,7 @@ SpdyFrame* SpdyFramer::SerializePushPromise(
push_promise.name_value_block(), &hpack_encoding);
}
size += hpack_encoding.size();
- if (size > GetHeaderFragmentMaxSize()) {
+ if (size > kMaxControlFrameSize) {
size += GetNumberRequiredContinuationFrames(size) *
GetContinuationMinimumSize();
flags &= ~PUSH_PROMISE_FLAG_END_PUSH_PROMISE;
@@ -2965,7 +2972,6 @@ size_t SpdyFramer::GetSerializedLength(const SpdyHeaderBlock& headers) {
}
size_t SpdyFramer::GetNumberRequiredContinuationFrames(size_t size) {
- const size_t kMaxControlFrameSize = GetHeaderFragmentMaxSize();
DCHECK_GT(protocol_version(), SPDY3);
DCHECK_GT(size, kMaxControlFrameSize);
size_t overflow = size - kMaxControlFrameSize;
@@ -2977,8 +2983,6 @@ void SpdyFramer::WritePayloadWithContinuation(SpdyFrameBuilder* builder,
SpdyStreamId stream_id,
SpdyFrameType type,
int padding_payload_len) {
- const size_t kMaxControlFrameSize = GetHeaderFragmentMaxSize();
-
uint8 end_flag = 0;
uint8 flags = 0;
if (type == HEADERS) {