* arping profile */
if (++state->arping_index < ifo->arping_len) {
astate->addr.s_addr =
- ifo->arping[state->arping_index - 1];
+ ifo->arping[state->arping_index];
arp_probe(astate);
return;
}
#ifdef ARPING
ifo = ifp->options;
- if (state->arping_index &&
- state->arping_index <= ifo->arping_len &&
+ if (state->arping_index != -1 &&
+ state->arping_index < ifo->arping_len &&
amsg &&
- (amsg->sip.s_addr == ifo->arping[state->arping_index - 1] ||
+ (amsg->sip.s_addr == ifo->arping[state->arping_index] ||
(amsg->sip.s_addr == 0 &&
- amsg->tip.s_addr == ifo->arping[state->arping_index - 1])))
+ amsg->tip.s_addr == ifo->arping[state->arping_index])))
{
char buf[HWADDR_LEN * 3];
- astate->failed.s_addr = ifo->arping[state->arping_index - 1];
+ astate->failed.s_addr = ifo->arping[state->arping_index];
arp_report_conflicted(astate, amsg);
hwaddr_ntoa(amsg->sha, ifp->hwlen, buf, sizeof(buf));
if (dhcpcd_selectprofile(ifp, buf) == -1 &&
return;
}
+#ifdef ARPING
+ state->arping_index = -1;
+#endif
if (ifp->options->options & DHCPCD_RELEASE &&
!(ifp->options->options & DHCPCD_INFORM))
{
/* 0 is a valid fd, so init to -1 */
state->raw_fd = -1;
+#ifdef ARPING
+ state->arping_index = -1;
+#endif
/* Now is a good time to find IPv4 routes */
if_initrt(ifp->ctx, AF_INET);
}
dhcp_start(struct interface *ifp)
{
struct timespec tv;
+#ifdef ARPING
+ const struct dhcp_state *state;
+#endif
if (!(ifp->options->options & DHCPCD_IPV4))
return;
return;
}
+#ifdef ARPING
+ /* If we have arpinged then we have already delayed. */
+ state = D_CSTATE(ifp);
+ if (state != NULL && state->arping_index != -1) {
+ dhcp_start1(ifp);
+ return;
+ }
+#endif
+
tv.tv_sec = DHCP_MIN_DELAY;
tv.tv_nsec = (suseconds_t)arc4random_uniform(
(DHCP_MAX_DELAY - DHCP_MIN_DELAY) * NSEC_PER_SEC);
void
dhcp_abort(struct interface *ifp)
{
+#ifdef ARPING
+ struct dhcp_state *state;
+
+ state = D_STATE(ifp);
+ if (state != NULL)
+ state->arping_index = -1;
+#endif
eloop_timeout_delete(ifp->ctx->eloop, dhcp_start1, ifp);
}
if (parse_addr(ctx, &addr, NULL, arg) != 0)
return -1;
naddr = realloc(ifo->arping,
- sizeof(in_addr_t) * (ifo->arping_len + 1));
+ sizeof(in_addr_t) * ((size_t)ifo->arping_len + 1));
if (naddr == NULL) {
logger(ctx, LOG_ERR, "%s: %m", __func__);
return -1;