8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 /*
  28  * Copyright (c) 2016, Joyent, Inc. All rights reserved.
  29  */
  30 
  31 #ifndef _SYS_NETSTACK_H
  32 #define _SYS_NETSTACK_H
  33 
  34 #include <sys/kstat.h>
  35 #include <sys/cred.h>
  36 #include <sys/mutex.h>
  37 
  38 #ifdef  __cplusplus
  39 extern "C" {
  40 #endif
  41 
  42 /*
  43  * This allows various pieces in and around IP to have a separate instance
  44  * for each instance of IP. This is used to support zones that have an
  45  * exclusive stack.
  46  * Pieces of software far removed from IP (e.g., kernel software
  47  * sitting on top of TCP or UDP) probably should not use the netstack
  48  * support; if such software wants to support separate zones it
 
 219 struct netstack_registry {
 220         int             nr_flags;       /* 0 if nothing registered */
 221         void            *(*nr_create)(netstackid_t, netstack_t *);
 222         void            (*nr_shutdown)(netstackid_t, void *);
 223         void            (*nr_destroy)(netstackid_t, void *);
 224 };
 225 
 226 /* nr_flags values */
 227 #define NRF_REGISTERED  0x01
 228 #define NRF_DYING       0x02    /* No new creates */
 229 
 230 /*
 231  * To support kstat_create_netstack() using kstat_add_zone we need
 232  * to track both
 233  *  - all zoneids that use the global/shared stack
 234  *  - all kstats that have been added for the shared stack
 235  */
 236 
 237 extern void netstack_init(void);
 238 extern void netstack_hold(netstack_t *);
 239 extern void netstack_rele(netstack_t *);
 240 extern netstack_t *netstack_find_by_cred(const cred_t *);
 241 extern netstack_t *netstack_find_by_stackid(netstackid_t);
 242 extern netstack_t *netstack_find_by_zoneid(zoneid_t);
 243 extern boolean_t netstack_inuse_by_stackid(netstackid_t stackid);
 244 
 245 extern zoneid_t netstackid_to_zoneid(netstackid_t);
 246 extern zoneid_t netstack_get_zoneid(netstack_t *);
 247 extern netstackid_t zoneid_to_netstackid(zoneid_t);
 248 
 249 extern netstack_t *netstack_get_current(void);
 250 
 251 /*
 252  * Register interest in changes to the set of netstacks.
 253  * The createfn and destroyfn are required, but the shutdownfn can be
 254  * NULL.
 255  * Note that due to the current zsd implementation, when the create
 256  * function is called the zone isn't fully present, thus functions
 257  * like zone_find_by_* will fail, hence the create function can not
 258  * use many zones kernel functions including zcmn_err().
 
 | 
 
 
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 /*
  28  * Copyright (c) 2017, Joyent, Inc. All rights reserved.
  29  */
  30 
  31 #ifndef _SYS_NETSTACK_H
  32 #define _SYS_NETSTACK_H
  33 
  34 #include <sys/kstat.h>
  35 #include <sys/cred.h>
  36 #include <sys/mutex.h>
  37 
  38 #ifdef  __cplusplus
  39 extern "C" {
  40 #endif
  41 
  42 /*
  43  * This allows various pieces in and around IP to have a separate instance
  44  * for each instance of IP. This is used to support zones that have an
  45  * exclusive stack.
  46  * Pieces of software far removed from IP (e.g., kernel software
  47  * sitting on top of TCP or UDP) probably should not use the netstack
  48  * support; if such software wants to support separate zones it
 
 219 struct netstack_registry {
 220         int             nr_flags;       /* 0 if nothing registered */
 221         void            *(*nr_create)(netstackid_t, netstack_t *);
 222         void            (*nr_shutdown)(netstackid_t, void *);
 223         void            (*nr_destroy)(netstackid_t, void *);
 224 };
 225 
 226 /* nr_flags values */
 227 #define NRF_REGISTERED  0x01
 228 #define NRF_DYING       0x02    /* No new creates */
 229 
 230 /*
 231  * To support kstat_create_netstack() using kstat_add_zone we need
 232  * to track both
 233  *  - all zoneids that use the global/shared stack
 234  *  - all kstats that have been added for the shared stack
 235  */
 236 
 237 extern void netstack_init(void);
 238 extern void netstack_hold(netstack_t *);
 239 extern netstack_t *netstack_hold_if_active(netstack_t *);
 240 extern void netstack_rele(netstack_t *);
 241 extern netstack_t *netstack_find_by_cred(const cred_t *);
 242 extern netstack_t *netstack_find_by_stackid(netstackid_t);
 243 extern netstack_t *netstack_find_by_zoneid(zoneid_t);
 244 extern boolean_t netstack_inuse_by_stackid(netstackid_t stackid);
 245 
 246 extern zoneid_t netstackid_to_zoneid(netstackid_t);
 247 extern zoneid_t netstack_get_zoneid(netstack_t *);
 248 extern netstackid_t zoneid_to_netstackid(zoneid_t);
 249 
 250 extern netstack_t *netstack_get_current(void);
 251 
 252 /*
 253  * Register interest in changes to the set of netstacks.
 254  * The createfn and destroyfn are required, but the shutdownfn can be
 255  * NULL.
 256  * Note that due to the current zsd implementation, when the create
 257  * function is called the zone isn't fully present, thus functions
 258  * like zone_find_by_* will fail, hence the create function can not
 259  * use many zones kernel functions including zcmn_err().
 
 |