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);