Set broadcast when sending DHCPREQUEST and DHCPDISCOVER
authorMathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>
Thu, 19 Jul 2018 00:13:54 +0000 (01:13 +0100)
committerBen Hutchings <ben@decadent.org.uk>
Thu, 19 Jul 2018 00:13:54 +0000 (01:13 +0100)
We need to do this, since our devices are probably not configured yet and
there may be more than one device we're trying to do DHCP on on the same
network. Otherwise, things might be dropped.

Patch is originally from here:
https://bugs.launchpad.net/ubuntu/+source/klibc/+bug/1327412/comments/5
... but the reporter "patpat" has not provided contact information, and
this is independently verifiable by looking at RFC 2131, section 4.1,
page 24.

Gbp-Pq: Name broadcast_dhcp_send.patch

usr/kinit/ipconfig/dhcp_proto.c

index ebf79cc0b5f710bfb5272f8b449c4a4a050689c8..d5b759bbc16ba855c8291ae2051e7da2cb7a1854 100644 (file)
@@ -201,8 +201,14 @@ static int dhcp_send(struct netdev *dev, struct iovec *vec)
        bootp.hlen      = dev->hwlen;
        bootp.xid       = dev->bootp.xid;
        bootp.ciaddr    = INADDR_ANY;
-       bootp.yiaddr    = dev->ip_addr;
+       /* yiaddr should always be set to 0 for the messages we're likely
+        * to send as a DHCP client: DHCPDISCOVER, DHCPREQUEST, DHCPDECLINE,
+        * DHCPINFORM, DHCPRELEASE
+        * cf. RFC2131 section 4.1.1, table 5.
+        */
+       bootp.yiaddr    = INADDR_ANY;
        bootp.giaddr    = INADDR_ANY;
+       bootp.flags     = htons(0x8000);
        bootp.secs      = htons(time(NULL) - dev->open_time);
        memcpy(bootp.chaddr, dev->hwaddr, 16);