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


   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.

  24  */
  25 
  26 #include <arpa/inet.h>
  27 #include <assert.h>
  28 #include <libdlaggr.h>
  29 #include <libdllink.h>
  30 #include <libdlstat.h>
  31 #include <libnwam.h>
  32 #include <libscf.h>
  33 #include <netinet/in.h>
  34 #include <stdlib.h>
  35 #include <strings.h>

  36 #include <sys/socket.h>
  37 #include <sys/time.h>
  38 #include <sys/types.h>
  39 #include <values.h>
  40 #include <zone.h>
  41 
  42 #include "conditions.h"
  43 #include "events.h"
  44 #include "objects.h"
  45 #include "ncp.h"
  46 #include "util.h"
  47 
  48 /*
  49  * ncu.c - handles various NCU tasks - intialization/refresh, state machine
  50  * for NCUs etc.
  51  */
  52 
  53 #define VBOX_IFACE_PREFIX       "vboxnet"
  54 
  55 static void populate_ip_ncu_properties(nwam_ncu_handle_t, nwamd_ncu_t *);


 111     uint_t *cnt, const char *prop)
 112 {
 113         nwam_error_t err;
 114 
 115         if ((err = nwam_ncu_get_prop_value(ncuh, prop, val)) != NWAM_SUCCESS)
 116                 return (err);
 117         return (nwam_value_get_string_array(*val, strval, cnt));
 118 }
 119 
 120 nwam_error_t
 121 nwamd_get_ncu_uint(nwam_ncu_handle_t ncuh, nwam_value_t *val,
 122     uint64_t **uintval, uint_t *cnt, const char *prop)
 123 {
 124         nwam_error_t err;
 125 
 126         if ((err = nwam_ncu_get_prop_value(ncuh, prop, val)) != NWAM_SUCCESS)
 127                 return (err);
 128         return (nwam_value_get_uint64_array(*val, uintval, cnt));
 129 }
 130 











 131 /*
 132  * Run link/interface state machine in response to a state change
 133  * or enable/disable action event.
 134  */
 135 static void
 136 nwamd_ncu_state_machine(const char *object_name)
 137 {
 138         nwamd_object_t object;
 139         nwamd_ncu_t *ncu;
 140         link_state_t link_state;
 141         nwamd_event_t event;
 142         nwam_wlan_t key_wlan, connected_wlan;
 143         nwamd_link_t *link;
 144         char linkname[NWAM_MAX_NAME_LEN];
 145         boolean_t up;
 146 
 147         if ((object = nwamd_object_find(NWAM_OBJECT_TYPE_NCU, object_name))
 148             == NULL) {
 149                 nlog(LOG_ERR, "nwamd_ncu_state_machine: "
 150                     "request for nonexistent NCU %s", object_name);


 716                 nwam_value_free(ncu_prop);
 717         }
 718 
 719         /* link-autopush */
 720         if ((err = nwamd_get_ncu_string(ncuh, &ncu_prop,
 721             &ncu_data->ncu_link.nwamd_link_autopush,
 722             &ncu_data->ncu_link.nwamd_link_num_autopush,
 723             NWAM_NCU_PROP_LINK_AUTOPUSH)) != NWAM_SUCCESS) {
 724                 nlog(LOG_DEBUG,
 725                     "populate_link_ncu_properties: could not get %s value: %s",
 726                     NWAM_NCU_PROP_LINK_AUTOPUSH, nwam_strerror(err));
 727                 ncu_data->ncu_link.nwamd_link_num_autopush = 0;
 728         }
 729 }
 730 
 731 static void
 732 populate_ip_ncu_properties(nwam_ncu_handle_t ncuh, nwamd_ncu_t *ncu_data)
 733 {
 734         nwamd_if_t *nif = &ncu_data->ncu_if;
 735         struct nwamd_if_address **nifa, *nifai, *nifait;
 736         boolean_t static_addr = B_FALSE;
 737         uint64_t *addrsrcvalue;
 738         nwam_value_t ncu_prop;
 739         nwam_error_t err;
 740         ipadm_addrobj_t ipaddr;
 741         ipadm_status_t ipstatus;
 742         char **addrvalue;
 743         uint_t numvalues;
 744         uint64_t *ipversion;
 745         int i;
 746 
 747         nif->nwamd_if_ipv4 = B_FALSE;
 748         nif->nwamd_if_ipv6 = B_FALSE;
 749         nif->nwamd_if_dhcp_requested = B_FALSE;
 750         nif->nwamd_if_stateful_requested = B_FALSE;
 751         nif->nwamd_if_stateless_requested = B_FALSE;
 752         nif->nwamd_if_ipv4_default_route_set = B_FALSE;
 753         nif->nwamd_if_ipv6_default_route_set = B_FALSE;
 754 
 755         /* ip-version */
 756         if ((err = nwamd_get_ncu_uint(ncuh, &ncu_prop, &ipversion, &numvalues,
 757             NWAM_NCU_PROP_IP_VERSION)) != NWAM_SUCCESS) {
 758                 nlog(LOG_ERR,
 759                     "populate_ip_ncu_properties: could not get %s value: %s",
 760                     NWAM_NCU_PROP_IP_VERSION, nwam_strerror(err));
 761         } else {
 762                 for (i = 0; i < numvalues; i++) {
 763                         switch (ipversion[i]) {
 764                         case IPV4_VERSION:
 765                                 nif->nwamd_if_ipv4 = B_TRUE;
 766                                 break;
 767                         case IPV6_VERSION:
 768                                 nif->nwamd_if_ipv6 = B_TRUE;
 769                                 break;
 770                         default:
 771                                 nlog(LOG_ERR, "bogus ip version %lld",
 772                                     ipversion[i]);
 773                                 break;
 774                         }
 775                 }
 776                 nwam_value_free(ncu_prop);
 777         }
 778 

































 779         /* Free the old list. */
 780         for (nifai = nif->nwamd_if_list; nifai != NULL; nifai = nifait) {
 781                 nifait = nifai->next;
 782                 nifai->next = NULL;
 783                 ipadm_destroy_addrobj(nifai->ipaddr);
 784                 free(nifai);
 785         }
 786         nif->nwamd_if_list = NULL;
 787         nifa = &(nif->nwamd_if_list);
 788 
 789         if (!nif->nwamd_if_ipv4)
 790                 goto skip_ipv4;
 791 
 792         /* ipv4-addrsrc */
 793         if ((err = nwamd_get_ncu_uint(ncuh, &ncu_prop, &addrsrcvalue,
 794             &numvalues, NWAM_NCU_PROP_IPV4_ADDRSRC)) != NWAM_SUCCESS) {
 795                 nlog(nif->nwamd_if_ipv4 ? LOG_ERR : LOG_DEBUG,
 796                     "populate_ip_ncu_properties: could not get %s value: %s",
 797                     NWAM_NCU_PROP_IPV4_ADDRSRC, nwam_strerror(err));
 798         } else {


 811                 nwam_value_free(ncu_prop);
 812         }
 813         if (nif->nwamd_if_dhcp_requested) {
 814                 ipstatus = ipadm_create_addrobj(IPADM_ADDR_DHCP,
 815                     ncu_data->ncu_name, &ipaddr);
 816                 if (ipstatus != IPADM_SUCCESS) {
 817                         nlog(LOG_ERR, "populate_ip_ncu_properties: "
 818                             "ipadm_create_addrobj failed for v4 dhcp: %s",
 819                             ipadm_status2str(ipstatus));
 820                         goto skip_ipv4_dhcp;
 821                 }
 822 
 823                 ipstatus = ipadm_set_wait_time(ipaddr, ncu_wait_time);
 824                 if (ipstatus != IPADM_SUCCESS) {
 825                         nlog(LOG_ERR, "populate_ip_ncu_properties: "
 826                             "ipadm_set_wait_time failed for v4 dhcp: %s",
 827                             ipadm_status2str(ipstatus));
 828                         ipadm_destroy_addrobj(ipaddr);
 829                         goto skip_ipv4_dhcp;
 830                 }
















 831                 if ((*nifa = calloc(sizeof (**nifa), 1)) != NULL) {
 832                         (*nifa)->family = AF_INET;
 833                         (*nifa)->ipaddr_atype = IPADM_ADDR_DHCP;
 834                         (*nifa)->ipaddr = ipaddr;
 835                         nifa = &((*nifa)->next);
 836                         *nifa = NULL;
 837                 } else {
 838                         nlog(LOG_ERR, "populate_ip_ncu_properties: "
 839                             "couldn't allocate nwamd address for v4 dhcp: %s",
 840                             strerror(errno));
 841                         ipadm_destroy_addrobj(ipaddr);
 842                 }
 843         }
 844 
 845 skip_ipv4_dhcp:
 846         /* ipv4-addr */
 847         if (static_addr) {
 848                 if ((err = nwamd_get_ncu_string(ncuh, &ncu_prop, &addrvalue,
 849                     &numvalues, NWAM_NCU_PROP_IPV4_ADDR)) != NWAM_SUCCESS) {
 850                         nlog(LOG_ERR, "populate_ip_ncu_properties: "
 851                             "could not get %s value; %s",
 852                             NWAM_NCU_PROP_IPV4_ADDR, nwam_strerror(err));
 853                 } else {
 854                         for (i = 0; i < numvalues; i++) {
 855                                 ipstatus = ipadm_create_addrobj(
 856                                     IPADM_ADDR_STATIC, ncu_data->ncu_name,
 857                                     &ipaddr);
 858                                 if (ipstatus != IPADM_SUCCESS) {
 859                                         nlog(LOG_ERR,
 860                                             "populate_ip_ncu_properties: "
 861                                             "ipadm_create_addrobj failed "
 862                                             "for %s: %s", addrvalue[i],
 863                                             ipadm_status2str(ipstatus));
 864                                         continue;
 865                                 }
 866                                 /* ipadm_set_addr takes <addr>[/<mask>] */
 867                                 ipstatus = ipadm_set_addr(ipaddr, addrvalue[i],
 868                                     AF_INET);
 869                                 if (ipstatus != IPADM_SUCCESS) {
 870                                         nlog(LOG_ERR,
 871                                             "populate_ip_ncu_properties: "


 978                 if ((*nifa = calloc(sizeof (**nifa), 1)) != NULL) {
 979                         (*nifa)->family = AF_INET6;
 980                         (*nifa)->ipaddr_atype = IPADM_ADDR_IPV6_ADDRCONF;
 981                         (*nifa)->ipaddr = ipaddr;
 982                         nifa = &((*nifa)->next);
 983                         *nifa = NULL;
 984                 } else {
 985                         nlog(LOG_ERR, "populate_ip_ncu_properties: "
 986                             "couldn't allocate nwamd address for "
 987                             "v6 stateless/stateful: %s", strerror(errno));
 988                         ipadm_destroy_addrobj(ipaddr);
 989                 }
 990         }
 991 
 992 skip_ipv6_addrconf:
 993         /* ipv6-addr */
 994         if (static_addr) {
 995                 if ((err = nwamd_get_ncu_string(ncuh, &ncu_prop, &addrvalue,
 996                     &numvalues, NWAM_NCU_PROP_IPV6_ADDR)) != NWAM_SUCCESS) {
 997                         nlog(LOG_ERR, "populate_ip_ncu_properties: "
 998                             "could not get %s value; %s",
 999                             NWAM_NCU_PROP_IPV6_ADDR, nwam_strerror(err));
1000                 } else {
1001                         for (i = 0; i < numvalues; i++) {
1002                                 ipstatus = ipadm_create_addrobj(
1003                                     IPADM_ADDR_STATIC, ncu_data->ncu_name,
1004                                     &ipaddr);
1005                                 if (ipstatus != IPADM_SUCCESS) {
1006                                         nlog(LOG_ERR,
1007                                             "populate_ip_ncu_properties: "
1008                                             "ipadm_create_addrobj failed "
1009                                             "for %s: %s", addrvalue[i],
1010                                             ipadm_status2str(ipstatus));
1011                                         continue;
1012                                 }
1013                                 /* ipadm_set_addr takes <addr>[/<mask>] */
1014                                 ipstatus = ipadm_set_addr(ipaddr, addrvalue[i],
1015                                     AF_INET6);
1016                                 if (ipstatus != IPADM_SUCCESS) {
1017                                         nlog(LOG_ERR,
1018                                             "populate_ip_ncu_properties: "




   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright (c) 2016, Chris Fraire <cfraire@me.com>.
  25  */
  26 
  27 #include <arpa/inet.h>
  28 #include <assert.h>
  29 #include <libdlaggr.h>
  30 #include <libdllink.h>
  31 #include <libdlstat.h>
  32 #include <libnwam.h>
  33 #include <libscf.h>
  34 #include <netinet/in.h>
  35 #include <stdlib.h>
  36 #include <strings.h>
  37 #include <sys/param.h>
  38 #include <sys/socket.h>
  39 #include <sys/time.h>
  40 #include <sys/types.h>
  41 #include <values.h>
  42 #include <zone.h>
  43 
  44 #include "conditions.h"
  45 #include "events.h"
  46 #include "objects.h"
  47 #include "ncp.h"
  48 #include "util.h"
  49 
  50 /*
  51  * ncu.c - handles various NCU tasks - intialization/refresh, state machine
  52  * for NCUs etc.
  53  */
  54 
  55 #define VBOX_IFACE_PREFIX       "vboxnet"
  56 
  57 static void populate_ip_ncu_properties(nwam_ncu_handle_t, nwamd_ncu_t *);


 113     uint_t *cnt, const char *prop)
 114 {
 115         nwam_error_t err;
 116 
 117         if ((err = nwam_ncu_get_prop_value(ncuh, prop, val)) != NWAM_SUCCESS)
 118                 return (err);
 119         return (nwam_value_get_string_array(*val, strval, cnt));
 120 }
 121 
 122 nwam_error_t
 123 nwamd_get_ncu_uint(nwam_ncu_handle_t ncuh, nwam_value_t *val,
 124     uint64_t **uintval, uint_t *cnt, const char *prop)
 125 {
 126         nwam_error_t err;
 127 
 128         if ((err = nwam_ncu_get_prop_value(ncuh, prop, val)) != NWAM_SUCCESS)
 129                 return (err);
 130         return (nwam_value_get_uint64_array(*val, uintval, cnt));
 131 }
 132 
 133 nwam_error_t
 134 nwamd_get_ncu_boolean(nwam_ncu_handle_t ncuh, nwam_value_t *val,
 135     boolean_t **boolval, uint_t *cnt, const char *prop)
 136 {
 137         nwam_error_t err;
 138 
 139         if ((err = nwam_ncu_get_prop_value(ncuh, prop, val)) != NWAM_SUCCESS)
 140                 return (err);
 141         return (nwam_value_get_boolean_array(*val, boolval, cnt));
 142 }
 143 
 144 /*
 145  * Run link/interface state machine in response to a state change
 146  * or enable/disable action event.
 147  */
 148 static void
 149 nwamd_ncu_state_machine(const char *object_name)
 150 {
 151         nwamd_object_t object;
 152         nwamd_ncu_t *ncu;
 153         link_state_t link_state;
 154         nwamd_event_t event;
 155         nwam_wlan_t key_wlan, connected_wlan;
 156         nwamd_link_t *link;
 157         char linkname[NWAM_MAX_NAME_LEN];
 158         boolean_t up;
 159 
 160         if ((object = nwamd_object_find(NWAM_OBJECT_TYPE_NCU, object_name))
 161             == NULL) {
 162                 nlog(LOG_ERR, "nwamd_ncu_state_machine: "
 163                     "request for nonexistent NCU %s", object_name);


 729                 nwam_value_free(ncu_prop);
 730         }
 731 
 732         /* link-autopush */
 733         if ((err = nwamd_get_ncu_string(ncuh, &ncu_prop,
 734             &ncu_data->ncu_link.nwamd_link_autopush,
 735             &ncu_data->ncu_link.nwamd_link_num_autopush,
 736             NWAM_NCU_PROP_LINK_AUTOPUSH)) != NWAM_SUCCESS) {
 737                 nlog(LOG_DEBUG,
 738                     "populate_link_ncu_properties: could not get %s value: %s",
 739                     NWAM_NCU_PROP_LINK_AUTOPUSH, nwam_strerror(err));
 740                 ncu_data->ncu_link.nwamd_link_num_autopush = 0;
 741         }
 742 }
 743 
 744 static void
 745 populate_ip_ncu_properties(nwam_ncu_handle_t ncuh, nwamd_ncu_t *ncu_data)
 746 {
 747         nwamd_if_t *nif = &ncu_data->ncu_if;
 748         struct nwamd_if_address **nifa, *nifai, *nifait;
 749         boolean_t static_addr = B_FALSE, *boolvalue, dhcp_primary = B_FALSE;
 750         uint64_t *addrsrcvalue;
 751         nwam_value_t ncu_prop;
 752         nwam_error_t err;
 753         ipadm_addrobj_t ipaddr;
 754         ipadm_status_t ipstatus;
 755         char **addrvalue, ipreqhost[MAXNAMELEN];
 756         uint_t numvalues;
 757         uint64_t *ipversion;
 758         int i;
 759 
 760         nif->nwamd_if_ipv4 = B_FALSE;
 761         nif->nwamd_if_ipv6 = B_FALSE;
 762         nif->nwamd_if_dhcp_requested = B_FALSE;
 763         nif->nwamd_if_stateful_requested = B_FALSE;
 764         nif->nwamd_if_stateless_requested = B_FALSE;
 765         nif->nwamd_if_ipv4_default_route_set = B_FALSE;
 766         nif->nwamd_if_ipv6_default_route_set = B_FALSE;
 767 
 768         /* ip-version */
 769         if ((err = nwamd_get_ncu_uint(ncuh, &ncu_prop, &ipversion, &numvalues,
 770             NWAM_NCU_PROP_IP_VERSION)) != NWAM_SUCCESS) {
 771                 nlog(LOG_ERR,
 772                     "populate_ip_ncu_properties: could not get %s value: %s",
 773                     NWAM_NCU_PROP_IP_VERSION, nwam_strerror(err));
 774         } else {
 775                 for (i = 0; i < numvalues; i++) {
 776                         switch (ipversion[i]) {
 777                         case IPV4_VERSION:
 778                                 nif->nwamd_if_ipv4 = B_TRUE;
 779                                 break;
 780                         case IPV6_VERSION:
 781                                 nif->nwamd_if_ipv6 = B_TRUE;
 782                                 break;
 783                         default:
 784                                 nlog(LOG_ERR, "bogus ip version %lld",
 785                                     ipversion[i]);
 786                                 break;
 787                         }
 788                 }
 789                 nwam_value_free(ncu_prop);
 790         }
 791 
 792         /* ip-primary */
 793         if ((err = nwamd_get_ncu_boolean(ncuh, &ncu_prop, &boolvalue,
 794             &numvalues, NWAM_NCU_PROP_IP_PRIMARY)) != NWAM_SUCCESS) {
 795                 /* ip-primary is optional, so do not LOG_ERR */
 796                 nlog(LOG_DEBUG, "populate_ip_ncu_properties: "
 797                     "could not get %s value: %s",
 798                     NWAM_NCU_PROP_IP_PRIMARY, nwam_strerror(err));
 799         } else {
 800                 if (numvalues > 0)
 801                         dhcp_primary = boolvalue[0];
 802                 nwam_value_free(ncu_prop);
 803         }
 804 
 805         /* ip-reqhost */
 806         *ipreqhost = '\0';
 807 
 808         if ((err = nwamd_get_ncu_string(ncuh, &ncu_prop, &addrvalue,
 809             &numvalues, NWAM_NCU_PROP_IP_REQHOST)) != NWAM_SUCCESS) {
 810                 /* ip-reqhost is optional, so do not LOG_ERR */
 811                 nlog(LOG_DEBUG, "populate_ip_ncu_properties: "
 812                     "could not get %s value: %s",
 813                     NWAM_NCU_PROP_IP_REQHOST, nwam_strerror(err));
 814         } else {
 815                 if (numvalues > 0 && strlcpy(ipreqhost, addrvalue[0],
 816                     sizeof (ipreqhost)) >= sizeof (ipreqhost)) {
 817                         nlog(LOG_WARNING, "populate_ip_ncu_properties: "
 818                             "too long %s value: %s",
 819                             NWAM_NCU_PROP_IP_REQHOST, addrvalue[0]);
 820                         *ipreqhost = '\0';
 821                 }
 822                 nwam_value_free(ncu_prop);
 823         }
 824 
 825         /* Free the old list. */
 826         for (nifai = nif->nwamd_if_list; nifai != NULL; nifai = nifait) {
 827                 nifait = nifai->next;
 828                 nifai->next = NULL;
 829                 ipadm_destroy_addrobj(nifai->ipaddr);
 830                 free(nifai);
 831         }
 832         nif->nwamd_if_list = NULL;
 833         nifa = &(nif->nwamd_if_list);
 834 
 835         if (!nif->nwamd_if_ipv4)
 836                 goto skip_ipv4;
 837 
 838         /* ipv4-addrsrc */
 839         if ((err = nwamd_get_ncu_uint(ncuh, &ncu_prop, &addrsrcvalue,
 840             &numvalues, NWAM_NCU_PROP_IPV4_ADDRSRC)) != NWAM_SUCCESS) {
 841                 nlog(nif->nwamd_if_ipv4 ? LOG_ERR : LOG_DEBUG,
 842                     "populate_ip_ncu_properties: could not get %s value: %s",
 843                     NWAM_NCU_PROP_IPV4_ADDRSRC, nwam_strerror(err));
 844         } else {


 857                 nwam_value_free(ncu_prop);
 858         }
 859         if (nif->nwamd_if_dhcp_requested) {
 860                 ipstatus = ipadm_create_addrobj(IPADM_ADDR_DHCP,
 861                     ncu_data->ncu_name, &ipaddr);
 862                 if (ipstatus != IPADM_SUCCESS) {
 863                         nlog(LOG_ERR, "populate_ip_ncu_properties: "
 864                             "ipadm_create_addrobj failed for v4 dhcp: %s",
 865                             ipadm_status2str(ipstatus));
 866                         goto skip_ipv4_dhcp;
 867                 }
 868 
 869                 ipstatus = ipadm_set_wait_time(ipaddr, ncu_wait_time);
 870                 if (ipstatus != IPADM_SUCCESS) {
 871                         nlog(LOG_ERR, "populate_ip_ncu_properties: "
 872                             "ipadm_set_wait_time failed for v4 dhcp: %s",
 873                             ipadm_status2str(ipstatus));
 874                         ipadm_destroy_addrobj(ipaddr);
 875                         goto skip_ipv4_dhcp;
 876                 }
 877                 ipstatus = ipadm_set_primary(ipaddr, dhcp_primary);
 878                 if (ipstatus != IPADM_SUCCESS) {
 879                         nlog(LOG_ERR, "populate_ip_ncu_properties: "
 880                             "ipadm_set_primary failed for v4 dhcp: %s",
 881                             ipadm_status2str(ipstatus));
 882                         ipadm_destroy_addrobj(ipaddr);
 883                         goto skip_ipv4_dhcp;
 884                 }
 885                 ipstatus = ipadm_set_reqhost(ipaddr, ipreqhost);
 886                 if (ipstatus != IPADM_SUCCESS) {
 887                         nlog(LOG_ERR, "populate_ip_ncu_properties: "
 888                             "ipadm_set_reqhost failed for v4 dhcp: %s",
 889                             ipadm_status2str(ipstatus));
 890                         ipadm_destroy_addrobj(ipaddr);
 891                         goto skip_ipv4_dhcp;
 892                 }
 893                 if ((*nifa = calloc(sizeof (**nifa), 1)) != NULL) {
 894                         (*nifa)->family = AF_INET;
 895                         (*nifa)->ipaddr_atype = IPADM_ADDR_DHCP;
 896                         (*nifa)->ipaddr = ipaddr;
 897                         nifa = &((*nifa)->next);
 898                         *nifa = NULL;
 899                 } else {
 900                         nlog(LOG_ERR, "populate_ip_ncu_properties: "
 901                             "couldn't allocate nwamd address for v4 dhcp: %s",
 902                             strerror(errno));
 903                         ipadm_destroy_addrobj(ipaddr);
 904                 }
 905         }
 906 
 907 skip_ipv4_dhcp:
 908         /* ipv4-addr */
 909         if (static_addr) {
 910                 if ((err = nwamd_get_ncu_string(ncuh, &ncu_prop, &addrvalue,
 911                     &numvalues, NWAM_NCU_PROP_IPV4_ADDR)) != NWAM_SUCCESS) {
 912                         nlog(LOG_ERR, "populate_ip_ncu_properties: "
 913                             "could not get %s value: %s",
 914                             NWAM_NCU_PROP_IPV4_ADDR, nwam_strerror(err));
 915                 } else {
 916                         for (i = 0; i < numvalues; i++) {
 917                                 ipstatus = ipadm_create_addrobj(
 918                                     IPADM_ADDR_STATIC, ncu_data->ncu_name,
 919                                     &ipaddr);
 920                                 if (ipstatus != IPADM_SUCCESS) {
 921                                         nlog(LOG_ERR,
 922                                             "populate_ip_ncu_properties: "
 923                                             "ipadm_create_addrobj failed "
 924                                             "for %s: %s", addrvalue[i],
 925                                             ipadm_status2str(ipstatus));
 926                                         continue;
 927                                 }
 928                                 /* ipadm_set_addr takes <addr>[/<mask>] */
 929                                 ipstatus = ipadm_set_addr(ipaddr, addrvalue[i],
 930                                     AF_INET);
 931                                 if (ipstatus != IPADM_SUCCESS) {
 932                                         nlog(LOG_ERR,
 933                                             "populate_ip_ncu_properties: "


1040                 if ((*nifa = calloc(sizeof (**nifa), 1)) != NULL) {
1041                         (*nifa)->family = AF_INET6;
1042                         (*nifa)->ipaddr_atype = IPADM_ADDR_IPV6_ADDRCONF;
1043                         (*nifa)->ipaddr = ipaddr;
1044                         nifa = &((*nifa)->next);
1045                         *nifa = NULL;
1046                 } else {
1047                         nlog(LOG_ERR, "populate_ip_ncu_properties: "
1048                             "couldn't allocate nwamd address for "
1049                             "v6 stateless/stateful: %s", strerror(errno));
1050                         ipadm_destroy_addrobj(ipaddr);
1051                 }
1052         }
1053 
1054 skip_ipv6_addrconf:
1055         /* ipv6-addr */
1056         if (static_addr) {
1057                 if ((err = nwamd_get_ncu_string(ncuh, &ncu_prop, &addrvalue,
1058                     &numvalues, NWAM_NCU_PROP_IPV6_ADDR)) != NWAM_SUCCESS) {
1059                         nlog(LOG_ERR, "populate_ip_ncu_properties: "
1060                             "could not get %s value: %s",
1061                             NWAM_NCU_PROP_IPV6_ADDR, nwam_strerror(err));
1062                 } else {
1063                         for (i = 0; i < numvalues; i++) {
1064                                 ipstatus = ipadm_create_addrobj(
1065                                     IPADM_ADDR_STATIC, ncu_data->ncu_name,
1066                                     &ipaddr);
1067                                 if (ipstatus != IPADM_SUCCESS) {
1068                                         nlog(LOG_ERR,
1069                                             "populate_ip_ncu_properties: "
1070                                             "ipadm_create_addrobj failed "
1071                                             "for %s: %s", addrvalue[i],
1072                                             ipadm_status2str(ipstatus));
1073                                         continue;
1074                                 }
1075                                 /* ipadm_set_addr takes <addr>[/<mask>] */
1076                                 ipstatus = ipadm_set_addr(ipaddr, addrvalue[i],
1077                                     AF_INET6);
1078                                 if (ipstatus != IPADM_SUCCESS) {
1079                                         nlog(LOG_ERR,
1080                                             "populate_ip_ncu_properties: "