[trafficserver] branch 7.1.x updated: remove unnecessary assertion for "alternate"
This is an automated email from the ASF dual-hosted git repository. zwoop pushed a commit to branch 7.1.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git The following commit(s) were added to refs/heads/7.1.x by this push: new 6dfd927 remove unnecessary assertion for "alternate" 6dfd927 is described below commit 6dfd927887e2db9c8862e55455c573f73190637a Author: Fei DengAuthorDate: Tue Sep 5 16:08:57 2017 -0500 remove unnecessary assertion for "alternate" (cherry picked from commit a5fd988170fdacb7df3fad1b2d7cd908a98c28dd) Conflicts: iocore/cache/CacheRead.cc Trivially resolved, because of clang-tidy being run on master. --- iocore/cache/CacheRead.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iocore/cache/CacheRead.cc b/iocore/cache/CacheRead.cc index a9986bd..6b2fbee 100644 --- a/iocore/cache/CacheRead.cc +++ b/iocore/cache/CacheRead.cc @@ -245,7 +245,7 @@ CacheVC::openReadChooseWriter(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSE continue; } } - ink_assert(w->alternate.valid()); + if (w->alternate.valid()) vector.insert(>alternate, alt_ndx); } -- To stop receiving notification emails like this one, please contact ['"commits@trafficserver.apache.org" '].
[trafficserver] branch 7.1.x updated: Add a metric for tracking RSS of traffic_server
This is an automated email from the ASF dual-hosted git repository. zwoop pushed a commit to branch 7.1.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git The following commit(s) were added to refs/heads/7.1.x by this push: new 6f4faf4 Add a metric for tracking RSS of traffic_server 6f4faf4 is described below commit 6f4faf44e959656d05fe037fc0cb194f2914adb9 Author: Leif HedstromAuthorDate: Wed Sep 13 13:01:34 2017 -0600 Add a metric for tracking RSS of traffic_server (cherry picked from commit c1a656e372d2577fdf63d34769a898acd1ab804f) --- .../monitoring/statistics/core/general.en.rst | 5 proxy/Main.cc | 34 -- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/doc/admin-guide/monitoring/statistics/core/general.en.rst b/doc/admin-guide/monitoring/statistics/core/general.en.rst index eb08eda..50468ae 100644 --- a/doc/admin-guide/monitoring/statistics/core/general.en.rst +++ b/doc/admin-guide/monitoring/statistics/core/general.en.rst @@ -117,3 +117,8 @@ General A shortened string containing the release number of the running instance of |TS|. +.. ts:stat:: global proxy.process.traffic_server.memory.rss integer + :units: bytes + + The resident set size (RSS) of the ``traffic_server`` process. This is + basically the amount of memory this process is consuming. diff --git a/proxy/Main.cc b/proxy/Main.cc index b6ff339..828595a 100644 --- a/proxy/Main.cc +++ b/proxy/Main.cc @@ -353,8 +353,11 @@ public: { memset(&_usage, 0, sizeof(_usage)); SET_HANDLER(::periodic); +RecRegisterStatInt(RECT_PROCESS, "proxy.process.traffic_server.memory.rss", static_cast(0), RECP_NON_PERSISTENT); } + ~MemoryLimit() override { mutex = nullptr; } + int periodic(int event, Event *e) { @@ -364,14 +367,15 @@ public: delete this; return EVENT_DONE; } -if (_memory_limit == 0) { - // first time it has been run - _memory_limit = REC_ConfigReadInteger("proxy.config.memory.max_usage"); - _memory_limit = _memory_limit >> 10; // divide by 1024 -} -if (_memory_limit > 0) { - if (getrusage(RUSAGE_SELF, &_usage) == 0) { -Debug("server", "memory usage - ru_maxrss: %ld memory limit: %" PRId64, _usage.ru_maxrss, _memory_limit); + +// "reload" the setting, we don't do this often so not expensive +_memory_limit = REC_ConfigReadInteger("proxy.config.memory.max_usage"); +_memory_limit = _memory_limit >> 10; // divide by 1024 + +if (getrusage(RUSAGE_SELF, &_usage) == 0) { + RecSetRecordInt("proxy.process.traffic_server.memory.rss", _usage.ru_maxrss << 10, REC_SOURCE_DEFAULT); // * 1024 + Debug("server", "memory usage - ru_maxrss: %ld memory limit: %" PRId64, _usage.ru_maxrss, _memory_limit); + if (_memory_limit > 0) { if (_usage.ru_maxrss > _memory_limit) { if (net_memory_throttle == false) { net_memory_throttle = true; @@ -383,13 +387,13 @@ public: Debug("server", "memory usage under limit - ru_maxrss: %ld memory limit: %" PRId64, _usage.ru_maxrss, _memory_limit); } } + } else { +// this feature has not been enabled +Debug("server", "limiting connections based on memory usage has been disabled"); +e->cancel(); +delete this; +return EVENT_DONE; } -} else { - // this feature has not be enabled - Debug("server", "limiting connections based on memory usage has been disabled"); - e->cancel(); - delete this; - return EVENT_DONE; } return EVENT_CONT; } @@ -1781,7 +1785,7 @@ main(int /* argc ATS_UNUSED */, const char **argv) eventProcessor.schedule_every(new SignalContinuation, HRTIME_MSECOND * 500, ET_CALL); eventProcessor.schedule_every(new DiagsLogContinuation, HRTIME_SECOND, ET_TASK); - eventProcessor.schedule_every(new MemoryLimit, HRTIME_SECOND, ET_TASK); + eventProcessor.schedule_every(new MemoryLimit, HRTIME_SECOND * 10, ET_TASK); REC_RegisterConfigUpdateFunc("proxy.config.dump_mem_info_frequency", init_memory_tracker, nullptr); init_memory_tracker(nullptr, RECD_NULL, RecData(), nullptr); -- To stop receiving notification emails like this one, please contact ['"commits@trafficserver.apache.org" '].
[trafficserver] branch master updated: This removes the FILE_WRITE mechanism from the core
This is an automated email from the ASF dual-hosted git repository. zwoop pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/trafficserver.git The following commit(s) were added to refs/heads/master by this push: new f6bdbc3 This removes the FILE_WRITE mechanism from the core f6bdbc3 is described below commit f6bdbc303c783e50307b56243b87921c10da6a53 Author: Leif HedstromAuthorDate: Tue Oct 10 16:33:12 2017 -0600 This removes the FILE_WRITE mechanism from the core This eliminates the TS Mgmt APIs as well, and various tests around writing configuration files. This is a step towards getting rid of configuration writing completely, but I'm doing it piecemeal. --- lib/perl/lib/Apache/TS/AdminClient.pm | 43 +++--- mgmt/api/APITestCliRemote.cc | 251 -- mgmt/api/CfgContextManager.cc | 71 -- mgmt/api/CfgContextManager.h | 1 - mgmt/api/CoreAPI.cc | 60 mgmt/api/CoreAPI.h| 1 - mgmt/api/CoreAPIRemote.cc | 28 mgmt/api/EventControlMain.cc | 1 - mgmt/api/INKMgmtAPI.cc| 12 -- mgmt/api/NetworkMessage.cc| 3 - mgmt/api/NetworkMessage.h | 1 - mgmt/api/TSControlMain.cc | 36 - mgmt/api/include/mgmtapi.h| 20 --- 13 files changed, 21 insertions(+), 507 deletions(-) diff --git a/lib/perl/lib/Apache/TS/AdminClient.pm b/lib/perl/lib/Apache/TS/AdminClient.pm index 920cf71..b0aad94 100644 --- a/lib/perl/lib/Apache/TS/AdminClient.pm +++ b/lib/perl/lib/Apache/TS/AdminClient.pm @@ -31,28 +31,27 @@ use Apache::TS; # Mgmt API command constants, should track ts/mgmtapi.h use constant { TS_FILE_READ => 0, -TS_FILE_WRITE => 1, -TS_RECORD_SET => 2, -TS_RECORD_GET => 3, -TS_PROXY_STATE_GET=> 4, -TS_PROXY_STATE_SET=> 5, -TS_RECONFIGURE=> 6, -TS_RESTART=> 7, -TS_BOUNCE => 8, -TS_EVENT_RESOLVE => 9, -TS_EVENT_GET_MLT => 10, -TS_EVENT_ACTIVE => 11, -TS_EVENT_REG_CALLBACK => 12, -TS_EVENT_UNREG_CALLBACK => 13, -TS_EVENT_NOTIFY => 14, -TS_STATS_RESET_NODE => 15, -TS_STORAGE_DEVICE_CMD_OFFLINE => 16, -TS_RECORD_MATCH_GET => 17, -TS_API_PING => 18, -TS_SERVER_BACKTRACE => 19, -TS_RECORD_DESCRIBE_CONFIG => 20, -TS_LIFECYCLE_MESSAGE => 21, -TS_UNDEFINED_OP => 22 +TS_RECORD_SET => 1, +TS_RECORD_GET => 2, +TS_PROXY_STATE_GET=> 3, +TS_PROXY_STATE_SET=> 4, +TS_RECONFIGURE=> 5, +TS_RESTART=> 6, +TS_BOUNCE => 7, +TS_EVENT_RESOLVE => 8, +TS_EVENT_GET_MLT => 9, +TS_EVENT_ACTIVE => 10, +TS_EVENT_REG_CALLBACK => 11, +TS_EVENT_UNREG_CALLBACK => 12, +TS_EVENT_NOTIFY => 13, +TS_STATS_RESET_NODE => 14, +TS_STORAGE_DEVICE_CMD_OFFLINE => 15, +TS_RECORD_MATCH_GET => 16, +TS_API_PING => 17, +TS_SERVER_BACKTRACE => 18, +TS_RECORD_DESCRIBE_CONFIG => 19, +TS_LIFECYCLE_MESSAGE => 20, +TS_UNDEFINED_OP => 21 }; use constant { diff --git a/mgmt/api/APITestCliRemote.cc b/mgmt/api/APITestCliRemote.cc index 262f187..f2e38b9 100644 --- a/mgmt/api/APITestCliRemote.cc +++ b/mgmt/api/APITestCliRemote.cc @@ -43,7 +43,6 @@ * File operations: * --- * read_file: reads hosting.config file - * write_file: write some made-up text to hosting.config file * proxy.config.xxx (a records.config variable): returns value of that record * records: tests get/set/get a record of each different type * (int, float, counter, string) @@ -1355,38 +1354,6 @@ test_read_file() } } -/* - * test_write_file - * - * writes hosting.config with some garbage text then reads the file and - * prints the new file to stdout - */ -void -test_write_file() -{ - char *f_text = nullptr; - int f_size= -1; - int f_ver = -1; - char new_f_text[] = "blah, blah blah\n I hope this works. please!!! \n"; - int new_f_size= strlen(new_f_text); - - printf("\n"); - if (TSConfigFileWrite(TS_FNAME_HOSTING, new_f_text, new_f_size, -1) != TS_ERR_OKAY) { -printf("[TSConfigFileWrite] FAILED!\n"); - } else { -printf("[TSConfigFileWrite] SUCCESS!\n"); - } - printf("\n"); - - // should free
[trafficserver] 03/03: Fix heap-use-after-free in QUICStreamFrame::store
This is an automated email from the ASF dual-hosted git repository. maskit pushed a commit to branch quic-05 in repository https://gitbox.apache.org/repos/asf/trafficserver.git commit 92d7c3a29e988a4a80433b3d27efd3fea6ea1427 Author: Masaori KoshibaAuthorDate: Thu Oct 12 16:34:14 2017 +0900 Fix heap-use-after-free in QUICStreamFrame::store Make data of QUICStramFrame ats_unique_buf. Copy data of _write_vio to the buffer, when QUICStream sends frame. Ideally this malloc and copy should be avoided. (cherry picked from commit 2250a414d8818b5f6b781a9ee9811521d6022e20) --- iocore/net/quic/QUICFrame.cc | 11 +- iocore/net/quic/QUICFrame.h | 4 +- iocore/net/quic/test/test_QUICFrame.cc | 50 +- iocore/net/quic/test/test_QUICFrameDispatcher.cc | 7 +- iocore/net/quic/test/test_QUICStream.cc | 215 +-- 5 files changed, 174 insertions(+), 113 deletions(-) diff --git a/iocore/net/quic/QUICFrame.cc b/iocore/net/quic/QUICFrame.cc index 69951d4..4bb02b4 100644 --- a/iocore/net/quic/QUICFrame.cc +++ b/iocore/net/quic/QUICFrame.cc @@ -72,9 +72,9 @@ QUICFrame::reset(const uint8_t *buf, size_t len) // STREAM Frame // -QUICStreamFrame::QUICStreamFrame(const uint8_t *data, size_t data_len, QUICStreamId stream_id, QUICOffset offset, bool last) +QUICStreamFrame::QUICStreamFrame(ats_unique_buf data, size_t data_len, QUICStreamId stream_id, QUICOffset offset, bool last) { - this->_data = data; + this->_data = std::move(data); this->_data_len = data_len; this->_stream_id = stream_id; this->_offset= offset; @@ -183,7 +183,7 @@ QUICStreamFrame::data() const if (this->_buf) { return this->_buf + this->_get_data_offset(); } else { -return this->_data; +return this->_data.get(); } } @@ -1315,8 +1315,11 @@ QUICFrameFactory::fast_create(const uint8_t *buf, size_t len) QUICStreamFrameUPtr QUICFrameFactory::create_stream_frame(const uint8_t *data, size_t data_len, QUICStreamId stream_id, QUICOffset offset, bool last) { + ats_unique_buf buf = ats_unique_malloc(data_len); + memcpy(buf.get(), data, data_len); + QUICStreamFrame *frame = quicStreamFrameAllocator.alloc(); - new (frame) QUICStreamFrame(data, data_len, stream_id, offset, last); + new (frame) QUICStreamFrame(std::move(buf), data_len, stream_id, offset, last); return QUICStreamFrameUPtr(frame, ::delete_stream_frame); } diff --git a/iocore/net/quic/QUICFrame.h b/iocore/net/quic/QUICFrame.h index 772d65a..9f2b356 100644 --- a/iocore/net/quic/QUICFrame.h +++ b/iocore/net/quic/QUICFrame.h @@ -59,7 +59,7 @@ class QUICStreamFrame : public QUICFrame public: QUICStreamFrame() : QUICFrame() {} QUICStreamFrame(const uint8_t *buf, size_t len) : QUICFrame(buf, len) {} - QUICStreamFrame(const uint8_t *buf, size_t len, QUICStreamId streamid, QUICOffset offset, bool last = false); + QUICStreamFrame(ats_unique_buf buf, size_t len, QUICStreamId streamid, QUICOffset offset, bool last = false); virtual QUICFrameType type() const override; virtual size_t size() const override; virtual void store(uint8_t *buf, size_t *len) const override; @@ -74,7 +74,7 @@ public: LINK(QUICStreamFrame, link); private: - const uint8_t *_data= nullptr; + ats_unique_buf _data= {nullptr, [](void *p) { ats_free(p); }}; size_t _data_len= 0; QUICStreamId _stream_id = 0; QUICOffset _offset = 0; diff --git a/iocore/net/quic/test/test_QUICFrame.cc b/iocore/net/quic/test/test_QUICFrame.cc index 90c82fb..36f1eee 100644 --- a/iocore/net/quic/test/test_QUICFrame.cc +++ b/iocore/net/quic/test/test_QUICFrame.cc @@ -55,11 +55,14 @@ TEST_CASE("QUICFrame Type", "[quic]") TEST_CASE("Construct QUICFrame", "[quic]") { - uint8_t payload[] = "foo"; + uint8_t raw[] = "foo"; + ats_unique_buf payload = ats_unique_malloc(sizeof(raw)); + memcpy(payload.get(), raw, sizeof(raw)); + uint8_t buf[65536]; size_t len; - QUICStreamFrame frame1(payload, sizeof(payload), 0xffcc9966, 0xffddbb9977553311); + QUICStreamFrame frame1(std::move(payload), sizeof(raw), 0xffcc9966, 0xffddbb9977553311); frame1.store(buf, ); CHECK(frame1.type() == QUICFrameType::STREAM); CHECK(frame1.size() == 19); @@ -119,7 +122,12 @@ TEST_CASE("Store STREAM Frame", "[quic]") 0x00, 0x05, // Data Length 0x01, 0x02, 0x03, 0x04, 0x05, // Stream Data }; - QUICStreamFrame streamFrame1(reinterpret_cast("\x01\x02\x03\x04\x05"), 5, 0x01, 0x00); + + uint8_t raw1[] = "\x01\x02\x03\x04\x05"; + ats_unique_buf payload1 = ats_unique_malloc(5); + memcpy(payload1.get(), raw1, 5); + + QUICStreamFrame streamFrame1(std::move(payload1), 5, 0x01, 0x00); streamFrame1.store(buf, ); CHECK(len == 9); CHECK(memcmp(buf, expected1, len) == 0); @@ -132,7 +140,11 @@ TEST_CASE("Store STREAM Frame", "[quic]") 0x00, 0x05, //
[trafficserver] 01/03: add QUICInBuffer feature
This is an automated email from the ASF dual-hosted git repository. maskit pushed a commit to branch quic-05 in repository https://gitbox.apache.org/repos/asf/trafficserver.git commit 46cf6d50173562002642278d0c6d9cb0886f3cbe Author: scw00AuthorDate: Tue Oct 10 08:19:00 2017 +0800 add QUICInBuffer feature (cherry picked from commit 2f5caad25df450b16f9458c7119a421652f6ddb5) --- iocore/net/quic/Makefile.am| 3 +- iocore/net/quic/QUICIncomingFrameBuffer.cc | 135 iocore/net/quic/QUICIncomingFrameBuffer.h | 58 +++ iocore/net/quic/QUICStream.cc | 36 ++--- iocore/net/quic/QUICStream.h | 7 +- iocore/net/quic/test/Makefile.am | 35 +++- .../net/quic/test/test_QUICIncomingFrameBuffer.cc | 177 + 7 files changed, 421 insertions(+), 30 deletions(-) diff --git a/iocore/net/quic/Makefile.am b/iocore/net/quic/Makefile.am index 90ba2fe..3fc2585 100644 --- a/iocore/net/quic/Makefile.am +++ b/iocore/net/quic/Makefile.am @@ -61,7 +61,8 @@ libquic_a_SOURCES = \ QUICConfig.cc \ QUICDebugNames.cc \ QUICApplication.cc \ - QUICApplicationMap.cc + QUICApplicationMap.cc \ + QUICIncomingFrameBuffer.cc include $(top_srcdir)/build/tidy.mk diff --git a/iocore/net/quic/QUICIncomingFrameBuffer.cc b/iocore/net/quic/QUICIncomingFrameBuffer.cc new file mode 100644 index 000..e769054 --- /dev/null +++ b/iocore/net/quic/QUICIncomingFrameBuffer.cc @@ -0,0 +1,135 @@ +/** @file + * + * A brief file description + * + * @section license License + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "QUICIncomingFrameBuffer.h" + +QUICIncomingFrameBuffer::~QUICIncomingFrameBuffer() +{ + this->_out_of_order_queue.clear(); + + while (!this->_recv_buffer.empty()) { +this->_recv_buffer.pop(); + } +} + +std::shared_ptr +QUICIncomingFrameBuffer::pop() +{ + if (this->_recv_buffer.empty()) { +auto frame = this->_out_of_order_queue.find(this->_recv_offset); +while (frame != this->_out_of_order_queue.end()) { + this->_recv_buffer.push(frame->second); + this->_recv_offset += frame->second->data_length(); + this->_out_of_order_queue.erase(frame); + frame = this->_out_of_order_queue.find(this->_recv_offset); +} + } + + if (!this->_recv_buffer.empty()) { +auto frame = this->_recv_buffer.front(); +this->_recv_buffer.pop(); +return frame; + } + return nullptr; +} + +QUICErrorUPtr +QUICIncomingFrameBuffer::insert(const std::shared_ptr frame) +{ + QUICOffset offset = frame->offset(); + size_t len= frame->data_length(); + + QUICErrorUPtr err = this->_check_and_set_fin_flag(offset, len, frame->has_fin_flag()); + if (err->cls != QUICErrorClass::NONE) { +return err; + } + + if (this->_recv_offset > offset) { +// dup frame; +return QUICErrorUPtr(new QUICNoError()); + } else if (this->_recv_offset == offset) { +this->_recv_offset = offset + len; +this->_recv_buffer.push(frame); + } else { +this->_out_of_order_queue.insert(std::make_pair(offset, frame)); + } + + return QUICErrorUPtr(new QUICNoError()); +} + +void +QUICIncomingFrameBuffer::clear() +{ + this->_out_of_order_queue.clear(); + + while (!this->_recv_buffer.empty()) { +this->_recv_buffer.pop(); + } + + this->_fin_offset = UINT64_MAX; + this->_max_offset = 0; + this->_recv_offset = 0; +} + +bool +QUICIncomingFrameBuffer::empty() +{ + return this->_out_of_order_queue.empty() && this->_recv_buffer.empty(); +} + +QUICErrorUPtr +QUICIncomingFrameBuffer::_check_and_set_fin_flag(QUICOffset offset, size_t len, bool fin_flag) +{ + // stream with fin flag {11.3. Stream Final Offset} + // Once a final offset for a stream is known, it cannot change. + // If a RST_STREAM or STREAM frame causes the final offset to change for a stream, + // an endpoint SHOULD respond with a FINAL_OFFSET_ERROR error (see Section 12). + // A receiver SHOULD treat receipt of data at or beyond the final offset as a + // FINAL_OFFSET_ERROR error, even after a stream is closed. + + // {11.3. Stream Final Offset} + // A receiver SHOULD treat
[trafficserver] branch quic-05 updated (ff2d8a7 -> 92d7c3a)
This is an automated email from the ASF dual-hosted git repository. maskit pushed a change to branch quic-05 in repository https://gitbox.apache.org/repos/asf/trafficserver.git. from ff2d8a7 Call the QUICFrame destructor before freeing into the ClassAllocator new 46cf6d5 add QUICInBuffer feature new 1a70d29 Fix building unit tests of quic new 92d7c3a Fix heap-use-after-free in QUICStreamFrame::store The 3 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .gitignore | 1 + iocore/net/quic/Makefile.am| 3 +- iocore/net/quic/QUICFrame.cc | 11 +- iocore/net/quic/QUICFrame.h| 4 +- iocore/net/quic/QUICIncomingFrameBuffer.cc | 135 + ...CApplicationMap.h => QUICIncomingFrameBuffer.h} | 34 +++- iocore/net/quic/QUICStream.cc | 36 ++-- iocore/net/quic/QUICStream.h | 7 +- iocore/net/quic/test/Makefile.am | 43 - iocore/net/quic/test/test_QUICFrame.cc | 50 - iocore/net/quic/test/test_QUICFrameDispatcher.cc | 7 +- .../net/quic/test/test_QUICIncomingFrameBuffer.cc | 177 + iocore/net/quic/test/test_QUICStream.cc| 215 - 13 files changed, 572 insertions(+), 151 deletions(-) create mode 100644 iocore/net/quic/QUICIncomingFrameBuffer.cc copy iocore/net/quic/{QUICApplicationMap.h => QUICIncomingFrameBuffer.h} (57%) create mode 100644 iocore/net/quic/test/test_QUICIncomingFrameBuffer.cc -- To stop receiving notification emails like this one, please contact ['"commits@trafficserver.apache.org"'].
[trafficserver] 02/03: Fix building unit tests of quic
This is an automated email from the ASF dual-hosted git repository. maskit pushed a commit to branch quic-05 in repository https://gitbox.apache.org/repos/asf/trafficserver.git commit 1a70d2953c6d0fef88f1512b6e4f390288c80daf Author: Masaori KoshibaAuthorDate: Thu Oct 12 14:11:32 2017 +0900 Fix building unit tests of quic (cherry picked from commit d46ff1251c628b642f1822591d1ac5126e916933) --- .gitignore | 1 + iocore/net/quic/test/Makefile.am | 8 2 files changed, 9 insertions(+) diff --git a/.gitignore b/.gitignore index de3eff5..ed253d8 100644 --- a/.gitignore +++ b/.gitignore @@ -103,6 +103,7 @@ iocore/net/quic/test/test_QUICTypeUtil iocore/net/quic/test/test_QUICAckFrameCreator iocore/net/quic/test/test_QUICVersionNegotiator iocore/net/quic/test/test_QUICFlowController +iocore/net/quic/test/test_QUICIncomingFrameBuffer iocore/net/quic/ts_quic_client iocore/aio/test_AIO iocore/eventsystem/test_Buffer diff --git a/iocore/net/quic/test/Makefile.am b/iocore/net/quic/test/Makefile.am index e25eced..b53ec4d 100644 --- a/iocore/net/quic/test/Makefile.am +++ b/iocore/net/quic/test/Makefile.am @@ -132,6 +132,7 @@ test_QUICFrame_SOURCES = \ ../QUICTypes.cc \ ../QUICStream.cc \ ../QUICStreamState.cc \ + ../QUICIncomingFrameBuffer.cc \ ../QUICDebugNames.cc \ ../QUICFlowController.cc \ ../../SSLNextProtocolSet.cc @@ -166,6 +167,7 @@ test_QUICFrameDispatcher_SOURCES = \ ../QUICPacket.cc \ ../QUICStream.cc \ ../QUICStreamState.cc \ + ../QUICIncomingFrameBuffer.cc \ ../QUICApplication.cc \ ../QUICHandshake.cc \ ../QUICTypes.cc \ @@ -252,6 +254,7 @@ test_QUICStreamManager_SOURCES = \ event_processor_main.cc \ test_QUICStreamManager.cc \ ../QUICStream.cc \ + ../QUICIncomingFrameBuffer.cc \ ../QUICFrameDispatcher.cc \ ../QUICStreamManager.cc \ ../QUICApplicationMap.cc \ @@ -290,6 +293,7 @@ test_QUICTransportParameters_SOURCES = \ ../QUICCrypto.cc \ $(QUICCrypto_impl) \ ../QUICStream.cc \ + ../QUICIncomingFrameBuffer.cc \ ../QUICStreamState.cc \ ../QUICStreamManager.cc \ ../QUICFlowController.cc \ @@ -380,6 +384,7 @@ test_QUICTypeUtil_SOURCES = \ main.cc \ test_QUICTypeUtil.cc \ ../QUICStream.cc \ + ../QUICIncomingFrameBuffer.cc \ ../QUICStreamState.cc \ ../QUICFlowController.cc \ ../QUICDebugNames.cc \ @@ -411,6 +416,7 @@ test_QUICAckFrameCreator_SOURCES = \ ../QUICFrame.cc \ ../QUICPacket.cc \ ../QUICStream.cc \ + ../QUICIncomingFrameBuffer.cc \ ../QUICStreamState.cc \ ../QUICFlowController.cc \ ../QUICDebugNames.cc \ @@ -449,6 +455,7 @@ test_QUICVersionNegotiator_SOURCES = \ ../QUICApplicationMap.cc \ ../QUICHandshake.cc \ ../QUICStream.cc \ + ../QUICIncomingFrameBuffer.cc \ ../QUICStreamState.cc \ ../QUICStreamManager.cc \ ../QUICFlowController.cc \ @@ -483,6 +490,7 @@ test_QUICFlowController_SOURCES = \ test_QUICFlowController.cc \ ../QUICFlowController.cc \ ../QUICStream.cc \ + ../QUICIncomingFrameBuffer.cc \ ../QUICStreamState.cc \ ../QUICDebugNames.cc \ ../QUICTypes.cc \ -- To stop receiving notification emails like this one, please contact "commits@trafficserver.apache.org" .
[trafficserver] branch master updated: Optimize: If failed on migrateToCurrentThread, put the server session back to global server session pool
This is an automated email from the ASF dual-hosted git repository. oknet pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/trafficserver.git The following commit(s) were added to refs/heads/master by this push: new c776c66 Optimize: If failed on migrateToCurrentThread, put the server session back to global server session pool c776c66 is described below commit c776c6677b0c005dd511945ae023a14f8f6b0bc3 Author: Oknet XuAuthorDate: Fri Sep 1 22:18:54 2017 +0800 Optimize: If failed on migrateToCurrentThread, put the server session back to global server session pool --- iocore/net/UnixNetVConnection.cc | 74 +++- proxy/http/HttpSessionManager.cc | 24 ++--- 2 files changed, 61 insertions(+), 37 deletions(-) diff --git a/iocore/net/UnixNetVConnection.cc b/iocore/net/UnixNetVConnection.cc index a4c7769..0e97ffa 100644 --- a/iocore/net/UnixNetVConnection.cc +++ b/iocore/net/UnixNetVConnection.cc @@ -1244,6 +1244,7 @@ UnixNetVConnection::populate(Connection _in, Continuation *c, void *arg) } if (h->startIO(this) < 0) { +con_in.move(this->con); Debug("iocore_net", "populate : Failed to add to epoll list"); return EVENT_ERROR; } @@ -1430,44 +1431,71 @@ UnixNetVConnection::migrateToCurrentThread(Continuation *cont, EThread *t) return this; } - Connection hold_con; - hold_con.move(this->con); - SSLNetVConnection *sslvc = dynamic_cast(this); - - SSL *save_ssl = (sslvc) ? sslvc->ssl : nullptr; - if (save_ssl) { -SSLNetVCDetach(sslvc->ssl); -sslvc->ssl = nullptr; + // Lock the NetHandler first in order to put the new NetVC into NetHandler and InactivityCop. + // It is safe and no performance issue to get the mutex lock for a NetHandler of current ethread. + SCOPED_MUTEX_LOCK(lock, client_nh->mutex, t); + + // Try to get the mutex lock for NetHandler of this NetVC + MUTEX_TRY_LOCK(lock_src, this->nh->mutex, t); + if (lock_src.is_locked()) { +// Deattach this NetVC from original NetHandler & InactivityCop. +this->nh->stopCop(this); +this->nh->stopIO(this); +// Put this NetVC into current NetHandler & InactivityCop. +this->thread = t; +client_nh->startIO(this); +client_nh->startCop(this); +// Move this NetVC to current EThread Successfully. +return this; } - // Do_io_close will signal the VC to be freed on the original thread - // Since we moved the con context, the fd will not be closed - // Go ahead and remove the fd from the original thread's epoll structure, so it is not - // processed on two threads simultaneously - this->ep.stop(); - this->do_io_close(); + // Failed to get the mutex lock for original NetHandler. + // Try to migrate it by create a new NetVC and then move con.fd and ssl ctx. + SSLNetVConnection *sslvc = dynamic_cast(this); + SSL *save_ssl= (sslvc) ? sslvc->ssl : nullptr; + + UnixNetVConnection *ret_vc = nullptr; // Create new VC: if (save_ssl) { SSLNetVConnection *sslvc = static_cast(sslNetProcessor.allocate_vc(t)); -if (sslvc->populate(hold_con, cont, save_ssl) != EVENT_DONE) { - sslvc->do_io_close(); - sslvc = nullptr; +if (sslvc->populate(this->con, cont, save_ssl) != EVENT_DONE) { + sslvc->free(t); + sslvc = nullptr; + ret_vc = this; } else { sslvc->set_context(get_context()); + ret_vc = dynamic_cast(sslvc); } -return sslvc; -// Update the SSL fields } else { UnixNetVConnection *netvc = static_cast(netProcessor.allocate_vc(t)); -if (netvc->populate(hold_con, cont, save_ssl) != EVENT_DONE) { - netvc->do_io_close(); - netvc = nullptr; +if (netvc->populate(this->con, cont, save_ssl) != EVENT_DONE) { + netvc->free(t); + netvc = nullptr; + ret_vc = this; } else { netvc->set_context(get_context()); + ret_vc = netvc; } -return netvc; } + + // clear con.fd and ssl ctx from this NetVC since a new NetVC is created. + if (ret_vc != this) { +if (save_ssl) { + SSLNetVCDetach(sslvc->ssl); + sslvc->ssl = nullptr; +} +ink_assert(this->con.fd == NO_FD); + +// Do_io_close will signal the VC to be freed on the original thread +// Since we moved the con context, the fd will not be closed +// Go ahead and remove the fd from the original thread's epoll structure, so it is not +// processed on two threads simultaneously +this->ep.stop(); +this->do_io_close(); + } + + return ret_vc; } void diff --git a/proxy/http/HttpSessionManager.cc b/proxy/http/HttpSessionManager.cc index 1e4334a..49450f2 100644 --- a/proxy/http/HttpSessionManager.cc +++ b/proxy/http/HttpSessionManager.cc @@ -326,21 +326,17 @@ HttpSessionManager::acquire_session(Continuation * /* cont ATS_UNUSED */, sockad UnixNetVConnection *server_vc = dynamic_cast(to_return->get_netvc()); if (server_vc) {
[trafficserver] branch quic-latest updated: Stop Version Negotiation Packet retransmission
This is an automated email from the ASF dual-hosted git repository. masaori pushed a commit to branch quic-latest in repository https://gitbox.apache.org/repos/asf/trafficserver.git The following commit(s) were added to refs/heads/quic-latest by this push: new e72cfd9 Stop Version Negotiation Packet retransmission e72cfd9 is described below commit e72cfd9c10b940971ff2643d46417ab4098656fa Author: Masaori KoshibaAuthorDate: Fri Oct 13 12:02:30 2017 +0900 Stop Version Negotiation Packet retransmission --- iocore/net/QUICNetVConnection.cc| 2 ++ iocore/net/quic/QUICLossDetector.cc | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/iocore/net/QUICNetVConnection.cc b/iocore/net/QUICNetVConnection.cc index a941336..4229c56 100644 --- a/iocore/net/QUICNetVConnection.cc +++ b/iocore/net/QUICNetVConnection.cc @@ -228,6 +228,8 @@ QUICNetVConnection::transmit_packet(QUICPacketUPtr packet) void QUICNetVConnection::retransmit_packet(const QUICPacket ) { + ink_assert(packet.type() != QUICPacketType::VERSION_NEGOTIATION && packet.type() != QUICPacketType::UNINITIALIZED); + uint16_t size = packet.payload_size(); const uint8_t *payload = packet.payload(); diff --git a/iocore/net/quic/QUICLossDetector.cc b/iocore/net/quic/QUICLossDetector.cc index b9d3c10..41bb3fc 100644 --- a/iocore/net/quic/QUICLossDetector.cc +++ b/iocore/net/quic/QUICLossDetector.cc @@ -145,8 +145,9 @@ QUICLossDetector::on_packet_sent(QUICPacketUPtr packet) bool is_handshake = false; QUICPacketType type = packet->type(); - if (type != QUICPacketType::ZERO_RTT_PROTECTED && type != QUICPacketType::ONE_RTT_PROTECTED_KEY_PHASE_0 && - type != QUICPacketType::ONE_RTT_PROTECTED_KEY_PHASE_1) { + // XXX: Should QUICPacketType::SERVER_STATELESS_RETRY be included? + if (type == QUICPacketType::CLIENT_INITIAL || type == QUICPacketType::SERVER_CLEARTEXT || + type == QUICPacketType::CLIENT_CLEARTEXT) { is_handshake = true; } -- To stop receiving notification emails like this one, please contact ['"commits@trafficserver.apache.org" '].
[trafficserver] branch 7.1.x updated (6f4faf4 -> d3278fa)
This is an automated email from the ASF dual-hosted git repository. zwoop pushed a change to branch 7.1.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git. from 6f4faf4 Add a metric for tracking RSS of traffic_server new 9b60360 Avoid sending duplicate push promise on same client session #2205 new b43c0a7 Coverity CID #1224619 Uninitialized members new d3278fa clang-format The 3 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: doc/admin-guide/files/records.config.en.rst | 7 +++ mgmt/RecordsConfig.cc | 2 ++ proxy/InkAPI.cc | 6 +- proxy/Main.cc | 1 - proxy/http2/HTTP2.cc| 2 ++ proxy/http2/HTTP2.h | 1 + proxy/http2/Http2ClientSession.cc | 6 ++ proxy/http2/Http2ClientSession.h| 23 +++ 8 files changed, 46 insertions(+), 2 deletions(-) -- To stop receiving notification emails like this one, please contact ['"commits@trafficserver.apache.org"'].
[trafficserver] 01/03: Avoid sending duplicate push promise on same client session #2205
This is an automated email from the ASF dual-hosted git repository. zwoop pushed a commit to branch 7.1.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git commit 9b603606f600d4c4277ffab322a9a30dd65cba8e Author: Rahul MalikAuthorDate: Fri Aug 4 13:53:32 2017 -0700 Avoid sending duplicate push promise on same client session #2205 (cherry picked from commit 22733a32b81346cd758b69377c61d3569a63c13a) Conflicts: doc/admin-guide/files/records.config.en.rst proxy/http2/Http2ClientSession.h --- doc/admin-guide/files/records.config.en.rst | 7 +++ mgmt/RecordsConfig.cc | 2 ++ proxy/InkAPI.cc | 6 +- proxy/http2/HTTP2.cc| 2 ++ proxy/http2/HTTP2.h | 1 + proxy/http2/Http2ClientSession.cc | 6 ++ proxy/http2/Http2ClientSession.h| 23 +++ 7 files changed, 46 insertions(+), 1 deletion(-) diff --git a/doc/admin-guide/files/records.config.en.rst b/doc/admin-guide/files/records.config.en.rst index 54ce8ce..8776917 100644 --- a/doc/admin-guide/files/records.config.en.rst +++ b/doc/admin-guide/files/records.config.en.rst @@ -3340,6 +3340,13 @@ HTTP/2 Configuration Enable the experimental HTTP/2 Stream Priority feature. +.. ts:cv:: CONFIG proxy.config.http2.push_diary_size INT 256 + :reloadable: + + Indicates the maximum number of HTTP/2 server pushes that are remembered per + HTTP/2 connection to avoid duplicate pushes on the same connection. If the + maximum number is reached, new entries are not remembered. + Plug-in Configuration = diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc index 383ede2..61c79cd 100644 --- a/mgmt/RecordsConfig.cc +++ b/mgmt/RecordsConfig.cc @@ -1434,6 +1434,8 @@ static const RecordElement RecordsConfig[] = , {RECT_CONFIG, "proxy.config.http2.active_timeout_in", RECD_INT, "900", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL} , + {RECT_CONFIG, "proxy.config.http2.push_diary_size", RECD_INT, "256", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL} + , //# Add LOCAL Records Here {RECT_LOCAL, "proxy.local.incoming_ip_to_bind", RECD_STRING, nullptr, RECU_NULL, RR_NULL, RECC_NULL, nullptr, RECA_NULL} diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc index c2ad922..2f4626f 100644 --- a/proxy/InkAPI.cc +++ b/proxy/InkAPI.cc @@ -7684,7 +7684,11 @@ TSHttpTxnServerPush(TSHttpTxn txnp, const char *url, int url_len) HttpSM *sm = reinterpret_cast(txnp); Http2Stream *stream = dynamic_cast(sm->ua_session); if (stream) { -stream->push_promise(url_obj); +Http2ClientSession *parent = static_cast(stream->get_parent()); +if (!parent->is_url_pushed(url, url_len)) { + stream->push_promise(url_obj); + parent->add_url_to_pushed_table(url, url_len); +} } url_obj.destroy(); } diff --git a/proxy/http2/HTTP2.cc b/proxy/http2/HTTP2.cc index 16b518b..67af7b6 100644 --- a/proxy/http2/HTTP2.cc +++ b/proxy/http2/HTTP2.cc @@ -725,6 +725,7 @@ uint32_t Http2::max_request_header_size= 131072; uint32_t Http2::accept_no_activity_timeout = 120; uint32_t Http2::no_activity_timeout_in = 120; uint32_t Http2::active_timeout_in = 0; +uint32_t Http2::push_diary_size= 256; void Http2::init() @@ -741,6 +742,7 @@ Http2::init() REC_EstablishStaticConfigInt32U(accept_no_activity_timeout, "proxy.config.http2.accept_no_activity_timeout"); REC_EstablishStaticConfigInt32U(no_activity_timeout_in, "proxy.config.http2.no_activity_timeout_in"); REC_EstablishStaticConfigInt32U(active_timeout_in, "proxy.config.http2.active_timeout_in"); + REC_EstablishStaticConfigInt32U(push_diary_size, "proxy.config.http2.push_diary_size"); // If any settings is broken, ATS should not start ink_release_assert(http2_settings_parameter_is_valid({HTTP2_SETTINGS_MAX_CONCURRENT_STREAMS, max_concurrent_streams_in})); diff --git a/proxy/http2/HTTP2.h b/proxy/http2/HTTP2.h index 19272a5..2c0ec8c 100644 --- a/proxy/http2/HTTP2.h +++ b/proxy/http2/HTTP2.h @@ -376,6 +376,7 @@ public: static uint32_t accept_no_activity_timeout; static uint32_t no_activity_timeout_in; static uint32_t active_timeout_in; + static uint32_t push_diary_size; static void init(); }; diff --git a/proxy/http2/Http2ClientSession.cc b/proxy/http2/Http2ClientSession.cc index b7ee905..f545918 100644 --- a/proxy/http2/Http2ClientSession.cc +++ b/proxy/http2/Http2ClientSession.cc @@ -86,6 +86,10 @@ Http2ClientSession::destroy() void Http2ClientSession::free() { + if (h2_pushed_urls) { +this->h2_pushed_urls = ink_hash_table_destroy(this->h2_pushed_urls); + } + if (client_vc) { release_netvc(); client_vc->do_io_close(); @@ -190,6 +194,8 @@ Http2ClientSession::new_connection(NetVConnection *new_vc, MIOBuffer *iobuf, IOB this->read_buffer
[trafficserver] 03/03: clang-format
This is an automated email from the ASF dual-hosted git repository. zwoop pushed a commit to branch 7.1.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git commit d3278faf82aa51916d4f12bc8e9dfd28832e654b Author: Masakazu KitajoAuthorDate: Fri Oct 13 08:54:32 2017 +0900 clang-format --- proxy/Main.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/proxy/Main.cc b/proxy/Main.cc index 828595a..8d13f26 100644 --- a/proxy/Main.cc +++ b/proxy/Main.cc @@ -357,7 +357,6 @@ public: } ~MemoryLimit() override { mutex = nullptr; } - int periodic(int event, Event *e) { -- To stop receiving notification emails like this one, please contact "commits@trafficserver.apache.org" .
[trafficserver] 02/03: Coverity CID #1224619 Uninitialized members
This is an automated email from the ASF dual-hosted git repository. zwoop pushed a commit to branch 7.1.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git commit b43c0a71acccb70b085003514333b250cdecfba3 Author: Phil SorberAuthorDate: Wed Sep 20 20:40:08 2017 -0600 Coverity CID #1224619 Uninitialized members (cherry picked from commit e84cf75cefdb40859e68d588bdecdac7720a84ba) --- proxy/http2/Http2ClientSession.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proxy/http2/Http2ClientSession.h b/proxy/http2/Http2ClientSession.h index 2851528..aa1c10c 100644 --- a/proxy/http2/Http2ClientSession.h +++ b/proxy/http2/Http2ClientSession.h @@ -337,8 +337,8 @@ private: bool half_close_local; int recursion; - InkHashTable *h2_pushed_urls; - uint32_t h2_pushed_urls_size; + InkHashTable *h2_pushed_urls = nullptr; + uint32_t h2_pushed_urls_size = 0; }; extern ClassAllocator http2ClientSessionAllocator; -- To stop receiving notification emails like this one, please contact "commits@trafficserver.apache.org" .
[trafficserver] branch quic-latest updated (88b5d7c -> 2250a41)
This is an automated email from the ASF dual-hosted git repository. masaori pushed a change to branch quic-latest in repository https://gitbox.apache.org/repos/asf/trafficserver.git. omit 88b5d7c Fix heap-use-after-free omit a0e5c98 Fix building unit tests of quic new d46ff12 Fix building unit tests of quic new 2250a41 Fix heap-use-after-free in QUICStreamFrame::store This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (88b5d7c) \ N -- N -- N refs/heads/quic-latest (2250a41) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omit" are not gone; other references still refer to them. Any revisions marked "discard" are gone forever. The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: iocore/net/quic/QUICFrame.cc | 7 ++- iocore/net/quic/QUICFrame.h| 2 +- iocore/net/quic/QUICStream.cc | 6 +-- .../net/quic/test/test_QUICIncomingFrameBuffer.cc | 52 +- iocore/net/quic/test/test_QUICStreamManager.cc | 40 +++-- iocore/net/quic/test/test_QUICStreamState.cc | 48 +--- proxy/hq/HQClientTransaction.cc| 1 - 7 files changed, 53 insertions(+), 103 deletions(-) -- To stop receiving notification emails like this one, please contact ['"commits@trafficserver.apache.org"'].
[trafficserver] 01/02: Fix building unit tests of quic
This is an automated email from the ASF dual-hosted git repository. masaori pushed a commit to branch quic-latest in repository https://gitbox.apache.org/repos/asf/trafficserver.git commit d46ff1251c628b642f1822591d1ac5126e916933 Author: Masaori KoshibaAuthorDate: Thu Oct 12 14:11:32 2017 +0900 Fix building unit tests of quic --- .gitignore | 1 + iocore/net/quic/test/Makefile.am | 8 2 files changed, 9 insertions(+) diff --git a/.gitignore b/.gitignore index de3eff5..ed253d8 100644 --- a/.gitignore +++ b/.gitignore @@ -103,6 +103,7 @@ iocore/net/quic/test/test_QUICTypeUtil iocore/net/quic/test/test_QUICAckFrameCreator iocore/net/quic/test/test_QUICVersionNegotiator iocore/net/quic/test/test_QUICFlowController +iocore/net/quic/test/test_QUICIncomingFrameBuffer iocore/net/quic/ts_quic_client iocore/aio/test_AIO iocore/eventsystem/test_Buffer diff --git a/iocore/net/quic/test/Makefile.am b/iocore/net/quic/test/Makefile.am index e25eced..b53ec4d 100644 --- a/iocore/net/quic/test/Makefile.am +++ b/iocore/net/quic/test/Makefile.am @@ -132,6 +132,7 @@ test_QUICFrame_SOURCES = \ ../QUICTypes.cc \ ../QUICStream.cc \ ../QUICStreamState.cc \ + ../QUICIncomingFrameBuffer.cc \ ../QUICDebugNames.cc \ ../QUICFlowController.cc \ ../../SSLNextProtocolSet.cc @@ -166,6 +167,7 @@ test_QUICFrameDispatcher_SOURCES = \ ../QUICPacket.cc \ ../QUICStream.cc \ ../QUICStreamState.cc \ + ../QUICIncomingFrameBuffer.cc \ ../QUICApplication.cc \ ../QUICHandshake.cc \ ../QUICTypes.cc \ @@ -252,6 +254,7 @@ test_QUICStreamManager_SOURCES = \ event_processor_main.cc \ test_QUICStreamManager.cc \ ../QUICStream.cc \ + ../QUICIncomingFrameBuffer.cc \ ../QUICFrameDispatcher.cc \ ../QUICStreamManager.cc \ ../QUICApplicationMap.cc \ @@ -290,6 +293,7 @@ test_QUICTransportParameters_SOURCES = \ ../QUICCrypto.cc \ $(QUICCrypto_impl) \ ../QUICStream.cc \ + ../QUICIncomingFrameBuffer.cc \ ../QUICStreamState.cc \ ../QUICStreamManager.cc \ ../QUICFlowController.cc \ @@ -380,6 +384,7 @@ test_QUICTypeUtil_SOURCES = \ main.cc \ test_QUICTypeUtil.cc \ ../QUICStream.cc \ + ../QUICIncomingFrameBuffer.cc \ ../QUICStreamState.cc \ ../QUICFlowController.cc \ ../QUICDebugNames.cc \ @@ -411,6 +416,7 @@ test_QUICAckFrameCreator_SOURCES = \ ../QUICFrame.cc \ ../QUICPacket.cc \ ../QUICStream.cc \ + ../QUICIncomingFrameBuffer.cc \ ../QUICStreamState.cc \ ../QUICFlowController.cc \ ../QUICDebugNames.cc \ @@ -449,6 +455,7 @@ test_QUICVersionNegotiator_SOURCES = \ ../QUICApplicationMap.cc \ ../QUICHandshake.cc \ ../QUICStream.cc \ + ../QUICIncomingFrameBuffer.cc \ ../QUICStreamState.cc \ ../QUICStreamManager.cc \ ../QUICFlowController.cc \ @@ -483,6 +490,7 @@ test_QUICFlowController_SOURCES = \ test_QUICFlowController.cc \ ../QUICFlowController.cc \ ../QUICStream.cc \ + ../QUICIncomingFrameBuffer.cc \ ../QUICStreamState.cc \ ../QUICDebugNames.cc \ ../QUICTypes.cc \ -- To stop receiving notification emails like this one, please contact "commits@trafficserver.apache.org" .
[trafficserver] 02/02: Fix heap-use-after-free in QUICStreamFrame::store
This is an automated email from the ASF dual-hosted git repository. masaori pushed a commit to branch quic-latest in repository https://gitbox.apache.org/repos/asf/trafficserver.git commit 2250a414d8818b5f6b781a9ee9811521d6022e20 Author: Masaori KoshibaAuthorDate: Thu Oct 12 16:34:14 2017 +0900 Fix heap-use-after-free in QUICStreamFrame::store Make data of QUICStramFrame ats_unique_buf. Copy data of _write_vio to the buffer, when QUICStream sends frame. Ideally this malloc and copy should be avoided. --- iocore/net/quic/QUICFrame.cc | 11 +- iocore/net/quic/QUICFrame.h | 4 +- iocore/net/quic/test/test_QUICFrame.cc | 50 +- iocore/net/quic/test/test_QUICFrameDispatcher.cc | 7 +- iocore/net/quic/test/test_QUICStream.cc | 215 +-- 5 files changed, 174 insertions(+), 113 deletions(-) diff --git a/iocore/net/quic/QUICFrame.cc b/iocore/net/quic/QUICFrame.cc index 69951d4..4bb02b4 100644 --- a/iocore/net/quic/QUICFrame.cc +++ b/iocore/net/quic/QUICFrame.cc @@ -72,9 +72,9 @@ QUICFrame::reset(const uint8_t *buf, size_t len) // STREAM Frame // -QUICStreamFrame::QUICStreamFrame(const uint8_t *data, size_t data_len, QUICStreamId stream_id, QUICOffset offset, bool last) +QUICStreamFrame::QUICStreamFrame(ats_unique_buf data, size_t data_len, QUICStreamId stream_id, QUICOffset offset, bool last) { - this->_data = data; + this->_data = std::move(data); this->_data_len = data_len; this->_stream_id = stream_id; this->_offset= offset; @@ -183,7 +183,7 @@ QUICStreamFrame::data() const if (this->_buf) { return this->_buf + this->_get_data_offset(); } else { -return this->_data; +return this->_data.get(); } } @@ -1315,8 +1315,11 @@ QUICFrameFactory::fast_create(const uint8_t *buf, size_t len) QUICStreamFrameUPtr QUICFrameFactory::create_stream_frame(const uint8_t *data, size_t data_len, QUICStreamId stream_id, QUICOffset offset, bool last) { + ats_unique_buf buf = ats_unique_malloc(data_len); + memcpy(buf.get(), data, data_len); + QUICStreamFrame *frame = quicStreamFrameAllocator.alloc(); - new (frame) QUICStreamFrame(data, data_len, stream_id, offset, last); + new (frame) QUICStreamFrame(std::move(buf), data_len, stream_id, offset, last); return QUICStreamFrameUPtr(frame, ::delete_stream_frame); } diff --git a/iocore/net/quic/QUICFrame.h b/iocore/net/quic/QUICFrame.h index 772d65a..9f2b356 100644 --- a/iocore/net/quic/QUICFrame.h +++ b/iocore/net/quic/QUICFrame.h @@ -59,7 +59,7 @@ class QUICStreamFrame : public QUICFrame public: QUICStreamFrame() : QUICFrame() {} QUICStreamFrame(const uint8_t *buf, size_t len) : QUICFrame(buf, len) {} - QUICStreamFrame(const uint8_t *buf, size_t len, QUICStreamId streamid, QUICOffset offset, bool last = false); + QUICStreamFrame(ats_unique_buf buf, size_t len, QUICStreamId streamid, QUICOffset offset, bool last = false); virtual QUICFrameType type() const override; virtual size_t size() const override; virtual void store(uint8_t *buf, size_t *len) const override; @@ -74,7 +74,7 @@ public: LINK(QUICStreamFrame, link); private: - const uint8_t *_data= nullptr; + ats_unique_buf _data= {nullptr, [](void *p) { ats_free(p); }}; size_t _data_len= 0; QUICStreamId _stream_id = 0; QUICOffset _offset = 0; diff --git a/iocore/net/quic/test/test_QUICFrame.cc b/iocore/net/quic/test/test_QUICFrame.cc index 90c82fb..36f1eee 100644 --- a/iocore/net/quic/test/test_QUICFrame.cc +++ b/iocore/net/quic/test/test_QUICFrame.cc @@ -55,11 +55,14 @@ TEST_CASE("QUICFrame Type", "[quic]") TEST_CASE("Construct QUICFrame", "[quic]") { - uint8_t payload[] = "foo"; + uint8_t raw[] = "foo"; + ats_unique_buf payload = ats_unique_malloc(sizeof(raw)); + memcpy(payload.get(), raw, sizeof(raw)); + uint8_t buf[65536]; size_t len; - QUICStreamFrame frame1(payload, sizeof(payload), 0xffcc9966, 0xffddbb9977553311); + QUICStreamFrame frame1(std::move(payload), sizeof(raw), 0xffcc9966, 0xffddbb9977553311); frame1.store(buf, ); CHECK(frame1.type() == QUICFrameType::STREAM); CHECK(frame1.size() == 19); @@ -119,7 +122,12 @@ TEST_CASE("Store STREAM Frame", "[quic]") 0x00, 0x05, // Data Length 0x01, 0x02, 0x03, 0x04, 0x05, // Stream Data }; - QUICStreamFrame streamFrame1(reinterpret_cast("\x01\x02\x03\x04\x05"), 5, 0x01, 0x00); + + uint8_t raw1[] = "\x01\x02\x03\x04\x05"; + ats_unique_buf payload1 = ats_unique_malloc(5); + memcpy(payload1.get(), raw1, 5); + + QUICStreamFrame streamFrame1(std::move(payload1), 5, 0x01, 0x00); streamFrame1.store(buf, ); CHECK(len == 9); CHECK(memcmp(buf, expected1, len) == 0); @@ -132,7 +140,11 @@ TEST_CASE("Store STREAM Frame", "[quic]") 0x00, 0x05, // Data Length 0x01, 0x02, 0x03, 0x04, 0x05, // Stream Data }; -
[trafficserver] branch quic-latest updated: Fix heap-use-after-free
This is an automated email from the ASF dual-hosted git repository. masaori pushed a commit to branch quic-latest in repository https://gitbox.apache.org/repos/asf/trafficserver.git The following commit(s) were added to refs/heads/quic-latest by this push: new 88b5d7c Fix heap-use-after-free 88b5d7c is described below commit 88b5d7c71e1288400356adb6103f4ec18794652b Author: Masaori KoshibaAuthorDate: Thu Oct 12 15:39:31 2017 +0900 Fix heap-use-after-free Make data of QUICStramFrame ats_unique_buf. Copy data of _write_vio to the buffer, when QUICStream sends frame. Ideally this malloc and copy should be avoided. --- iocore/net/quic/QUICFrame.cc | 10 +- iocore/net/quic/QUICFrame.h| 6 +- iocore/net/quic/QUICStream.cc | 6 +- iocore/net/quic/test/test_QUICFrame.cc | 50 - iocore/net/quic/test/test_QUICFrameDispatcher.cc | 7 +- .../net/quic/test/test_QUICIncomingFrameBuffer.cc | 52 +++-- iocore/net/quic/test/test_QUICStream.cc| 215 - iocore/net/quic/test/test_QUICStreamManager.cc | 40 ++-- iocore/net/quic/test/test_QUICStreamState.cc | 48 - proxy/hq/HQClientTransaction.cc| 1 + 10 files changed, 273 insertions(+), 162 deletions(-) diff --git a/iocore/net/quic/QUICFrame.cc b/iocore/net/quic/QUICFrame.cc index 69951d4..8d2cc7f 100644 --- a/iocore/net/quic/QUICFrame.cc +++ b/iocore/net/quic/QUICFrame.cc @@ -72,9 +72,9 @@ QUICFrame::reset(const uint8_t *buf, size_t len) // STREAM Frame // -QUICStreamFrame::QUICStreamFrame(const uint8_t *data, size_t data_len, QUICStreamId stream_id, QUICOffset offset, bool last) +QUICStreamFrame::QUICStreamFrame(ats_unique_buf data, size_t data_len, QUICStreamId stream_id, QUICOffset offset, bool last) { - this->_data = data; + this->_data = std::move(data); this->_data_len = data_len; this->_stream_id = stream_id; this->_offset= offset; @@ -183,7 +183,7 @@ QUICStreamFrame::data() const if (this->_buf) { return this->_buf + this->_get_data_offset(); } else { -return this->_data; +return this->_data.get(); } } @@ -1313,10 +1313,10 @@ QUICFrameFactory::fast_create(const uint8_t *buf, size_t len) } QUICStreamFrameUPtr -QUICFrameFactory::create_stream_frame(const uint8_t *data, size_t data_len, QUICStreamId stream_id, QUICOffset offset, bool last) +QUICFrameFactory::create_stream_frame(ats_unique_buf data, size_t data_len, QUICStreamId stream_id, QUICOffset offset, bool last) { QUICStreamFrame *frame = quicStreamFrameAllocator.alloc(); - new (frame) QUICStreamFrame(data, data_len, stream_id, offset, last); + new (frame) QUICStreamFrame(std::move(data), data_len, stream_id, offset, last); return QUICStreamFrameUPtr(frame, ::delete_stream_frame); } diff --git a/iocore/net/quic/QUICFrame.h b/iocore/net/quic/QUICFrame.h index 772d65a..f84d328 100644 --- a/iocore/net/quic/QUICFrame.h +++ b/iocore/net/quic/QUICFrame.h @@ -59,7 +59,7 @@ class QUICStreamFrame : public QUICFrame public: QUICStreamFrame() : QUICFrame() {} QUICStreamFrame(const uint8_t *buf, size_t len) : QUICFrame(buf, len) {} - QUICStreamFrame(const uint8_t *buf, size_t len, QUICStreamId streamid, QUICOffset offset, bool last = false); + QUICStreamFrame(ats_unique_buf buf, size_t len, QUICStreamId streamid, QUICOffset offset, bool last = false); virtual QUICFrameType type() const override; virtual size_t size() const override; virtual void store(uint8_t *buf, size_t *len) const override; @@ -74,7 +74,7 @@ public: LINK(QUICStreamFrame, link); private: - const uint8_t *_data= nullptr; + ats_unique_buf _data= {nullptr, [](void *p) { ats_free(p); }}; size_t _data_len= 0; QUICStreamId _stream_id = 0; QUICOffset _offset = 0; @@ -591,7 +591,7 @@ public: * Creates a STREAM frame. * You have to make sure that the data size won't exceed the maximum size of QUIC packet. */ - static QUICStreamFrameUPtr create_stream_frame(const uint8_t *data, size_t data_len, QUICStreamId stream_id, QUICOffset offset, + static QUICStreamFrameUPtr create_stream_frame(ats_unique_buf data, size_t data_len, QUICStreamId stream_id, QUICOffset offset, bool last = false); /* * Creates a ACK frame. diff --git a/iocore/net/quic/QUICStream.cc b/iocore/net/quic/QUICStream.cc index f0ec0ff..3e99573 100644 --- a/iocore/net/quic/QUICStream.cc +++ b/iocore/net/quic/QUICStream.cc @@ -376,8 +376,10 @@ QUICStream::_send() break; } -QUICStreamFrameUPtr frame = QUICFrameFactory::create_stream_frame(reinterpret_cast(reader->start()), len, - this->_id, this->_send_offset, fin); +// TODO: avoid malloc & copy +ats_unique_buf data = ats_unique_malloc(len);