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
This commit is contained in:
Hugo Santos 2007-04-03 07:00:04 +00:00
parent 02a6d07927
commit 868583b54a
2 changed files with 10 additions and 3 deletions

View File

@ -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

View File

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