]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
If we're on a different subnet from the one we get DHCP for, don't use our current...
authorRoy Marples <roy@marples.name>
Thu, 11 Oct 2007 08:56:46 +0000 (08:56 +0000)
committerRoy Marples <roy@marples.name>
Thu, 11 Oct 2007 08:56:46 +0000 (08:56 +0000)
ChangeLog
dhcp.c

index 3c76ccc9c815d0b993a335b2735d09c9c4a27e35..2857757c7ca08a97d2e092c66be8b99319b79821 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,5 @@
+If we're on a different subnet from the one we get DHCP for, don't
+use our current address in messages. Thanks to Wilson Callan.
 Skip over bogus EINTR error on select when arp checking for a
 different address from what we already have. This should not
 happen, so a better fix is probably needed.
diff --git a/dhcp.c b/dhcp.c
index c180ed6b988f2de65c6617cadcefa0d3ce427753..2328c8365364f1532e6c487df85952ad8e9d7bb5 100644 (file)
--- a/dhcp.c
+++ b/dhcp.c
@@ -93,6 +93,11 @@ size_t send_message (const interface_t *iface, const dhcp_t *dhcp,
                /* Just incase we haven't actually configured the address yet */
                if (type == DHCP_INFORM && iface->previous_address.s_addr == 0)
                        message.ciaddr = dhcp->address.s_addr;
+
+               /* Zero the address if we're currently on a different subnet */
+               if (type == DHCP_REQUEST &&
+                       iface->previous_netmask.s_addr != dhcp->netmask.s_addr)
+                       message->ciaddr = from.s_addr = 0;
        }
 
        message.op = DHCP_BOOTREQUEST;