Print this page
    
usr/src/cmd/dlmgmtd/dlmgmt_door.c
    
      
        | Split | 
	Close | 
      
      | Expand all | 
      | Collapse all | 
    
    
          --- old/usr/src/cmd/dlmgmtd/dlmgmt_impl.h
          +++ new/usr/src/cmd/dlmgmtd/dlmgmt_impl.h
   1    1  /*
   2    2   * CDDL HEADER START
   3    3   *
   4    4   * The contents of this file are subject to the terms of the
   5    5   * Common Development and Distribution License (the "License").
   6    6   * You may not use this file except in compliance with the License.
   7    7   *
   8    8   * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9    9   * or http://www.opensolaris.org/os/licensing.
  10   10   * See the License for the specific language governing permissions
  11   11   * and limitations under the License.
  12   12   *
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  
    | 
      ↓ 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) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  24   24   * Copyright 2017 Joyent, Inc.
       25 + * Copyright 2023 Oxide Computer Company
  25   26   */
  26   27  
  27   28  /*
  28   29   * Functions to maintain a table of datalink configuration information.
  29   30   */
  30   31  
  31   32  #ifndef _DLMGMT_IMPL_H
  32   33  #define _DLMGMT_IMPL_H
  33   34  
  34   35  #ifdef  __cplusplus
  35   36  extern "C" {
  36   37  #endif
  37   38  
  38   39  #include <door.h>
  39   40  #include <libdllink.h>
  40   41  #include <sys/avl.h>
  41   42  
  42   43  /*
  43   44   * datalink attribute structure
  44   45   */
  45   46  typedef struct dlmgmt_linkattr_s {
  46   47          struct dlmgmt_linkattr_s        *lp_next;
  47   48          struct dlmgmt_linkattr_s        *lp_prev;
  48   49          char                            lp_name[MAXLINKATTRLEN];
  49   50          void                            *lp_val;
  50   51          dladm_datatype_t                lp_type;
  51   52          uint_t                          lp_sz;
  52   53          boolean_t                       lp_linkprop;
  53   54  } dlmgmt_linkattr_t;
  54   55  
  55   56  /*
  56   57   * datalink structure
  57   58   */
  58   59  typedef struct dlmgmt_link_s {
  59   60          dlmgmt_linkattr_t       *ll_head;
  60   61          char                    ll_link[MAXLINKNAMELEN];
  61   62          datalink_class_t        ll_class;
  62   63          uint32_t                ll_media;
  
    | 
      ↓ open down ↓ | 
    28 lines elided | 
    
      ↑ open up ↑ | 
  
  63   64          datalink_id_t           ll_linkid;
  64   65  
  65   66          /*
  66   67           * The zone that owns the link. If this is set to the id of
  67   68           * an NGZ and ll_onloan is set then the link was created and
  68   69           * is owned by the GZ but is currently being loaned out to an
  69   70           * NGZ. E.g., when the GZ admin creates a VNIC for exclusive
  70   71           * use by an NGZ. If ll_onloan is set then ll_zoneid cannot be 0.
  71   72           *
  72   73           * If ll_zoneid is set to the id of an NGZ but ll_onloan is
  73      -         * not set then the link was created and is owned by the NGZ.
       74 +         * not set then the link was created by, and is owned by, the NGZ.
  74   75           */
  75   76          zoneid_t                ll_zoneid;
  76   77          boolean_t               ll_onloan;
  77   78          avl_node_t              ll_name_node;
  78   79          avl_node_t              ll_id_node;
  79   80          uint32_t                ll_flags;
  80   81          uint32_t                ll_gen;         /* generation number */
  81      -        boolean_t               ll_trans;       /* transient link */
       82 +        /*
       83 +         * A transient link is one that is created and destroyed along with the
       84 +         * lifetime of a zone. It is a non-persistent link that is owned by the
       85 +         * zone (ll_zoneid is set to the id of the NGZ). It is specifically not
       86 +         * on-loan from the GZ.
       87 +         */
       88 +        boolean_t               ll_transient;
  82   89  } dlmgmt_link_t;
  83   90  
  84   91  /*
  85   92   * datalink configuration request structure
  86   93   */
  87   94  typedef struct dlmgmt_dlconf_s {
  88   95          dlmgmt_linkattr_t       *ld_head;
  89   96          char                    ld_link[MAXLINKNAMELEN];
  90   97          datalink_id_t           ld_linkid;
  91   98          datalink_class_t        ld_class;
  92   99          uint32_t                ld_media;
  93  100          int                     ld_id;
  94  101          zoneid_t                ld_zoneid;
  95  102          uint32_t                ld_gen;
  96  103          avl_node_t              ld_node;
  97  104  } dlmgmt_dlconf_t;
  98  105  
  99  106  extern boolean_t        debug;
 100  107  extern const char       *progname;
 101  108  extern char             cachefile[];
 102  109  extern dladm_handle_t   dld_handle;
 103  110  extern datalink_id_t    dlmgmt_nextlinkid;
 104  111  extern avl_tree_t       dlmgmt_name_avl;
 105  112  extern avl_tree_t       dlmgmt_id_avl;
 106  113  extern avl_tree_t       dlmgmt_dlconf_avl;
 107  114  
 108  115  boolean_t       linkattr_equal(dlmgmt_linkattr_t **, const char *, void *,
 109  116                      size_t);
 110  117  dlmgmt_linkattr_t *linkattr_find(dlmgmt_linkattr_t *, const char *);
 111  118  void            linkattr_unset(dlmgmt_linkattr_t **, const char *);
 112  119  int             linkattr_set(dlmgmt_linkattr_t **, const char *, void *,
 113  120                      size_t, dladm_datatype_t);
 114  121  int             linkattr_get(dlmgmt_linkattr_t **, const char *, void **,
 115  122                      size_t *, dladm_datatype_t *);
 116  123  void            linkattr_destroy(dlmgmt_link_t *);
 117  124  
 118  125  void            link_destroy(dlmgmt_link_t *);
 119  126  int             link_activate(dlmgmt_link_t *);
 120  127  boolean_t       link_is_visible(dlmgmt_link_t *, zoneid_t);
 121  128  dlmgmt_link_t   *link_by_id(datalink_id_t, zoneid_t);
 122  129  dlmgmt_link_t   *link_by_name(const char *, zoneid_t);
 123  130  int             dlmgmt_create_common(const char *, datalink_class_t,
 124  131                      uint32_t, zoneid_t, uint32_t, dlmgmt_link_t **);
 125  132  int             dlmgmt_destroy_common(dlmgmt_link_t *, uint32_t);
 126  133  int             dlmgmt_getattr_common(dlmgmt_linkattr_t **, const char *,
 127  134                      dlmgmt_getattr_retval_t *);
 128  135  
 129  136  void            dlmgmt_advance(dlmgmt_link_t *);
 130  137  void            dlmgmt_table_lock(boolean_t);
 131  138  void            dlmgmt_table_unlock();
 132  139  
 133  140  int             dlconf_create(const char *, datalink_id_t, datalink_class_t,
 134  141                      uint32_t, zoneid_t, dlmgmt_dlconf_t **);
 135  142  void            dlconf_destroy(dlmgmt_dlconf_t *);
 136  143  void            dlmgmt_advance_dlconfid(dlmgmt_dlconf_t *);
 137  144  void            dlmgmt_dlconf_table_lock(boolean_t);
 138  145  void            dlmgmt_dlconf_table_unlock(void);
 139  146  
 140  147  int             dlmgmt_generate_name(const char *, char *, size_t, zoneid_t);
 141  148  
  
    | 
      ↓ open down ↓ | 
    50 lines elided | 
    
      ↑ open up ↑ | 
  
 142  149  void            dlmgmt_linktable_init(void);
 143  150  void            dlmgmt_linktable_fini(void);
 144  151  
 145  152  int             dlmgmt_zone_init(zoneid_t);
 146  153  int             dlmgmt_elevate_privileges(void);
 147  154  int             dlmgmt_drop_privileges();
 148  155  void            dlmgmt_handler(void *, char *, size_t, door_desc_t *, uint_t);
 149  156  void            dlmgmt_log(int, const char *, ...);
 150  157  int             dlmgmt_write_db_entry(const char *, dlmgmt_link_t *, uint32_t);
 151  158  int             dlmgmt_delete_db_entry(dlmgmt_link_t *, uint32_t);
 152      -int             dlmgmt_db_init(zoneid_t, char *);
      159 +int             dlmgmt_db_init(zoneid_t, char *);
 153  160  void            dlmgmt_db_fini(zoneid_t);
 154  161  
 155  162  #ifdef  __cplusplus
 156  163  }
 157  164  #endif
 158  165  
 159  166  #endif  /* _DLMGMT_IMPL_H */
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX