mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:57:35 +00:00
DHCPClient: Retry DISCOVER for interfaces that fail
Attempts are spaced out with exponential backoff, cut at 10 minutes per attempt. Also avoid trying to acquire an IP on interfaces that aren't up. Fixes #6126. Fixes #6125.
This commit is contained in:
parent
8b0f1f816b
commit
c6607719d2
3 changed files with 129 additions and 54 deletions
|
@ -29,6 +29,7 @@
|
|||
#include "DHCPv4.h"
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/Result.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibCore/UDPServer.h>
|
||||
|
@ -59,7 +60,7 @@ class DHCPv4Client final : public Core::Object {
|
|||
C_OBJECT(DHCPv4Client)
|
||||
|
||||
public:
|
||||
explicit DHCPv4Client(Vector<InterfaceDescriptor> ifnames);
|
||||
explicit DHCPv4Client(Vector<InterfaceDescriptor> ifnames_for_immediate_discover, Vector<InterfaceDescriptor> ifnames_for_later);
|
||||
virtual ~DHCPv4Client() override;
|
||||
|
||||
void dhcp_discover(const InterfaceDescriptor& ifname);
|
||||
|
@ -69,10 +70,21 @@ public:
|
|||
|
||||
bool id_is_registered(u32 id) { return m_ongoing_transactions.contains(id); }
|
||||
|
||||
struct Interfaces {
|
||||
Vector<InterfaceDescriptor> ready;
|
||||
Vector<InterfaceDescriptor> not_ready;
|
||||
};
|
||||
static Result<Interfaces, String> get_discoverable_interfaces();
|
||||
|
||||
private:
|
||||
void try_discover_deferred_ifs();
|
||||
|
||||
HashMap<u32, OwnPtr<DHCPv4Transaction>> m_ongoing_transactions;
|
||||
Vector<InterfaceDescriptor> m_ifnames;
|
||||
Vector<InterfaceDescriptor> m_ifnames_for_immediate_discover;
|
||||
Vector<InterfaceDescriptor> m_ifnames_for_later;
|
||||
RefPtr<Core::UDPServer> m_server;
|
||||
RefPtr<Core::Timer> m_fail_check_timer;
|
||||
int m_max_timer_backoff_interval { 600000 }; // 10 minutes
|
||||
|
||||
void handle_offer(const DHCPv4Packet&, const ParsedDHCPv4Options&);
|
||||
void handle_ack(const DHCPv4Packet&, const ParsedDHCPv4Options&);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue