Rather than reboot time.
This allows reboot time of zero to skip the using old leases
while still allowing REQUESTs to gracefully fallback to DISCOVER.
request_time has a default of 180 seconds to mirror the DHCPv6
equivalent.
fallback_time and ipv4_ll time have a default of 5 seconds
to mirror the default reboot time.
Fixes #325 and affects #255.
dhcp_new_xid(ifp);
eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp);
if (!(state->added & STATE_EXPIRED)) {
- if (ifo->fallback)
+ if (ifo->fallback && ifo->fallback_time)
eloop_timeout_add_sec(ifp->ctx->eloop,
- ifo->reboot, dhcp_fallback, ifp);
+ ifo->fallback_time, dhcp_fallback, ifp);
#ifdef IPV4LL
else if (ifo->options & DHCPCD_IPV4LL)
eloop_timeout_add_sec(ifp->ctx->eloop,
- ifo->reboot, ipv4ll_start, ifp);
+ ifo->ipv4ll_time, ipv4ll_start, ifp);
#endif
}
if (ifo->options & DHCPCD_REQUEST)
{
struct interface *ifp = arg;
struct dhcp_state *state = D_STATE(ifp);
+ struct if_options *ifo = ifp->options;
state->state = DHS_REQUEST;
// Handle the server being silent to our request.
- eloop_timeout_add_sec(ifp->ctx->eloop, ifp->options->reboot,
- dhcp_requestfailed, ifp);
+ if (ifo->request_time != 0)
+ eloop_timeout_add_sec(ifp->ctx->eloop, ifo->request_time,
+ dhcp_requestfailed, ifp);
send_request(ifp);
}
/* Need to add this before dhcp_expire and friends. */
if (!ifo->fallback && ifo->options & DHCPCD_IPV4LL)
eloop_timeout_add_sec(ifp->ctx->eloop,
- ifo->reboot, ipv4ll_start, ifp);
+ ifo->ipv4ll_time, ipv4ll_start, ifp);
#endif
if (ifo->options & DHCPCD_LASTLEASE && state->lease.frominfo)
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd December 21, 2023
+.Dd May 24, 2024
.Dt DHCPCD.CONF 5
.Os
.Sh NAME
.It Ic fallback Ar profile
Fall back to using this profile if DHCP fails.
This allows you to configure a static profile instead of using ZeroConf.
+.It Ic fallback_time Ar seconds
+Start fallback after
+.Ar seconds .
+The default is 5 seconds.
.It Ic hostname Ar name
Sends the hostname
.Ar name
.It Ic interface Ar interface
Subsequent options are only parsed for this
.Ar interface .
+.It Ic ipv4ll_time Ar seconds
+Wait for
+.Ar seconds
+before starting IPv4LL.
+The default is 5 seconds.
.It Ic ipv6ra_autoconf
Generate SLAAC addresses for each Prefix advertised by an IPv6
Router Advertisement message with the Auto flag set.
.Ar script
instead of the default
.Pa @SCRIPT@ .
+.It Ic request_time Ar seconds
+Request the lease for
+.Ar seconds
+before going back to DISCOVER.
+The default is 180 seconds.
.It Ic ssid Ar ssid
Subsequent options are only parsed for this wireless
.Ar ssid .
{"configure", no_argument, NULL, O_CONFIGURE},
{"noconfigure", no_argument, NULL, O_NOCONFIGURE},
{"arp_persistdefence", no_argument, NULL, O_ARP_PERSISTDEFENCE},
+ {"request_time", required_argument, NULL, O_REQUEST_TIME},
+ {"fallback_time", required_argument, NULL, O_FALLBACK_TIME},
+ {"ipv4ll_time", required_argument, NULL, O_IPV4LL_TIME},
{NULL, 0, NULL, '\0'}
};
case O_ARP_PERSISTDEFENCE:
ifo->options |= DHCPCD_ARP_PERSISTDEFENCE;
break;
+ case O_REQUEST_TIME:
+ ARG_REQUIRED;
+ ifo->request_time =
+ (uint32_t)strtou(arg, NULL, 0, 0, UINT32_MAX, &e);
+ if (e) {
+ logerrx("invalid request time: %s", arg);
+ return -1;
+ }
+ break;
+#ifdef INET
+ case O_FALLBACK_TIME:
+ ARG_REQUIRED;
+ ifo->request_time =
+ (uint32_t)strtou(arg, NULL, 0, 0, UINT32_MAX, &e);
+ if (e) {
+ logerrx("invalid fallback time: %s", arg);
+ return -1;
+ }
+ break;
+ case O_IPV4LL_TIME:
+ ARG_REQUIRED;
+ ifo->ipv4ll_time =
+ (uint32_t)strtou(arg, NULL, 0, 0, UINT32_MAX, &e);
+ if (e) {
+ logerrx("invalid ipv4ll time: %s", arg);
+ return -1;
+ }
+ break;
+#endif
default:
return 0;
}
ifo->options |= DHCPCD_IF_UP | DHCPCD_LINK | DHCPCD_INITIAL_DELAY;
ifo->timeout = DEFAULT_TIMEOUT;
ifo->reboot = DEFAULT_REBOOT;
+ ifo->request_time = DEFAULT_REQUEST;
+#ifdef INET
+ ifo->fallback_time = DEFAULT_FALLBACK;
+ ifo->ipv4ll_time = DEFAULT_IPV4LL;
+#endif
ifo->metric = -1;
ifo->auth.options |= DHCPCD_AUTH_REQUIRE;
rb_tree_init(&ifo->routes, &rt_compare_list_ops);
#define DEFAULT_TIMEOUT 30
#define DEFAULT_REBOOT 5
+#define DEFAULT_REQUEST 180 /* secs to request, mirror DHCP6 */
+#define DEFAULT_FALLBACK 5 /* secs until fallback */
+#define DEFAULT_IPV4LL 5 /* secs until ipv4ll */
#ifndef HOSTNAME_MAX_LEN
#define HOSTNAME_MAX_LEN 250 /* 255 - 3 (FQDN) - 2 (DNS enc) */
#define O_NOCONFIGURE O_BASE + 51
#define O_RANDOMISE_HWADDR O_BASE + 52
#define O_ARP_PERSISTDEFENCE O_BASE + 53
+#define O_REQUEST_TIME O_BASE + 54
+#define O_FALLBACK_TIME O_BASE + 55
+#define O_IPV4LL_TIME O_BASE + 56
extern const struct option cf_options[];
uint32_t leasetime;
uint32_t timeout;
uint32_t reboot;
+ uint32_t request_time;
+ uint32_t fallback_time;
+ uint32_t ipv4ll_time;
unsigned long long options;
bool randomise_hwaddr;