From 0d3220d3e1306141ab6404e8a88a30bb887eba83 Mon Sep 17 00:00:00 2001 From: Tom Marshall Date: Tue, 23 Jun 2015 10:05:54 -0700 Subject: [PATCH] dhcpcd: Send unique IAID 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 --- dhcpcd.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/dhcpcd.c b/dhcpcd.c index a98034a..7f45aac 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -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); @@ -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;