Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 26 additions & 16 deletions src/dhcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -3128,15 +3128,35 @@ dhcp_handledhcp(struct interface *ifp, struct bootp *bootp, size_t bootp_len,
return;
}

if (state->xid != ntohl(bootp->xid)) {
if (IS_STATE_ACTIVE(state))
logdebugx("%s: wrong xid 0x%x (expecting 0x%x) from %s",
ifp->name, ntohl(bootp->xid), state->xid,
inet_ntoa(*from));
dhcp_redirect_dhcp(ifp, bootp, bootp_len, from);
/* We may have found a BOOTP server */
if (get_option_uint8(ifp->ctx, &type, bootp, bootp_len,
DHO_MESSAGETYPE) == -1)
type = 0;
else if (ifo->options & DHCPCD_BOOTP) {
logdebugx("%s: ignoring DHCP reply (expecting BOOTP)",
ifp->name);
return;
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
}

if (state->xid != ntohl(bootp->xid)) {
/* If the xid is 0 in a BOOTP reply FORCERENEW, move on and
* check AUTH. MikroTik dhpc servers send xid 0. */
if (bootp->xid == 0 && type == DHCP_FORCERENEW) {
Comment thread
coderabbitai[bot] marked this conversation as resolved.
if (IS_STATE_ACTIVE(state))
logdebugx(
"%s: xid 0 in a BOOTP reply FORCERENEW from %s",
ifp->name, inet_ntoa(*from));
} else {
if (IS_STATE_ACTIVE(state))
logdebugx(
"%s: wrong xid 0x%x (expecting 0x%x) from %s",
ifp->name, ntohl(bootp->xid), state->xid,
inet_ntoa(*from));
dhcp_redirect_dhcp(ifp, bootp, bootp_len, from);
return;
}
}

if (ifp->hwlen <= sizeof(bootp->chaddr) &&
memcmp(bootp->chaddr, ifp->hwaddr, ifp->hwlen)) {
if (IS_STATE_ACTIVE(state)) {
Expand Down Expand Up @@ -3170,16 +3190,6 @@ dhcp_handledhcp(struct interface *ifp, struct bootp *bootp, size_t bootp_len,
}
}

/* We may have found a BOOTP server */
if (get_option_uint8(ifp->ctx, &type, bootp, bootp_len,
DHO_MESSAGETYPE) == -1)
type = 0;
else if (ifo->options & DHCPCD_BOOTP) {
logdebugx("%s: ignoring DHCP reply (expecting BOOTP)",
ifp->name);
return;
}

#ifdef AUTH
/* Authenticate the message */
auth = get_option(ifp->ctx, bootp, bootp_len, DHO_AUTHENTICATION,
Expand Down