]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
DHCP: redirect message to other interfaces if received for inactive
authorRoy Marples <roy@marples.name>
Sun, 26 Jan 2020 16:44:40 +0000 (16:44 +0000)
committerRoy Marples <roy@marples.name>
Sun, 26 Jan 2020 16:44:40 +0000 (16:44 +0000)
This is unlikely but possible if you have a manual subnet route
via another interface you normally receive a DHCP address inside
this subnet.

Saves spamming the log that we received for an inactive interface
as well.

src/dhcp.c

index 1ae1a5a26623e21478b8f4722cc482346d00d32a..d53bf7ba315cd0ffee363a084a6d3c6a9cb0b9c6 100644 (file)
@@ -2898,6 +2898,8 @@ dhcp_redirect_dhcp(struct interface *ifp, struct bootp *bootp, size_t bootp_len,
 
        xid = ntohl(bootp->xid);
        TAILQ_FOREACH(ifn, ifp->ctx->ifaces, next) {
+               if (ifn == ifp)
+                       continue;
                state = D_CSTATE(ifn);
                if (state == NULL || state->state == DHS_NONE)
                        continue;
@@ -3548,8 +3550,9 @@ dhcp_recvmsg(struct dhcpcd_ctx *ctx, struct msghdr *msg)
        }
        state = D_CSTATE(ifp);
        if (state == NULL) {
-               logdebugx("%s: received BOOTP for inactive interface",
-                   ifp->name);
+               /* Try re-directing it to another interface. */
+               dhcp_redirect_dhcp(ifp, (struct bootp *)iov->iov_base,
+                   iov->iov_len, &from->sin_addr);
                return;
        }