Print this page
usr/src/cmd/dlmgmtd/dlmgmt_door.c

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libdladm/common/libdlmgmt.c
          +++ new/usr/src/lib/libdladm/common/libdlmgmt.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   * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  23   23   * Copyright 2016 Joyent, Inc.
       24 + * Copyright 2023 Oxide Computer Company
  24   25   */
  25   26  
  26   27  #include <door.h>
  27   28  #include <errno.h>
  28   29  #include <assert.h>
  29   30  #include <stdio.h>
  30   31  #include <stdlib.h>
  31   32  #include <unistd.h>
  32   33  #include <string.h>
  33   34  #include <strings.h>
↓ open down ↓ 82 lines elided ↑ open up ↑
 116  117          uint32_t                dlmgmt_flags;
 117  118          dladm_status_t          status;
 118  119          size_t                  sz = sizeof (retval);
 119  120  
 120  121          if (link == NULL || class == DATALINK_CLASS_ALL ||
 121  122              !(flags & (DLADM_OPT_ACTIVE | DLADM_OPT_PERSIST)) ||
 122  123              linkidp == NULL) {
 123  124                  return (DLADM_STATUS_BADARG);
 124  125          }
 125  126  
      127 +        if (getzoneid() != GLOBAL_ZONEID) {
      128 +                /*
      129 +                 * If we're creating this link in a non-global zone, then do
      130 +                 * not allow it to be persistent, and flag it as transient so
      131 +                 * that it will be automatically cleaned up on zone shutdown,
      132 +                 * rather than being moved to the GZ.
      133 +                 */
      134 +                if (flags & DLADM_OPT_PERSIST)
      135 +                        return (DLADM_STATUS_TEMPONLY);
      136 +                flags |= DLADM_OPT_TRANSIENT;
      137 +        }
      138 +
 126  139          dlmgmt_flags = (flags & DLADM_OPT_ACTIVE) ? DLMGMT_ACTIVE : 0;
 127  140          dlmgmt_flags |= (flags & DLADM_OPT_PERSIST) ? DLMGMT_PERSIST : 0;
 128  141          dlmgmt_flags |= (flags & DLADM_OPT_TRANSIENT) ? DLMGMT_TRANSIENT : 0;
 129  142  
 130  143          (void) strlcpy(createid.ld_link, link, MAXLINKNAMELEN);
 131  144          createid.ld_class = class;
 132  145          createid.ld_media = media;
 133  146          createid.ld_flags = dlmgmt_flags;
 134  147          createid.ld_cmd = DLMGMT_CMD_CREATE_LINKID;
 135  148          createid.ld_prefix = (flags & DLADM_OPT_PREFIX);
↓ open down ↓ 438 lines elided ↑ open up ↑
 574  587                   * might not be active anymore. Check and set its real status.
 575  588                   */
 576  589                  status = i_dladm_phys_status(handle, linkid, &retval.lr_flags);
 577  590                  if (status != DLADM_STATUS_OK)
 578  591                          return (status);
 579  592          }
 580  593  
 581  594          if (linkidp != NULL)
 582  595                  *linkidp = linkid;
 583  596          if (flagp != NULL) {
 584      -                *flagp = retval.lr_flags & DLMGMT_ACTIVE ? DLADM_OPT_ACTIVE : 0;
      597 +                *flagp = (retval.lr_flags & DLMGMT_ACTIVE) ?
      598 +                    DLADM_OPT_ACTIVE : 0;
 585  599                  *flagp |= (retval.lr_flags & DLMGMT_PERSIST) ?
 586  600                      DLADM_OPT_PERSIST : 0;
      601 +                *flagp |= (retval.lr_flags & DLMGMT_TRANSIENT) ?
      602 +                    DLADM_OPT_TRANSIENT : 0;
 587  603          }
 588  604          if (classp != NULL)
 589  605                  *classp = retval.lr_class;
 590  606          if (mediap != NULL)
 591  607                  *mediap = retval.lr_media;
 592  608  
 593  609          return (DLADM_STATUS_OK);
 594  610  }
 595  611  
 596  612  /*
↓ open down ↓ 184 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX