Skip to content

Commit

Permalink
Kernel: Send ACK/FIN in response to FIN packets on active connections
Browse files Browse the repository at this point in the history
This is to work around our lack of a shutdown() implementation.
  • Loading branch information
deoxxa authored and awesomekling committed Sep 8, 2019
1 parent 117d8db commit 328d52b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Kernel/Net/NetworkTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 328d52b

Please sign in to comment.