mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 19:38:12 +00:00
Kernel/Net: Add TCPSocket timer for TimeWait moving to Closed
RFC9293 states that from the TimeWait state the TCPSocket should wait the MSL (2mins) for delayed segments to expire so that their sequence numbers do not clash with a new connection's sequence numbers using the same ip address and port number. The wait also ensures the remote TCP peer has received the ACK to their FIN segment.
This commit is contained in:
parent
c87e1084b6
commit
b9cfb50f71
2 changed files with 37 additions and 9 deletions
|
@ -15,6 +15,7 @@
|
|||
#include <Kernel/Library/LockWeakPtr.h>
|
||||
#include <Kernel/Locking/MutexProtected.h>
|
||||
#include <Kernel/Net/IPv4Socket.h>
|
||||
#include <Kernel/Time/TimerQueue.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
|
@ -179,7 +180,7 @@ protected:
|
|||
void set_direction(Direction direction) { m_direction = direction; }
|
||||
|
||||
private:
|
||||
explicit TCPSocket(int protocol, NonnullOwnPtr<DoubleBuffer> receive_buffer, NonnullOwnPtr<KBuffer> scratch_buffer);
|
||||
explicit TCPSocket(int protocol, NonnullOwnPtr<DoubleBuffer> receive_buffer, NonnullOwnPtr<KBuffer> scratch_buffer, NonnullRefPtr<Timer> timer);
|
||||
virtual StringView class_name() const override { return "TCPSocket"sv; }
|
||||
|
||||
virtual void shut_down_for_writing() override;
|
||||
|
@ -192,6 +193,8 @@ private:
|
|||
virtual ErrorOr<void> protocol_bind() override;
|
||||
virtual ErrorOr<void> protocol_listen() override;
|
||||
|
||||
void do_state_closed();
|
||||
|
||||
void enqueue_for_retransmit();
|
||||
void dequeue_for_retransmit();
|
||||
|
||||
|
@ -236,6 +239,8 @@ private:
|
|||
u32 m_last_ack_number_sent { 0 };
|
||||
MonotonicTime m_last_ack_sent_time;
|
||||
|
||||
static constexpr Duration maximum_segment_lifetime = Duration::from_seconds(120);
|
||||
|
||||
// FIXME: Make this configurable (sysctl)
|
||||
static constexpr u32 maximum_retransmits = 5;
|
||||
MonotonicTime m_last_retransmit_time;
|
||||
|
@ -253,6 +258,8 @@ private:
|
|||
|
||||
Optional<IPv4SocketTuple> m_registered_socket_tuple;
|
||||
|
||||
NonnullRefPtr<Timer> m_timer;
|
||||
|
||||
public:
|
||||
using RetransmitList = IntrusiveList<&TCPSocket::m_retransmit_list_node>;
|
||||
static MutexProtected<TCPSocket::RetransmitList>& sockets_for_retransmit();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue