nic_router: prevent ARP request without ARP waiter

The router used to send an ARP request for a packet before allocating the
corresponding ARP waiter. If the ARP waiter could not be allocated due to
resource exhaustion plus emergency free failed, the packet got dropped and the
router had produced unnecessary network traffic. The commit fixes this by
sending only after successful allocation.

Ref #4534
This commit is contained in:
Martin Stein 2024-06-18 12:31:51 +02:00 committed by Norman Feske
parent 682dedb2e1
commit 31a438edf6

View File

@ -605,14 +605,14 @@ Packet_result Interface::_adapt_eth(Ethernet_frame &eth,
},
[&] /* handle_no_match */ ()
{
remote_domain.interfaces().for_each([&] (Interface &interface)
{
interface._broadcast_arp_request(
remote_ip_cfg.interface().address, hop_ip);
});
retry_once<Out_of_ram, Out_of_caps>(
[&] {
new (_alloc) Arp_waiter { *this, remote_domain, hop_ip, pkt, _config_ptr->arp_request_timeout(), _timer };
remote_domain.interfaces().for_each([&] (Interface &interface)
{
interface._broadcast_arp_request(
remote_ip_cfg.interface().address, hop_ip);
});
result = packet_postponed();
},
[&] { _try_emergency_free_quota(); },