Kernel: Put some network log messages behind debug flags

This commit is contained in:
Conrad Pankoff 2019-09-08 19:13:50 +10:00 committed by Andreas Kling
parent 328d52b323
commit a2b61e30c5
Notes: sideshowbarker 2024-07-19 12:11:48 +09:00
3 changed files with 12 additions and 0 deletions

View File

@ -190,7 +190,9 @@ ssize_t IPv4Socket::sendto(FileDescription&, const void* data, size_t data_lengt
if (rc < 0)
return rc;
#ifdef IPV4_SOCKET_DEBUG
kprintf("sendto: destination=%s:%u\n", m_peer_address.to_string().characters(), m_peer_port);
#endif
if (type() == SOCK_RAW) {
routing_decision.adapter->send_ipv4(routing_decision.next_hop, m_peer_address, (IPv4Protocol)protocol(), (const u8*)data, data_length);

View File

@ -389,7 +389,9 @@ void handle_tcp(const IPv4Packet& ipv4_packet)
case TCPSocket::State::Listen:
switch (tcp_packet.flags()) {
case TCPFlags::SYN: {
#ifdef TCP_DEBUG
kprintf("handle_tcp: incoming connection\n");
#endif
auto& local_address = ipv4_packet.destination();
auto& peer_address = ipv4_packet.source();
auto client = socket->create_client(local_address, tcp_packet.destination_port(), peer_address, tcp_packet.source_port());
@ -397,7 +399,9 @@ void handle_tcp(const IPv4Packet& ipv4_packet)
kprintf("handle_tcp: couldn't create client socket\n");
return;
}
#ifdef TCP_DEBUG
kprintf("handle_tcp: created new client socket with tuple %s\n", client->tuple().to_string().characters());
#endif
client->set_sequence_number(1000);
client->set_ack_number(tcp_packet.sequence_number() + payload_size + 1);
client->send_tcp_packet(TCPFlags::SYN | TCPFlags::ACK);

View File

@ -219,13 +219,17 @@ void TCPSocket::receive_tcp_packet(const TCPPacket& packet, u16 size)
if (packet.has_ack()) {
u32 ack_number = packet.ack_number();
#ifdef TCP_SOCKET_DEBUG
dbg() << "TCPSocket: receive_tcp_packet: " << ack_number;
#endif
int removed = 0;
while (!m_not_acked.is_empty()) {
auto& packet = m_not_acked.first();
#ifdef TCP_SOCKET_DEBUG
dbg() << "TCPSocket: iterate: " << packet.ack_number;
#endif
if (packet.ack_number <= ack_number) {
m_not_acked.take_first();
@ -235,7 +239,9 @@ void TCPSocket::receive_tcp_packet(const TCPPacket& packet, u16 size)
}
}
#ifdef TCP_SOCKET_DEBUG
dbg() << "TCPSocket: receive_tcp_packet acknowledged " << removed << " packets";
#endif
}
m_packets_in++;