From d815bbcbcc33fa98bf84e845aabe61cb61dc4dff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Wed, 4 Oct 2017 19:37:50 +0200 Subject: [PATCH] Revert "tcp: rfc 2018: implemented SACK option" This reverts commit 5c31f5a67a0aa37c8f2a1464252b2c5b0a959f33. --- .../network/protocols/tcp/BufferQueue.cpp | 35 ------------------- .../network/protocols/tcp/BufferQueue.h | 1 - .../network/protocols/tcp/TCPEndpoint.cpp | 22 ++---------- .../kernel/network/protocols/tcp/tcp.cpp | 23 +++--------- .../kernel/network/protocols/tcp/tcp.h | 5 ++- 5 files changed, 9 insertions(+), 77 deletions(-) diff --git a/src/add-ons/kernel/network/protocols/tcp/BufferQueue.cpp b/src/add-ons/kernel/network/protocols/tcp/BufferQueue.cpp index 4cf95c5e4a..de83ba3b31 100644 --- a/src/add-ons/kernel/network/protocols/tcp/BufferQueue.cpp +++ b/src/add-ons/kernel/network/protocols/tcp/BufferQueue.cpp @@ -436,41 +436,6 @@ BufferQueue::SetPushPointer() fPushPointer = fList.Tail()->sequence + fList.Tail()->size; } - -int -BufferQueue::PopulateSackInfo(tcp_sequence sequence, int maxSackCount, tcp_sack* sacks) -{ - SegmentList::ReverseIterator iterator = fList.GetReverseIterator(); - net_buffer* buffer = iterator.Next(); - - int sackCount = 0; - while (buffer != NULL && buffer->sequence > sequence) { - if (buffer->sequence + buffer->size < sacks[sackCount].left_edge) { - if (sackCount + 1 == maxSackCount) - break; - ++sackCount; - sacks[sackCount].left_edge = buffer->sequence; - sacks[sackCount].right_edge = buffer->sequence + buffer->size; - } else { - sacks[sackCount].left_edge = buffer->sequence; - if (sacks[sackCount].right_edge == 0) - sacks[sackCount].right_edge = buffer->sequence + buffer->size; - } - - buffer = iterator.Next(); - } - - if (sacks[0].left_edge != 0) { - for (int i = 0; i <= sackCount; ++i) { - sacks[i].left_edge = htonl(sacks[i].left_edge); - sacks[i].right_edge = htonl(sacks[i].right_edge); - } - ++sackCount; - } - - return sackCount; -} - #if DEBUG_BUFFER_QUEUE /*! Perform a sanity check of the whole queue. diff --git a/src/add-ons/kernel/network/protocols/tcp/BufferQueue.h b/src/add-ons/kernel/network/protocols/tcp/BufferQueue.h index 4c4567ee5f..73986a880c 100644 --- a/src/add-ons/kernel/network/protocols/tcp/BufferQueue.h +++ b/src/add-ons/kernel/network/protocols/tcp/BufferQueue.h @@ -42,7 +42,6 @@ public: inline size_t PushedData() const; void SetPushPointer(); - int PopulateSackInfo(tcp_sequence sequence, int maxSackCount, tcp_sack* sacks); size_t Used() const { return fNumBytes; } inline size_t Free() const; diff --git a/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp b/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp index aa28df9913..49e85d286a 100644 --- a/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp +++ b/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp @@ -318,8 +318,7 @@ enum { FLAG_CLOSED = 0x08, FLAG_DELETE_ON_CLOSE = 0x10, FLAG_LOCAL = 0x20, - FLAG_RECOVERY = 0x40, - FLAG_OPTION_SACK_PERMITTED = 0x80, + FLAG_RECOVERY = 0x40 }; @@ -449,7 +448,7 @@ TCPEndpoint::TCPEndpoint(net_socket* socket) fCongestionWindow(0), fSlowStartThreshold(0), fState(CLOSED), - fFlags(FLAG_OPTION_WINDOW_SCALE | FLAG_OPTION_TIMESTAMP | FLAG_OPTION_SACK_PERMITTED) + fFlags(FLAG_OPTION_WINDOW_SCALE | FLAG_OPTION_TIMESTAMP) { // TODO: to be replaced with a real read/write locking strategy! mutex_init(&fLock, "tcp lock"); @@ -1425,9 +1424,6 @@ TCPEndpoint::_PrepareReceivePath(tcp_segment_header& segment) fReceivedTimestamp = segment.timestamp_value; } else fFlags &= ~FLAG_OPTION_TIMESTAMP; - - if ((segment.options & TCP_SACK_PERMITTED) == 0) - fFlags &= ~FLAG_OPTION_SACK_PERMITTED; } fCongestionWindow = 2 * fSendMaxSegmentSize; @@ -2019,18 +2015,6 @@ TCPEndpoint::_SendQueued(bool force, uint32 sendWindow) segment.timestamp_value = tcp_now(); } - // SACK information is embedded with duplicate acknowledgements - if (!fReceiveQueue.IsContiguous() && fLastAcknowledgeSent == fReceiveNext - && (fFlags & FLAG_OPTION_SACK_PERMITTED) != 0) { - segment.options |= TCP_HAS_SACK; - int maxSackCount = 4 - ((fFlags & FLAG_OPTION_TIMESTAMP) != 0); - segment.sacks = (tcp_sack*)calloc(maxSackCount, sizeof(tcp_sack)); - if (segment.sacks != NULL) - segment.sackCount = fReceiveQueue.PopulateSackInfo(fReceiveNext, maxSackCount, segment.sacks); - else - segment.sackCount = 0; - } - if ((segment.flags & TCP_FLAG_SYNCHRONIZE) != 0 && fSendNext == fInitialSendSequence) { // add connection establishment options @@ -2039,8 +2023,6 @@ TCPEndpoint::_SendQueued(bool force, uint32 sendWindow) segment.options |= TCP_HAS_WINDOW_SCALE; segment.window_shift = fReceiveWindowShift; } - if ((fFlags & FLAG_OPTION_SACK_PERMITTED) != 0) - segment.options |= TCP_SACK_PERMITTED; } } diff --git a/src/add-ons/kernel/network/protocols/tcp/tcp.cpp b/src/add-ons/kernel/network/protocols/tcp/tcp.cpp index 9f4a3293d8..b14f662574 100644 --- a/src/add-ons/kernel/network/protocols/tcp/tcp.cpp +++ b/src/add-ons/kernel/network/protocols/tcp/tcp.cpp @@ -140,10 +140,10 @@ add_options(tcp_segment_header &segment, uint8 *buffer, size_t bufferSize) bump_option(option, length); } - if (segment.sackCount > 0) { + if (segment.sack_count > 0) { int sackCount = ((int)(bufferSize - length) - 4) / sizeof(tcp_sack); - if (sackCount > segment.sackCount) - sackCount = segment.sackCount; + if (sackCount > segment.sack_count) + sackCount = segment.sack_count; if (sackCount > 0) { option->kind = TCP_OPTION_NOP; @@ -154,7 +154,6 @@ add_options(tcp_segment_header &segment, uint8 *buffer, size_t bufferSize) option->length = 2 + sackCount * sizeof(tcp_sack); memcpy(option->sack, segment.sacks, sackCount * sizeof(tcp_sack)); bump_option(option, length); - free(segment.sacks); } } @@ -219,18 +218,6 @@ process_options(tcp_segment_header &segment, net_buffer *buffer, size_t size) if (option->length == 2 && size >= 2) segment.options |= TCP_SACK_PERMITTED; break; - case TCP_OPTION_SACK: - if (size >= option->length) { - segment.options |= TCP_HAS_SACK; - segment.sackCount = (option->length - 2) / sizeof(tcp_sack); - segment.sacks = option->sack; - - for (int i = 0; i < segment.sackCount; ++i) { - segment.sacks[i].left_edge = ntohl(segment.sacks[i].left_edge); - segment.sacks[i].right_edge = ntohl(segment.sacks[i].right_edge); - } - } - break; } if (length < 0) { @@ -445,9 +432,9 @@ tcp_options_length(tcp_segment_header& segment) if (segment.options & TCP_SACK_PERMITTED) length += 2; - if (segment.sackCount > 0) { + if (segment.sack_count > 0) { int sackCount = min_c((int)((kMaxOptionSize - length - 4) - / sizeof(tcp_sack)), segment.sackCount); + / sizeof(tcp_sack)), segment.sack_count); if (sackCount > 0) length += 4 + sackCount * sizeof(tcp_sack); } diff --git a/src/add-ons/kernel/network/protocols/tcp/tcp.h b/src/add-ons/kernel/network/protocols/tcp/tcp.h index 9b7f568f33..6f30ec2943 100644 --- a/src/add-ons/kernel/network/protocols/tcp/tcp.h +++ b/src/add-ons/kernel/network/protocols/tcp/tcp.h @@ -229,7 +229,6 @@ enum { TCP_HAS_WINDOW_SCALE = 1 << 0, TCP_HAS_TIMESTAMPS = 1 << 1, TCP_SACK_PERMITTED = 1 << 2, - TCP_HAS_SACK = 1 << 3, }; struct tcp_segment_header { @@ -238,7 +237,7 @@ struct tcp_segment_header { flags(_flags), window_shift(0), max_segment_size(0), - sackCount(0), + sack_count(0), options(0) {} @@ -254,7 +253,7 @@ struct tcp_segment_header { uint32 timestamp_reply; tcp_sack *sacks; - int sackCount; + int sack_count; uint32 options;