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

@@ -20,10 +20,11 @@
  */
 
 /*
  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2016 Argo Technologie SA.
+ * Copyright (c) 2016, Chris Fraire <cfraire@me.com>.
  */
 
 /*
  * Contains DB walker functions, which are of type `db_wfunc_t';
  *

@@ -906,11 +907,12 @@
                          * linklocal and non-linklocal nodes
                          */
                         if (strcmp(head->am_aobjname,
                             nodep->am_aobjname) == 0 &&
                             (head->am_atype != IPADM_ADDR_IPV6_ADDRCONF ||
-                            head->am_linklocal == nodep->am_linklocal))
+                            head->ipmgmt_am_linklocal ==
+                            nodep->ipmgmt_am_linklocal))
                                 break;
                 }
 
                 if (head != NULL) {
                         /* update the node */

@@ -918,14 +920,12 @@
                             sizeof (head->am_ifname));
                         head->am_lnum = nodep->am_lnum;
                         head->am_family = nodep->am_family;
                         head->am_flags = nodep->am_flags;
                         head->am_atype = nodep->am_atype;
-                        if (head->am_atype == IPADM_ADDR_IPV6_ADDRCONF) {
-                                head->am_ifid = nodep->am_ifid;
-                                head->am_linklocal = nodep->am_linklocal;
-                        }
+                        (void) memcpy(&head->am_atype_cache, &nodep->am_atype_cache,
+                            sizeof (head->am_atype_cache));
                 } else {
                         for (head = aobjmap.aobjmap_head; head != NULL;
                             head = head->am_next) {
                                 if (strcmp(head->am_ifname,
                                     nodep->am_ifname) == 0)

@@ -1066,15 +1066,16 @@
 
         (void) snprintf(strval, IPMGMT_STRSIZE, "%d", np->am_atype);
         if ((err = nvlist_add_string(*nvl, ATYPE, strval)) != 0)
                 goto fail;
 
-        if (np->am_atype == IPADM_ADDR_IPV6_ADDRCONF) {
+        switch (np->am_atype) {
+                case IPADM_ADDR_IPV6_ADDRCONF: {
                 struct sockaddr_in6     *in6;
 
-                in6 = (struct sockaddr_in6 *)&np->am_ifid;
-                if (np->am_linklocal &&
+                        in6 = &np->ipmgmt_am_ifid;
+                        if (np->ipmgmt_am_linklocal &&
                     IN6_IS_ADDR_UNSPECIFIED(&in6->sin6_addr)) {
                         if ((err = nvlist_add_string(*nvl, IPADM_NVP_IPNUMADDR,
                             "default")) != 0)
                                 goto fail;
                 } else {

@@ -1085,14 +1086,25 @@
                         }
                         if ((err = nvlist_add_string(*nvl, IPADM_NVP_IPNUMADDR,
                             strval)) != 0)
                                 goto fail;
                 }
-        } else {
+                }
+                        break;
+                case IPADM_ADDR_DHCP: {
+                        if (np->ipmgmt_am_reqhost &&
+                            *np->ipmgmt_am_reqhost != '\0' &&
+                            (err = nvlist_add_string(*nvl, IPADM_NVP_REQHOST,
+                            np->ipmgmt_am_reqhost)) != 0)
+                                goto fail;
+                }
+                        /* FALLTHRU */
+                default:
                 if ((err = nvlist_add_string(*nvl, IPADM_NVP_IPNUMADDR,
                     "")) != 0)
                         goto fail;
+                        break;
         }
         return (err);
 fail:
         nvlist_free(*nvl);
         return (err);

@@ -1136,20 +1148,20 @@
                         node.am_flags = atoi(strval);
                 } else if (strcmp(ATYPE, name) == 0) {
                         node.am_atype = (ipadm_addr_type_t)atoi(strval);
                 } else if (strcmp(IPADM_NVP_IPNUMADDR, name) == 0) {
                         if (node.am_atype == IPADM_ADDR_IPV6_ADDRCONF) {
-                                in6 = (struct sockaddr_in6 *)&node.am_ifid;
+                                in6 = &node.ipmgmt_am_ifid;
                                 if (strcmp(strval, "default") == 0) {
-                                        bzero(in6, sizeof (node.am_ifid));
-                                        node.am_linklocal = B_TRUE;
+                                        bzero(in6, sizeof (node.ipmgmt_am_ifid));
+                                        node.ipmgmt_am_linklocal = B_TRUE;
                                 } else {
                                         (void) inet_pton(AF_INET6, strval,
                                             &in6->sin6_addr);
                                         if (IN6_IS_ADDR_UNSPECIFIED(
                                             &in6->sin6_addr))
-                                                node.am_linklocal = B_TRUE;
+                                                node.ipmgmt_am_linklocal = B_TRUE;
                                 }
                         }
                 }
         }