Print this page


Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/dlmgmtd/dlmgmt_door.c
          +++ new/usr/src/cmd/dlmgmtd/dlmgmt_door.c
↓ open down ↓ 13 lines elided ↑ open up ↑
  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  /*
  23   23   * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  24      - * Copyright (c) 2011, Joyent Inc. All rights reserved.
  25   24   */
  26   25  
  27   26  /*
  28   27   * Main door handler functions used by dlmgmtd to process the different door
  29   28   * call requests. Door call requests can come from the user-land applications,
  30   29   * or from the kernel.
  31   30   *
  32   31   * Note on zones handling:
  33   32   *
  34   33   * There are two zoneid's associated with a link.  One is the zoneid of the
↓ open down ↓ 23 lines elided ↑ open up ↑
  58   57  #include <zone.h>
  59   58  #include <libsysevent.h>
  60   59  #include <libdlmgmt.h>
  61   60  #include <librcm.h>
  62   61  #include <sys/types.h>
  63   62  #include <sys/stat.h>
  64   63  #include <fcntl.h>
  65   64  #include <unistd.h>
  66   65  #include "dlmgmt_impl.h"
  67   66  
       67 +
  68   68  typedef void dlmgmt_door_handler_t(void *, void *, size_t *, zoneid_t,
  69   69      ucred_t *);
  70   70  
  71   71  typedef struct dlmgmt_door_info_s {
  72   72          uint_t                  di_cmd;
  73   73          size_t                  di_reqsz;
  74   74          size_t                  di_acksz;
  75   75          dlmgmt_door_handler_t   *di_handler;
  76   76  } dlmgmt_door_info_t;
  77   77  
↓ open down ↓ 364 lines elided ↑ open up ↑
 442  442  /* ARGSUSED */
 443  443  static void
 444  444  dlmgmt_getlinkid(void *argp, void *retp, size_t *sz, zoneid_t zoneid,
 445  445      ucred_t *cred)
 446  446  {
 447  447          dlmgmt_door_getlinkid_t *getlinkid = argp;
 448  448          dlmgmt_getlinkid_retval_t *retvalp = retp;
 449  449          dlmgmt_link_t           *linkp;
 450  450          int                     err = 0;
 451  451  
 452      -        /* Enable the global zone to lookup links it has given away. */
 453      -        if (zoneid == GLOBAL_ZONEID && getlinkid->ld_zoneid != -1)
 454      -                zoneid = getlinkid->ld_zoneid;
 455      -
 456  452          /*
 457  453           * Hold the reader lock to access the link
 458  454           */
 459  455          dlmgmt_table_lock(B_FALSE);
 460  456  
 461  457          if ((linkp = link_by_name(getlinkid->ld_link, zoneid)) == NULL) {
 462  458                  /*
 463  459                   * The link does not exist in this zone.
 464  460                   */
 465  461                  err = ENOENT;
↓ open down ↓ 802 lines elided ↑ open up ↑
1268 1264                  goto done;
1269 1265          }
1270 1266  
1271 1267          if (oldzoneid != GLOBAL_ZONEID) {
1272 1268                  if (zone_remove_datalink(oldzoneid, linkid) != 0) {
1273 1269                          err = errno;
1274 1270                          dlmgmt_log(LOG_WARNING, "unable to remove link %d from "
1275 1271                              "zone %d: %s", linkid, oldzoneid, strerror(err));
1276 1272                          goto done;
1277 1273                  }
1278      -
1279      -                if (newzoneid == GLOBAL_ZONEID && linkp->ll_onloan) {
1280      -                        /*
1281      -                         * We can only reassign a loaned VNIC back to the
1282      -                         * global zone when the zone is shutting down, since
1283      -                         * otherwise the VNIC is in use by the zone and will be
1284      -                         * busy.  Leave the VNIC assigned to the zone so we can
1285      -                         * still see it and delete it when dlmgmt_zonehalt()
1286      -                         * runs.
1287      -                         */
1288      -                        goto done;
1289      -                }
1290      -
     1274 +                avl_remove(&dlmgmt_loan_avl, linkp);
1291 1275                  linkp->ll_onloan = B_FALSE;
1292 1276          }
1293 1277          if (newzoneid != GLOBAL_ZONEID) {
1294 1278                  if (zone_add_datalink(newzoneid, linkid) != 0) {
1295 1279                          err = errno;
1296 1280                          dlmgmt_log(LOG_WARNING, "unable to add link %d to zone "
1297 1281                              "%d: %s", linkid, newzoneid, strerror(err));
1298 1282                          (void) zone_add_datalink(oldzoneid, linkid);
1299 1283                          goto done;
1300 1284                  }
     1285 +                avl_add(&dlmgmt_loan_avl, linkp);
1301 1286                  linkp->ll_onloan = B_TRUE;
1302 1287          }
1303 1288  
1304 1289          avl_remove(&dlmgmt_name_avl, linkp);
1305 1290          linkp->ll_zoneid = newzoneid;
1306 1291          avl_add(&dlmgmt_name_avl, linkp);
1307 1292  
1308 1293  done:
1309 1294          dlmgmt_table_unlock();
1310 1295          retvalp->lr_err = err;
↓ open down ↓ 200 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX