uint64_t discover_attempt;
uint64_t request_attempt;
uint64_t max_discover_attempts;
- uint64_t max_request_attempts;
OrderedHashmap *extra_options;
OrderedHashmap *vendor_options;
sd_event_source *timeout_t1;
#define RESTART_AFTER_NAK_MIN_USEC (1 * USEC_PER_SEC)
#define RESTART_AFTER_NAK_MAX_USEC (30 * USEC_PER_MINUTE)
+#define MAX_REQUEST_ATTEMPTS 5
#define TRANSIENT_FAILURE_ATTEMPTS 3 /* Arbitrary limit: how many attempts are considered enough to report
* transient failure. */
break;
case DHCP_STATE_REQUESTING:
case DHCP_STATE_BOUND:
- if (client->request_attempt >= client->max_request_attempts)
+ if (client->request_attempt >= MAX_REQUEST_ATTEMPTS)
goto error;
client->request_attempt++;
case DHCP_STATE_RENEWING:
case DHCP_STATE_REBINDING:
r = client_send_request(client);
- if (r < 0 && client->request_attempt >= client->max_request_attempts)
+ if (r < 0 && client->request_attempt >= MAX_REQUEST_ATTEMPTS)
goto error;
if (client->state == DHCP_STATE_INIT_REBOOT)
/* Avoid REQUEST infinite loop. Per RFC 2131 section 3.1.5: if the client receives
neither a DHCPACK or a DHCPNAK message after employing the retransmission algorithm,
the client reverts to INIT state and restarts the initialization process */
- if (client->request_attempt >= client->max_request_attempts) {
+ if (client->request_attempt >= MAX_REQUEST_ATTEMPTS) {
log_dhcp_client(client, "Max REQUEST attempts reached. Restarting...");
r = client_restart(client);
if (r >= 0)
.server_port = DHCP_PORT_SERVER,
.anonymize = !!anonymize,
.max_discover_attempts = UINT64_MAX,
- .max_request_attempts = 5,
.ip_service_type = -1,
};
/* NOTE: this could be moved to a function. */