On Tue, Nov 16, 2021 at 9:56 AM Joel Knight <knight.j...@gmail.com> wrote:
>
> Inspecting the REQUEST packets showed that dhclient was setting the
> ciaddr to the existing leased IP address while dhcpleased was not
> setting this field. RFC 2131 4.3.2 (with a nice summary at 4.3.6) is
> pretty strict about when ciaddr and the 'requested ip' option should
> be used. The diff below modifies dhcpleased to set ciaddr and
> 'requested ip' at the appropriate times.

Hey Florian,

I wasn't subscribed to tech@ at the time, so don't have your reply in
my inbox. Thanks for explaining the approach. Your patch works
(thankfully T1 is only 2 hours with my ISP :)).

One thing that got missed in the refactor was that the requested-ip
option should not be set in a RENEWING or BINDING state (or in other
words, when ciaddr is set). This chunk on top of your diff also works
as expected (successful unicast renewal at T1).



.joel

Index: frontend.c
===================================================================
RCS file: /data/cvs-mirror/OpenBSD/src/sbin/dhcpleased/frontend.c,v
retrieving revision 1.23
diff -p -u -r1.23 frontend.c
--- frontend.c  20 Oct 2021 07:04:49 -0000      1.23
+++ frontend.c  19 Nov 2021 16:25:18 -0000
@@ -963,11 +966,13 @@ build_packet(uint8_t message_type, char
        p += sizeof(dhcp_req_list);

        if (message_type == DHCPREQUEST) {
-               memcpy(dhcp_requested_address + 2, requested_ip,
-                   sizeof(*requested_ip));
-               memcpy(p, dhcp_requested_address,
-                   sizeof(dhcp_requested_address));
-               p += sizeof(dhcp_requested_address);
+               if (ciaddr->s_addr == 0) {
+                       memcpy(dhcp_requested_address + 2, requested_ip,
+                           sizeof(*requested_ip));
+                       memcpy(p, dhcp_requested_address,
+                           sizeof(dhcp_requested_address));
+                       p += sizeof(dhcp_requested_address);
+               }

                if (server_identifier->s_addr != INADDR_ANY) {
                        memcpy(dhcp_server_identifier + 2, server_identifier,

Reply via email to