From 7904b4736b0529dcd05ff79fd5cc0fc52b0b580a Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Fri, 21 Nov 2008 08:05:55 +0000 Subject: [PATCH] Backport r1074 to dhcpcd-4.0 which stops sending a ClientID by default. If CMDLINE_COMPAT is enabled then we keep the prior behaviour. --- README | 7 +++++++ client.c | 10 ++++++++-- dhcpcd.8.in | 13 ++++++++++--- dhcpcd.c | 7 ++++++- dhcpcd.conf.5.in | 13 ++++++++++--- 5 files changed, 41 insertions(+), 9 deletions(-) diff --git a/README b/README index d25847a9..1dff417d 100644 --- a/README +++ b/README @@ -56,6 +56,13 @@ If CMDLINE_COMPAT is defined the we renable DUID support by default IF the dhcpcd.duid file exits. This keeps the clients working as they were, which is good. +dhcpcd no longer sends a default ClientID for ethernet interfaces. +This is so we can re-use the address the kernel DHCP client found. +To retain the old behaviour of sending a default ClientID based on the +hardware address for interface, simply add the keyword clientid to dhcpcd.conf. +If CMDLINE_COMPAT is defined, we renable the sending of ClientID by default +AND adding clientid to dhcpcd.conf causes it NOT to be sent. + dhcpcd-4 is NOT fully commandline compatible with dhcpcd-2 and older and changes the meaning of some options. diff --git a/client.c b/client.c index 03a4ef76..94567500 100644 --- a/client.c +++ b/client.c @@ -520,12 +520,18 @@ client_setup(struct if_state *state, const struct options *options) iface->net.s_addr = lease->net.s_addr; } + /* If we haven't specified a ClientID and our hardware address + * length is greater than DHCP_CHADDR_LEN then we enforce a ClientID + * of the hardware address family and the hardware address. */ + if (!(state->options & DHCPCD_CLIENTID) && iface->hwlen > DHCP_CHADDR_LEN) + state->options |= DHCPCD_CLIENTID; + if (*options->clientid) { iface->clientid = xmalloc(options->clientid[0] + 1); memcpy(iface->clientid, options->clientid, options->clientid[0] + 1); - } else if (options->options & DHCPCD_CLIENTID) { - if (options->options & DHCPCD_DUID) { + } else if (state->options & DHCPCD_CLIENTID) { + if (state->options & DHCPCD_DUID) { duid = xmalloc(DUID_LEN); if ((len = get_duid(duid, iface)) == 0) logger(LOG_ERR, "get_duid: %s", diff --git a/dhcpcd.8.in b/dhcpcd.8.in index 0a9e51e4..66341d49 100644 --- a/dhcpcd.8.in +++ b/dhcpcd.8.in @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd August 20, 2008 +.Dd November 18, 2008 .Dt DHCPCD 8 SMM .Sh NAME .Nm dhcpcd @@ -324,9 +324,16 @@ itself never does any DNS updates. encodes the FQDN hostname as specified in .Li RFC1035 . .It Fl I , -clientid Ar clientid -Change the default clientid sent from the interface hardware address. +Send the +.Ar clientid . If the string is of the format 01:02:03 then it is encoded as hex. -If not set then none is sent. +For interfaces whose hardware address is longer than 8 bytes, or if the +.Ar clientid +is an empty string then +.Nm +sends a default +.Ar clientid +of the hardware family and the hardware address. .El .Ss Restriciting behaviour .Nm diff --git a/dhcpcd.c b/dhcpcd.c index b8ec1847..93d8b8d6 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -521,10 +521,14 @@ parse_option(int opt, char *oarg, struct options *options) return -1; } options->clientid[0] = (uint8_t)s; +#ifdef CMDLINE_COMPAT if (s == 0) { options->options &= ~DHCPCD_DUID; options->options &= ~DHCPCD_CLIENTID; } +#else + options->options |= DHCPCD_CLIENTID; +#endif break; case 'K': options->options &= ~DHCPCD_LINK; @@ -618,7 +622,7 @@ main(int argc, char **argv) setlogprefix(PACKAGE ": "); options = xzalloc(sizeof(*options)); - options->options |= DHCPCD_CLIENTID | DHCPCD_GATEWAY | DHCPCD_DAEMONISE; + options->options |= DHCPCD_GATEWAY | DHCPCD_DAEMONISE; options->options |= DHCPCD_ARP | DHCPCD_IPV4LL | DHCPCD_LINK; options->timeout = DEFAULT_TIMEOUT; strlcpy(options->script, SCRIPT, sizeof(options->script)); @@ -628,6 +632,7 @@ main(int argc, char **argv) "%s %s", PACKAGE, VERSION); #ifdef CMDLINE_COMPAT + options->options |= DHCPCD_CLIENTID; add_option_mask(options->requestmask, DHO_DNSSERVER); add_option_mask(options->requestmask, DHO_DNSDOMAIN); add_option_mask(options->requestmask, DHO_DNSSEARCH); diff --git a/dhcpcd.conf.5.in b/dhcpcd.conf.5.in index 05ba6463..6f0d3189 100644 --- a/dhcpcd.conf.5.in +++ b/dhcpcd.conf.5.in @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd August 18, 2008 +.Dd November 18, 2008 .Dt DHCPCD.CONF 5 SMM .Sh NAME .Nm dhcpcd.conf @@ -48,9 +48,16 @@ Background immediately. This is useful for startup scripts which don't disable link messages for carrier status. .It Ic clientid Ar string -Change the default clientid sent from the interface hardware address. +Send the +.Ar clientid . If the string is of the format 01:02:03 then it is encoded as hex. -If not set then none is sent. +For interfaces whose hardware address is longer than 8 bytes, or if the +.Ar clientid +is an empty string then +.Nm dhcpcd +sends a default +.Ar clientid +of the hardware family and the hardware address. .It Ic duid Generate an .Rs -- 2.47.2