summaryrefslogtreecommitdiff
path: root/Kernel/Net/NetworkTask.cpp
diff options
context:
space:
mode:
authorBrian Gianforcaro <bgianf@serenityos.org>2021-08-01 05:11:49 -0700
committerAndreas Kling <kling@serenityos.org>2021-08-03 18:54:23 +0200
commit720a686a761b476ff0a793b243f6cc2848fffd04 (patch)
tree9f4bf339947849a64c217e41035e49fe672cc206 /Kernel/Net/NetworkTask.cpp
parent8c4785bd10d16ec33b994de38bf444e927dc782a (diff)
downloadserenity-720a686a761b476ff0a793b243f6cc2848fffd04.zip
Kernel: Handle OOM when allocating Packet KBuffers
Diffstat (limited to 'Kernel/Net/NetworkTask.cpp')
-rw-r--r--Kernel/Net/NetworkTask.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/Kernel/Net/NetworkTask.cpp b/Kernel/Net/NetworkTask.cpp
index 6745f51144..04b3d4d71e 100644
--- a/Kernel/Net/NetworkTask.cpp
+++ b/Kernel/Net/NetworkTask.cpp
@@ -254,8 +254,8 @@ void handle_icmp(EthernetFrameHeader const& eth, IPv4Packet const& ipv4_packet,
return;
}
adapter->fill_in_ipv4_header(*packet, adapter->ipv4_address(), eth.source(), ipv4_packet.source(), IPv4Protocol::ICMP, icmp_packet_size, 64);
- memset(packet->buffer.data() + ipv4_payload_offset, 0, sizeof(ICMPEchoPacket));
- auto& response = *(ICMPEchoPacket*)(packet->buffer.data() + ipv4_payload_offset);
+ memset(packet->buffer->data() + ipv4_payload_offset, 0, sizeof(ICMPEchoPacket));
+ auto& response = *(ICMPEchoPacket*)(packet->buffer->data() + ipv4_payload_offset);
response.header.set_type(ICMPType::EchoReply);
response.header.set_code(0);
response.identifier = request.identifier;
@@ -264,7 +264,7 @@ void handle_icmp(EthernetFrameHeader const& eth, IPv4Packet const& ipv4_packet,
memcpy(response.payload(), request.payload(), icmp_payload_size);
response.header.set_checksum(internet_checksum(&response, icmp_packet_size));
// FIXME: What is the right TTL value here? Is 64 ok? Should we use the same TTL as the echo request?
- adapter->send_packet({ packet->buffer.data(), packet->buffer.size() });
+ adapter->send_packet(packet->bytes());
adapter->release_packet_buffer(*packet);
}
}
@@ -359,7 +359,7 @@ void send_tcp_rst(IPv4Packet const& ipv4_packet, TCPPacket const& tcp_packet, Re
rst_packet.set_flags(TCPFlags::RST | TCPFlags::ACK);
rst_packet.set_checksum(TCPSocket::compute_tcp_checksum(ipv4_packet.source(), ipv4_packet.destination(), rst_packet, 0));
- routing_decision.adapter->send_packet({ packet->buffer.data(), packet->buffer.size() });
+ routing_decision.adapter->send_packet(packet->bytes());
routing_decision.adapter->release_packet_buffer(*packet);
}