From 328d52b323a59663a9bc89667613dd00f252453d Mon Sep 17 00:00:00 2001 From: Conrad Pankoff Date: Sun, 8 Sep 2019 17:42:19 +1000 Subject: [PATCH] Kernel: Send ACK/FIN in response to FIN packets on active connections This is to work around our lack of a shutdown() implementation. --- Kernel/Net/NetworkTask.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Kernel/Net/NetworkTask.cpp b/Kernel/Net/NetworkTask.cpp index 55a6b98a3d..67aaf90a42 100644 --- a/Kernel/Net/NetworkTask.cpp +++ b/Kernel/Net/NetworkTask.cpp @@ -527,8 +527,12 @@ void handle_tcp(const IPv4Packet& ipv4_packet) socket->did_receive(ipv4_packet.source(), tcp_packet.source_port(), KBuffer::copy(&ipv4_packet, sizeof(IPv4Packet) + ipv4_packet.payload_size())); socket->set_ack_number(tcp_packet.sequence_number() + payload_size + 1); - socket->send_tcp_packet(TCPFlags::ACK); - socket->set_state(TCPSocket::State::CloseWait); + // TODO: We should only send a FIN packet out once we're shutting + // down our side of the socket, so we should change this back to + // just being an ACK and a transition to CloseWait once we have a + // shutdown() implementation. + socket->send_tcp_packet(TCPFlags::FIN | TCPFlags::ACK); + socket->set_state(TCPSocket::State::Closing); socket->set_connected(false); return; }