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/lib/ipmgmtd/ipmgmt_persist.c
          +++ new/usr/src/cmd/cmd-inet/lib/ipmgmtd/ipmgmt_persist.c
↓ open down ↓ 14 lines elided ↑ open up ↑
  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  /*
  23   23   * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
  24   24   * Copyright 2016 Argo Technologie SA.
       25 + * Copyright (c) 2016, Chris Fraire <cfraire@me.com>.
  25   26   */
  26   27  
  27   28  /*
  28   29   * Contains DB walker functions, which are of type `db_wfunc_t';
  29   30   *
  30   31   * typedef boolean_t db_wfunc_t(void *cbarg, nvlist_t *db_nvl, char *buf,
  31   32   *                              size_t bufsize, int *errp);
  32   33   *
  33   34   * ipadm_rw_db() walks through the data store, one line at a time and calls
  34   35   * these call back functions with:
↓ open down ↓ 866 lines elided ↑ open up ↑
 901  902                   * update, else add the new node.
 902  903                   */
 903  904                  for (; head != NULL; head = head->am_next) {
 904  905                          /*
 905  906                           * For IPv6, we need to distinguish between the
 906  907                           * linklocal and non-linklocal nodes
 907  908                           */
 908  909                          if (strcmp(head->am_aobjname,
 909  910                              nodep->am_aobjname) == 0 &&
 910  911                              (head->am_atype != IPADM_ADDR_IPV6_ADDRCONF ||
 911      -                            head->am_linklocal == nodep->am_linklocal))
      912 +                            head->ipmgmt_am_linklocal ==
      913 +                            nodep->ipmgmt_am_linklocal))
 912  914                                  break;
 913  915                  }
 914  916  
 915  917                  if (head != NULL) {
 916  918                          /* update the node */
 917  919                          (void) strlcpy(head->am_ifname, nodep->am_ifname,
 918  920                              sizeof (head->am_ifname));
 919  921                          head->am_lnum = nodep->am_lnum;
 920  922                          head->am_family = nodep->am_family;
 921  923                          head->am_flags = nodep->am_flags;
 922  924                          head->am_atype = nodep->am_atype;
 923      -                        if (head->am_atype == IPADM_ADDR_IPV6_ADDRCONF) {
 924      -                                head->am_ifid = nodep->am_ifid;
 925      -                                head->am_linklocal = nodep->am_linklocal;
 926      -                        }
      925 +                        (void) memcpy(&head->am_atype_cache, &nodep->am_atype_cache,
      926 +                            sizeof (head->am_atype_cache));
 927  927                  } else {
 928  928                          for (head = aobjmap.aobjmap_head; head != NULL;
 929  929                              head = head->am_next) {
 930  930                                  if (strcmp(head->am_ifname,
 931  931                                      nodep->am_ifname) == 0)
 932  932                                          break;
 933  933                          }
 934  934                          nodep->am_nextnum = (head == NULL ? 0 :
 935  935                              head->am_nextnum);
 936  936                          err = i_ipmgmt_add_amnode(nodep);
↓ open down ↓ 124 lines elided ↑ open up ↑
1061 1061                  goto fail;
1062 1062  
1063 1063          (void) snprintf(strval, IPMGMT_STRSIZE, "%d", np->am_flags);
1064 1064          if ((err = nvlist_add_string(*nvl, FLAGS, strval)) != 0)
1065 1065                  goto fail;
1066 1066  
1067 1067          (void) snprintf(strval, IPMGMT_STRSIZE, "%d", np->am_atype);
1068 1068          if ((err = nvlist_add_string(*nvl, ATYPE, strval)) != 0)
1069 1069                  goto fail;
1070 1070  
1071      -        if (np->am_atype == IPADM_ADDR_IPV6_ADDRCONF) {
1072      -                struct sockaddr_in6     *in6;
     1071 +        switch (np->am_atype) {
     1072 +                case IPADM_ADDR_IPV6_ADDRCONF: {
     1073 +                        struct sockaddr_in6     *in6;
1073 1074  
1074      -                in6 = (struct sockaddr_in6 *)&np->am_ifid;
1075      -                if (np->am_linklocal &&
1076      -                    IN6_IS_ADDR_UNSPECIFIED(&in6->sin6_addr)) {
1077      -                        if ((err = nvlist_add_string(*nvl, IPADM_NVP_IPNUMADDR,
1078      -                            "default")) != 0)
1079      -                                goto fail;
1080      -                } else {
1081      -                        if (inet_ntop(AF_INET6, &in6->sin6_addr, strval,
1082      -                            IPMGMT_STRSIZE) == NULL) {
1083      -                                err = errno;
1084      -                                goto fail;
     1075 +                        in6 = &np->ipmgmt_am_ifid;
     1076 +                        if (np->ipmgmt_am_linklocal &&
     1077 +                                IN6_IS_ADDR_UNSPECIFIED(&in6->sin6_addr)) {
     1078 +                                if ((err = nvlist_add_string(*nvl, IPADM_NVP_IPNUMADDR,
     1079 +                                        "default")) != 0)
     1080 +                                        goto fail;
     1081 +                        } else {
     1082 +                                if (inet_ntop(AF_INET6, &in6->sin6_addr, strval,
     1083 +                                        IPMGMT_STRSIZE) == NULL) {
     1084 +                                        err = errno;
     1085 +                                        goto fail;
     1086 +                                }
     1087 +                                if ((err = nvlist_add_string(*nvl, IPADM_NVP_IPNUMADDR,
     1088 +                                        strval)) != 0)
     1089 +                                        goto fail;
1085 1090                          }
1086      -                        if ((err = nvlist_add_string(*nvl, IPADM_NVP_IPNUMADDR,
1087      -                            strval)) != 0)
     1091 +                }
     1092 +                        break;
     1093 +                case IPADM_ADDR_DHCP: {
     1094 +                        if (np->ipmgmt_am_reqhost &&
     1095 +                            *np->ipmgmt_am_reqhost != '\0' &&
     1096 +                            (err = nvlist_add_string(*nvl, IPADM_NVP_REQHOST,
     1097 +                            np->ipmgmt_am_reqhost)) != 0)
1088 1098                                  goto fail;
1089 1099                  }
1090      -        } else {
1091      -                if ((err = nvlist_add_string(*nvl, IPADM_NVP_IPNUMADDR,
1092      -                    "")) != 0)
1093      -                        goto fail;
     1100 +                        /* FALLTHRU */
     1101 +                default:
     1102 +                        if ((err = nvlist_add_string(*nvl, IPADM_NVP_IPNUMADDR,
     1103 +                            "")) != 0)
     1104 +                                goto fail;
     1105 +                        break;
1094 1106          }
1095 1107          return (err);
1096 1108  fail:
1097 1109          nvlist_free(*nvl);
1098 1110          return (err);
1099 1111  }
1100 1112  
1101 1113  /*
1102 1114   * Read the aobjmap data store and build the in-memory representation
1103 1115   * of the aobjmap. We don't need to hold any locks while building this as
↓ open down ↓ 27 lines elided ↑ open up ↑
1131 1143                  } else if (strcmp(IPADM_NVP_LIFNUM, name) == 0) {
1132 1144                          node.am_lnum = atoi(strval);
1133 1145                  } else if (strcmp(IPADM_NVP_FAMILY, name) == 0) {
1134 1146                          node.am_family = (sa_family_t)atoi(strval);
1135 1147                  } else if (strcmp(FLAGS, name) == 0) {
1136 1148                          node.am_flags = atoi(strval);
1137 1149                  } else if (strcmp(ATYPE, name) == 0) {
1138 1150                          node.am_atype = (ipadm_addr_type_t)atoi(strval);
1139 1151                  } else if (strcmp(IPADM_NVP_IPNUMADDR, name) == 0) {
1140 1152                          if (node.am_atype == IPADM_ADDR_IPV6_ADDRCONF) {
1141      -                                in6 = (struct sockaddr_in6 *)&node.am_ifid;
     1153 +                                in6 = &node.ipmgmt_am_ifid;
1142 1154                                  if (strcmp(strval, "default") == 0) {
1143      -                                        bzero(in6, sizeof (node.am_ifid));
1144      -                                        node.am_linklocal = B_TRUE;
     1155 +                                        bzero(in6, sizeof (node.ipmgmt_am_ifid));
     1156 +                                        node.ipmgmt_am_linklocal = B_TRUE;
1145 1157                                  } else {
1146 1158                                          (void) inet_pton(AF_INET6, strval,
1147 1159                                              &in6->sin6_addr);
1148 1160                                          if (IN6_IS_ADDR_UNSPECIFIED(
1149 1161                                              &in6->sin6_addr))
1150      -                                                node.am_linklocal = B_TRUE;
     1162 +                                                node.ipmgmt_am_linklocal = B_TRUE;
1151 1163                                  }
1152 1164                          }
1153 1165                  }
1154 1166          }
1155 1167  
1156 1168          /* we have all the information we need, add the node */
1157 1169          *errp = i_ipmgmt_add_amnode(&node);
1158 1170  
1159 1171          return (B_TRUE);
1160 1172  }
↓ open down ↓ 532 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX