Print this page
        
@@ -19,11 +19,10 @@
  * CDDL HEADER END
  */
 
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011, Joyent Inc. All rights reserved.
  */
 
 /*
  * Main door handler functions used by dlmgmtd to process the different door
  * call requests. Door call requests can come from the user-land applications,
@@ -63,10 +62,11 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include "dlmgmt_impl.h"
 
+
 typedef void dlmgmt_door_handler_t(void *, void *, size_t *, zoneid_t,
     ucred_t *);
 
 typedef struct dlmgmt_door_info_s {
         uint_t                  di_cmd;
@@ -447,14 +447,10 @@
         dlmgmt_door_getlinkid_t *getlinkid = argp;
         dlmgmt_getlinkid_retval_t *retvalp = retp;
         dlmgmt_link_t           *linkp;
         int                     err = 0;
 
-        /* Enable the global zone to lookup links it has given away. */
-        if (zoneid == GLOBAL_ZONEID && getlinkid->ld_zoneid != -1)
-                zoneid = getlinkid->ld_zoneid;
-
         /*
          * Hold the reader lock to access the link
          */
         dlmgmt_table_lock(B_FALSE);
 
@@ -1273,23 +1269,11 @@
                         err = errno;
                         dlmgmt_log(LOG_WARNING, "unable to remove link %d from "
                             "zone %d: %s", linkid, oldzoneid, strerror(err));
                         goto done;
                 }
-
-                if (newzoneid == GLOBAL_ZONEID && linkp->ll_onloan) {
-                        /*
-                         * We can only reassign a loaned VNIC back to the
-                         * global zone when the zone is shutting down, since
-                         * otherwise the VNIC is in use by the zone and will be
-                         * busy.  Leave the VNIC assigned to the zone so we can
-                         * still see it and delete it when dlmgmt_zonehalt()
-                         * runs.
-                         */
-                        goto done;
-                }
-
+                avl_remove(&dlmgmt_loan_avl, linkp);
                 linkp->ll_onloan = B_FALSE;
         }
         if (newzoneid != GLOBAL_ZONEID) {
                 if (zone_add_datalink(newzoneid, linkid) != 0) {
                         err = errno;
@@ -1296,10 +1280,11 @@
                         dlmgmt_log(LOG_WARNING, "unable to add link %d to zone "
                             "%d: %s", linkid, newzoneid, strerror(err));
                         (void) zone_add_datalink(oldzoneid, linkid);
                         goto done;
                 }
+                avl_add(&dlmgmt_loan_avl, linkp);
                 linkp->ll_onloan = B_TRUE;
         }
 
         avl_remove(&dlmgmt_name_avl, linkp);
         linkp->ll_zoneid = newzoneid;