Skip to content

Commit

Permalink
dhcpcd: Send unique IAID
Browse files Browse the repository at this point in the history
The current logic uses the kernel iface index when the name is longer
than 4 octets.  This is not stable -- the iface index changes under
various scenarios, such as toggling airplane mode.

Instead, use the lower 4 octets of the iface hwaddr.  This is the same
logic used in the current dhcpcd code and in the ISC DHCP client.

Note the upstream fix is here:

  http://roy.marples.name/projects/dhcpcd/ci/31ea92e995477728?sbs=1

This is several revisions beyond our current code and it is rumored
that the next major AOSP release will switch to a different DHCP
client, so we won't bother trying to sync up with upstream.

Change-Id: I0663b9bcf3803978adcef6d936ae49e128c7b1f2
  • Loading branch information
tdmcyngn committed Jun 23, 2015
1 parent b922468 commit 0d3220d
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions dhcpcd.c
Expand Up @@ -776,7 +776,7 @@ configure_interface1(struct interface *iface)
struct if_state *ifs = iface->state;
struct if_options *ifo = ifs->options;
uint8_t *duid;
size_t len = 0, ifl;
size_t len = 0;

/* Do any platform specific configuration */
if_conf(iface);
Expand Down Expand Up @@ -824,16 +824,8 @@ configure_interface1(struct interface *iface)
iface->clientid = xmalloc(len + 6);
iface->clientid[0] = len + 5;
iface->clientid[1] = 255; /* RFC 4361 */
ifl = strlen(iface->name);
if (ifl < 5) {
memcpy(iface->clientid + 2, iface->name, ifl);
if (ifl < 4)
memset(iface->clientid + 2 + ifl,
0, 4 - ifl);
} else {
ifl = htonl(if_nametoindex(iface->name));
memcpy(iface->clientid + 2, &ifl, 4);
}
memcpy(iface->clientid + 2,
iface->hwaddr + iface->hwlen - 4, 4);
memcpy(iface->clientid + 6, duid, len);
} else if (len == 0) {
len = iface->hwlen + 1;
Expand Down

0 comments on commit 0d3220d

Please sign in to comment.