Print this page
7388 Support DHCP Client FQDN. Allow IAID/DUID for all v4.

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/cmd-inet/sbin/dhcpagent/states.c
          +++ new/usr/src/cmd/cmd-inet/sbin/dhcpagent/states.c
↓ open down ↓ 12 lines elided ↑ open up ↑
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
       23 + * Copyright (c) 2016, Chris Fraire <cfraire@me.com>.
  23   24   *
  24   25   * This module contains core functions for managing DHCP state machine
  25   26   * instances.
  26   27   */
  27   28  
  28   29  #include <assert.h>
  29   30  #include <stdlib.h>
  30   31  #include <search.h>
  31   32  #include <string.h>
  32   33  #include <ctype.h>
↓ open down ↓ 292 lines elided ↑ open up ↑
 325  326          free_pkt_list(&dsmp->dsm_recv_pkt_list);
 326  327          if (dsmp->dsm_ack != dsmp->dsm_orig_ack)
 327  328                  free_pkt_entry(dsmp->dsm_orig_ack);
 328  329          free_pkt_entry(dsmp->dsm_ack);
 329  330          free(dsmp->dsm_send_pkt.pkt);
 330  331          free(dsmp->dsm_cid);
 331  332          free(dsmp->dsm_prl);
 332  333          free(dsmp->dsm_pil);
 333  334          free(dsmp->dsm_routers);
 334  335          free(dsmp->dsm_reqhost);
      336 +        free(dsmp->dsm_msg_reqhost);
      337 +        free(dsmp->dsm_reqfqdn);
 335  338          free(dsmp);
 336  339  
 337  340          /* no big deal if this fails */
 338  341          if (global_smach_count == 0 && inactivity_id == -1) {
 339  342                  inactivity_id = iu_schedule_timer(tq, DHCP_INACTIVITY_WAIT,
 340  343                      inactivity_shutdown, NULL);
 341  344          }
 342  345  }
 343  346  
 344  347  /*
↓ open down ↓ 697 lines elided ↑ open up ↑
1042 1045                          return (DHCP_IPC_SUCCESS);
1043 1046                  }
1044 1047          }
1045 1048  no_specified_id:
1046 1049  
1047 1050          /*
1048 1051           * There was either no user-specified Client ID value, or we were
1049 1052           * unable to parse it.  We need to determine if a Client ID is required
1050 1053           * and, if so, generate one.
1051 1054           *
1052      -         * If it's IPv4, not in an IPMP group, and not a logical interface,
     1055 +         * If it's IPv4, not in an IPMP group, not a logical interface,
     1056 +         * and a DHCP default for DF_V4_DEFAULT_IAID_DUID is not affirmative,
1053 1057           * then we need to preserve backward-compatibility by avoiding
1054 1058           * new-fangled DUID/IAID construction.  (Note: even for IPMP test
1055 1059           * addresses, we construct a DUID/IAID since we may renew a lease for
1056 1060           * an IPMP test address on any functioning IP interface in the group.)
1057 1061           */
1058 1062          if (!pif->pif_isv6 && pif->pif_grifname[0] == '\0' &&
1059      -            strchr(dsmp->dsm_name, ':') == NULL) {
     1063 +            strchr(dsmp->dsm_name, ':') == NULL &&
     1064 +            !df_get_bool(dsmp->dsm_name, pif->pif_isv6,
     1065 +            DF_V4_DEFAULT_IAID_DUID)) {
1060 1066                  if (pif->pif_hwtype == ARPHRD_IB) {
1061 1067                          /*
1062 1068                           * This comes from the DHCP over IPoIB specification.
1063 1069                           * In the absence of an user specified client id, IPoIB
1064 1070                           * automatically uses the required format, with the
1065 1071                           * unique 4 octet value set to 0 (since IPoIB driver
1066 1072                           * allows only a single interface on a port with a
1067 1073                           * specific GID to belong to an IP subnet (PSARC
1068 1074                           * 2001/289, FWARC 2002/702).
1069 1075                           *
↓ open down ↓ 141 lines elided ↑ open up ↑
1211 1217  
1212 1218          free_pkt_list(&dsmp->dsm_recv_pkt_list);
1213 1219          free_pkt_entry(dsmp->dsm_ack);
1214 1220          if (dsmp->dsm_orig_ack != dsmp->dsm_ack)
1215 1221                  free_pkt_entry(dsmp->dsm_orig_ack);
1216 1222          dsmp->dsm_ack = dsmp->dsm_orig_ack = NULL;
1217 1223  
1218 1224          free(dsmp->dsm_reqhost);
1219 1225          dsmp->dsm_reqhost = NULL;
1220 1226  
     1227 +        /*
     1228 +         * Do not reset dsm_msg_reqhost here. Unlike dsm_reqhost coming from
     1229 +         * /etc/host.*, dsm_msg_reqhost comes externally, and it survives until
     1230 +         * it is reset from another external message.
     1231 +         */
     1232 +
     1233 +        free(dsmp->dsm_reqfqdn);
     1234 +        dsmp->dsm_reqfqdn = NULL;
     1235 +
1221 1236          cancel_smach_timers(dsmp);
1222 1237  
1223 1238          (void) set_smach_state(dsmp, INIT);
1224 1239          if (dsmp->dsm_isv6) {
1225 1240                  dsmp->dsm_server = ipv6_all_dhcp_relay_and_servers;
1226 1241          } else {
1227 1242                  IN6_IPADDR_TO_V4MAPPED(htonl(INADDR_BROADCAST),
1228 1243                      &dsmp->dsm_server);
1229 1244          }
1230 1245          dsmp->dsm_neg_hrtime = gethrtime();
↓ open down ↓ 388 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX