]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Stop sending FQDN by default.
authorRoy Marples <roy@marples.name>
Mon, 22 Jul 2013 19:05:54 +0000 (19:05 +0000)
committerRoy Marples <roy@marples.name>
Mon, 22 Jul 2013 19:05:54 +0000 (19:05 +0000)
Instead, if sending the hostname in DHCPv4, send a FQDN in DHCPv6.

This allows for a cleaner configuration file and fixes some DDNS problems
with upstream servers.

dhcp.c
dhcp6.c
dhcpcd.conf

diff --git a/dhcp.c b/dhcp.c
index 669624d176dbb823a86f49b2a65c2a7cab9ede5c..06ed6111d66435054b5949615e6bb1410aa79b2a 100644 (file)
--- a/dhcp.c
+++ b/dhcp.c
@@ -986,25 +986,10 @@ make_message(struct dhcp_message **message,
                        }
                }
 
-               /* Regardless of RFC2132, we should always send a hostname
-                * upto the first dot (the short hostname) as otherwise
-                * confuses some DHCP servers when updating DNS.
-                * The FQDN option should be used if a FQDN is required. */
                if (ifo->hostname[0] == '\0')
                        hostname = get_hostname();
                else
                        hostname = ifo->hostname;
-               if (ifo->options & DHCPCD_HOSTNAME && hostname) {
-                       *p++ = DHO_HOSTNAME;
-                       hp = strchr(hostname, '.');
-                       if (hp)
-                               len = hp - hostname;
-                       else
-                               len = strlen(hostname);
-                       *p++ = len;
-                       memcpy(p, hostname, len);
-                       p += len;
-               }
                if (ifo->fqdn != FQDN_DISABLE) {
                        /* IETF DHC-FQDN option (81), RFC4702 */
                        *p++ = DHO_FQDN;
@@ -1031,6 +1016,22 @@ make_message(struct dhcp_message **message,
                                *lp += ul;
                                p += ul;
                        }
+               } else if (ifo->options & DHCPCD_HOSTNAME && hostname) {
+                       *p++ = DHO_HOSTNAME;
+                       /*
+                        * Regardless of RFC2132, we should always send a
+                        * hostname upto the first dot (the short hostname) as
+                        * a FQDN confuses some DHCP servers when updating DNS.
+                        * The FQDN option should be used if a FQDN is wanted.
+                        */
+                       hp = strchr(hostname, '.');
+                       if (hp)
+                               len = hp - hostname;
+                       else
+                               len = strlen(hostname);
+                       *p++ = len;
+                       memcpy(p, hostname, len);
+                       p += len;
                }
 
                /* vendor is already encoded correctly, so just add it */
diff --git a/dhcp6.c b/dhcp6.c
index 8ae5466f32b71deb2061feea54b42847ea734a78..9e95b2793e9447f04fff39b066137db7f218a597 100644 (file)
--- a/dhcp6.c
+++ b/dhcp6.c
@@ -380,6 +380,7 @@ dhcp6_makemessage(struct interface *ifp)
        uint32_t u32;
        const struct ipv6_addr *ap;
        const char *hostname = NULL; /* assignment just to appease GCC*/
+       int fqdn;
 
        state = D6_STATE(ifp);
        if (state->send) {
@@ -387,8 +388,22 @@ dhcp6_makemessage(struct interface *ifp)
                state->send = NULL;
        }
 
-       /* Work out option size first */
        ifo = ifp->options;
+       fqdn = ifo->fqdn;
+
+       if (fqdn == FQDN_DISABLE || ifo->options & DHCPCD_HOSTNAME) {
+               /* We're sending the DHCPv4 hostname option, so send FQDN as
+                * DHCPv6 has no FQDN option and DHCPv4 must not send
+                * hostname and FQDN according to RFC4702 */
+               if (fqdn == FQDN_DISABLE)
+                       fqdn = FQDN_BOTH;
+               if (ifo->hostname[0] == '\0')
+                       hostname = get_hostname();
+               else
+                       hostname = ifo->hostname;
+       }
+
+       /* Work out option size first */
        n_options = 0;
        len = 0;
        si = NULL;
@@ -405,13 +420,8 @@ dhcp6_makemessage(struct interface *ifp)
                if (len)
                        len += sizeof(*o);
 
-               if (ifo->fqdn != FQDN_DISABLE) {
-                       if (ifo->hostname[0] == '\0')
-                               hostname = get_hostname();
-                       else
-                               hostname = ifo->hostname;
+               if (fqdn != FQDN_DISABLE)
                        len += sizeof(*o) + 1 + encode_rfc1035(hostname, NULL);
-               }
        }
 
        len += sizeof(*state->send);
@@ -617,11 +627,11 @@ dhcp6_makemessage(struct interface *ifp)
        }
 
        if (state->send->type !=  DHCP6_RELEASE) {
-               if (ifo->fqdn != FQDN_DISABLE) {
+               if (fqdn != FQDN_DISABLE) {
                        o = D6_NEXT_OPTION(o);
                        o->code = htons(D6_OPTION_FQDN);
                        p = D6_OPTION_DATA(o);
-                       switch (ifo->fqdn) {
+                       switch (fqdn) {
                        case FQDN_BOTH:
                                *p = D6_FQDN_BOTH;
                                break;
@@ -2303,7 +2313,8 @@ dhcp6_start1(void *arg)
                                add_option_mask(ifo->requestmask6,
                                    dhc->dhcp6_opt);
                }
-               if (ifo->fqdn != FQDN_DISABLE)
+               if (ifo->fqdn != FQDN_DISABLE ||
+                   ifo->options & DHCPCD_HOSTNAME)
                        add_option_mask(ifo->requestmask6, D6_OPTION_FQDN);
        }
 
index a646e93cc88cc12e73998984e6a6faccddcb214a..349c6f22037cbdb02be4bd50330aca10d65585d3 100644 (file)
@@ -1,15 +1,9 @@
 # A sample configuration for dhcpcd.
 # See dhcpcd.conf(5) for details.
 
-# Inform the DHCPv4 server of our hostname for DDNS.
-# This has been superceded by the FQDN option below, but is included
-# by default for servers which do not understand it.
+# Inform the DHCP server of our hostname for DDNS.
 hostname
 
-# Inform the DHCP server of our hostname for DDNS
-# and/or query for what it should be.
-fqdn
-
 # Use the hardware address of the interface for the Client ID.
 #clientid
 # or
@@ -22,7 +16,7 @@ duid
 option rapid_commit
 
 # A list of options to request from the DHCP server.
-option domain_name_servers, domain_name, domain_search, host_name, fqdn
+option domain_name_servers, domain_name, domain_search, host_name
 option classless_static_routes
 # Most distributions have NTP support.
 option ntp_servers