From 868583b54a8fb3706b5e68c3ed5420d70f4d3d45 Mon Sep 17 00:00:00 2001 From: Hugo Santos Date: Tue, 3 Apr 2007 07:00:04 +0000 Subject: [PATCH] fixed a potential problem in TCP's accept() with the init'ing of new connections' MSS git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20527 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kernel/network/protocols/tcp/TCPEndpoint.cpp | 12 +++++++++--- .../kernel/network/protocols/tcp/TCPEndpoint.h | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp b/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp index e1765f48c9..ed19ef5a55 100644 --- a/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp +++ b/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp @@ -236,8 +236,7 @@ TCPEndpoint::Connect(const struct sockaddr *address) return status; } - fReceiveMaxSegmentSize = next->module->get_mtu(next, (sockaddr *)address) - - sizeof(tcp_header); + fReceiveMaxSegmentSize = _GetMSS(address); // Compute the window shift we advertise to our peer - if it doesn't support // this option, this will be reset to 0 (when its SYN is received) @@ -597,7 +596,7 @@ TCPEndpoint::ListenReceive(tcp_segment_header &segment, net_buffer *buffer) endpoint->fReceiveQueue.SetInitialSequence(segment.sequence + 1); endpoint->fState = SYNCHRONIZE_RECEIVED; endpoint->fAcceptSemaphore = fAcceptSemaphore; - endpoint->fReceiveMaxSegmentSize = endpoint->fRoute->mtu - 40; + endpoint->fReceiveMaxSegmentSize = _GetMSS((sockaddr *)&newSocket->peer); // 40 bytes for IP and TCP header without any options // TODO: make this depending on the RTF_LOCAL flag? endpoint->fReceiveNext = segment.sequence + 1; @@ -1208,6 +1207,13 @@ TCPEndpoint::_SendQueued(bool force) } +int +TCPEndpoint::_GetMSS(const sockaddr *address) const +{ + return next->module->get_mtu(next, (sockaddr *)address) - sizeof(tcp_header); +} + + // #pragma mark - timer diff --git a/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.h b/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.h index bfc54b0bf3..ee5ff14ba5 100644 --- a/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.h +++ b/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.h @@ -65,6 +65,7 @@ class TCPEndpoint : public net_protocol { bool _ShouldSendSegment(tcp_segment_header &segment, uint32 length, bool outstandingAcknowledge); status_t _SendQueued(bool force = false); + int _GetMSS(const struct sockaddr *) const; static void _TimeWaitTimer(net_timer *timer, void *data); static void _RetransmitTimer(net_timer *timer, void *data);