dhcpv6: prevent network loop scenario
authorPaul Donald <[email protected]>
Mon, 17 Nov 2025 01:15:51 +0000 (02:15 +0100)
committerÁlvaro Fernández Rojas <[email protected]>
Tue, 18 Nov 2025 07:27:46 +0000 (08:27 +0100)
It's possible for odhcpd to talk with its (odhcp6c) self in a network loop
scenario with strange results. Prevent this by returning early.

Signed-off-by: Paul Donald <[email protected]>
Link: https://github.com/openwrt/odhcpd/pull/314
Signed-off-by: Álvaro Fernández Rojas <[email protected]>
src/dhcpv6.c

index a808400e7fae4538339649248e82b452b81297a6..9d812626617d96a8ed18bff6f9e69e7c6bfb4957 100644 (file)
@@ -708,6 +708,12 @@ static void handle_client_request(void *addr, void *data, size_t len,
                }
        }
 
+       if (dest.serverid_length == clientid.len && 
+           !memcmp(clientid.buf, dest.serverid_buf, dest.serverid_length)) {
+               /* Bail if we are in a network loop where we talk with ourself */
+               return;         
+       }
+
        if (!IN6_IS_ADDR_MULTICAST((struct in6_addr *)dest_addr) && iov[IOV_NESTED].iov_len == 0 &&
            (hdr->msg_type == DHCPV6_MSG_REQUEST || hdr->msg_type == DHCPV6_MSG_RENEW ||
             hdr->msg_type == DHCPV6_MSG_RELEASE || hdr->msg_type == DHCPV6_MSG_DECLINE)) {