Kernel: Outbound packets should use the source address from the socket

Previously we'd use the adapter's address as the source address
when sending packets. Instead we should use the socket's bound local
address.
This commit is contained in:
Gunnar Beutner 2021-05-12 14:36:09 +02:00 committed by Andreas Kling
commit 2b6aa571d1
Notes: sideshowbarker 2024-07-18 18:17:45 +09:00
6 changed files with 16 additions and 13 deletions

View file

@ -206,7 +206,8 @@ KResultOr<size_t> IPv4Socket::sendto(FileDescription&, const UserOrKernelBuffer&
dbgln_if(IPV4_SOCKET_DEBUG, "sendto: destination={}:{}", m_peer_address, m_peer_port);
if (type() == SOCK_RAW) {
auto result = routing_decision.adapter->send_ipv4(routing_decision.next_hop, m_peer_address, (IPv4Protocol)protocol(), data, data_length, m_ttl);
auto result = routing_decision.adapter->send_ipv4(local_address(), routing_decision.next_hop,
m_peer_address, (IPv4Protocol)protocol(), data, data_length, m_ttl);
if (result.is_error())
return result;
return data_length;