netstack.h revision 7ddc9b1afd18f260b9fb78ec7732facd91769131
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh/*
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * CDDL HEADER START
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh *
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * The contents of this file are subject to the terms of the
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * Common Development and Distribution License (the "License").
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * You may not use this file except in compliance with the License.
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh *
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * or http://www.opensolaris.org/os/licensing.
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * See the License for the specific language governing permissions
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * and limitations under the License.
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh *
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * When distributing Covered Code, include this CDDL HEADER in each
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * If applicable, add the following below this CDDL HEADER, with the
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * fields enclosed by brackets "[]" replaced with your own identifying
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * information: Portions Copyright [yyyy] [name of copyright owner]
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh *
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * CDDL HEADER END
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh */
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh/*
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * Use is subject to license terms.
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh */
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh#ifndef _SYS_NETSTACK_H
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh#define _SYS_NETSTACK_H
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh#include <sys/kstat.h>
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh#ifdef __cplusplus
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dhextern "C" {
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh#endif
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh/*
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * This allows various pieces in and around IP to have a separate instance
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * for each instance of IP. This is used to support zones that have an
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * exclusive stack.
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * Pieces of software far removed from IP (e.g., kernel software
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * sitting on top of TCP or UDP) probably should not use the netstack
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * support; if such software wants to support separate zones it
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * can do that using the zones framework (zone_key_create() etc)
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * whether there is a shared IP stack or and exclusive IP stack underneath.
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh */
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh/*
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * Each netstack has an identifier. We reuse the zoneid allocation for
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * this but have a separate typedef. Thus the shared stack (used by
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * the global zone and other shared stack zones) have a zero ID, and
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * the exclusive stacks have a netstackid that is the same as their zoneid.
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh */
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dhtypedef id_t netstackid_t;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh#define GLOBAL_NETSTACKID 0
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh/*
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * One for each module which uses netstack support.
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * Used in netstack_register().
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh *
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * The order of these is important for some modules both for
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * the creation (which done in ascending order) and destruction (which is
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * done ine in decending order).
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh */
23f4867fdff96a11dd674de6259a5a0d0a13251cnordmark#define NS_ALL -1 /* Match all */
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed#define NS_STR 0 /* autopush list etc */
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed#define NS_HOOK 1
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed#define NS_NETI 2
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed#define NS_ARP 3
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed#define NS_IP 4
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed#define NS_ICMP 5
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed#define NS_UDP 6
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed#define NS_TCP 7
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed#define NS_SCTP 8
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed#define NS_RTS 9
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed#define NS_IPSEC 10
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed#define NS_KEYSOCK 11
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed#define NS_SPDSOCK 12
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed#define NS_IPSECAH 13
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed#define NS_IPSECESP 14
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed#define NS_TUN 15
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed#define NS_MAX (NS_TUN+1)
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark/*
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark * State maintained for each module which tracks the state of
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark * the create, shutdown and destroy callbacks.
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark *
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark * Keeps track of pending actions to avoid holding locks when
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark * calling into the create/shutdown/destroy functions in the module.
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark */
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark#ifdef _KERNEL
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmarktypedef struct {
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark uint16_t nms_flags;
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark kcondvar_t nms_cv;
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark} nm_state_t;
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark/*
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark * nms_flags
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark */
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark#define NSS_CREATE_NEEDED 0x0001
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark#define NSS_CREATE_INPROGRESS 0x0002
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark#define NSS_CREATE_COMPLETED 0x0004
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark#define NSS_SHUTDOWN_NEEDED 0x0010
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark#define NSS_SHUTDOWN_INPROGRESS 0x0020
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark#define NSS_SHUTDOWN_COMPLETED 0x0040
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark#define NSS_DESTROY_NEEDED 0x0100
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark#define NSS_DESTROY_INPROGRESS 0x0200
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark#define NSS_DESTROY_COMPLETED 0x0400
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark#define NSS_CREATE_ALL \
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark (NSS_CREATE_NEEDED|NSS_CREATE_INPROGRESS|NSS_CREATE_COMPLETED)
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark#define NSS_SHUTDOWN_ALL \
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark (NSS_SHUTDOWN_NEEDED|NSS_SHUTDOWN_INPROGRESS|NSS_SHUTDOWN_COMPLETED)
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark#define NSS_DESTROY_ALL \
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark (NSS_DESTROY_NEEDED|NSS_DESTROY_INPROGRESS|NSS_DESTROY_COMPLETED)
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark#define NSS_ALL_INPROGRESS \
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark (NSS_CREATE_INPROGRESS|NSS_SHUTDOWN_INPROGRESS|NSS_DESTROY_INPROGRESS)
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark#else
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark/* User-level compile like IP Filter needs a netstack_t. Dummy */
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmarktypedef uint_t nm_state_t;
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark#endif /* _KERNEL */
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh/*
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * One for every netstack in the system.
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * We use a union so that the compilar and lint can provide type checking -
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * in principle we could have
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * #define netstack_arp netstack_modules[NS_ARP]
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * etc, but that would imply void * types hence no type checking by the
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * compiler.
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh *
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * All the fields in netstack_t except netstack_next are protected by
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * netstack_lock. netstack_next is protected by netstack_g_lock.
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh */
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dhstruct netstack {
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh union {
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh void *nu_modules[NS_MAX];
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh struct {
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed struct str_stack *nu_str;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh struct hook_stack *nu_hook;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh struct neti_stack *nu_neti;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh struct arp_stack *nu_arp;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh struct ip_stack *nu_ip;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh struct icmp_stack *nu_icmp;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh struct udp_stack *nu_udp;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh struct tcp_stack *nu_tcp;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh struct sctp_stack *nu_sctp;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh struct rts_stack *nu_rts;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh struct ipsec_stack *nu_ipsec;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh struct keysock_stack *nu_keysock;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh struct spd_stack *nu_spdsock;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh struct ipsecah_stack *nu_ipsecah;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh struct ipsecesp_stack *nu_ipsecesp;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh struct tun_stack *nu_tun;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh } nu_s;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh } netstack_u;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh#define netstack_modules netstack_u.nu_modules
7ddc9b1afd18f260b9fb78ec7732facd91769131Darren Reed#define netstack_str netstack_u.nu_s.nu_str
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh#define netstack_hook netstack_u.nu_s.nu_hook
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh#define netstack_neti netstack_u.nu_s.nu_neti
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh#define netstack_arp netstack_u.nu_s.nu_arp
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh#define netstack_ip netstack_u.nu_s.nu_ip
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh#define netstack_icmp netstack_u.nu_s.nu_icmp
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh#define netstack_udp netstack_u.nu_s.nu_udp
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh#define netstack_tcp netstack_u.nu_s.nu_tcp
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh#define netstack_sctp netstack_u.nu_s.nu_sctp
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh#define netstack_rts netstack_u.nu_s.nu_rts
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh#define netstack_ipsec netstack_u.nu_s.nu_ipsec
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh#define netstack_keysock netstack_u.nu_s.nu_keysock
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh#define netstack_spdsock netstack_u.nu_s.nu_spdsock
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh#define netstack_ipsecah netstack_u.nu_s.nu_ipsecah
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh#define netstack_ipsecesp netstack_u.nu_s.nu_ipsecesp
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh#define netstack_tun netstack_u.nu_s.nu_tun
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark nm_state_t netstack_m_state[NS_MAX]; /* module state */
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh kmutex_t netstack_lock;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh struct netstack *netstack_next;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh netstackid_t netstack_stackid;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh int netstack_numzones; /* Number of zones using this */
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh int netstack_refcnt; /* Number of hold-rele */
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh int netstack_flags; /* See below */
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark#ifdef _KERNEL
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark /* Needed to ensure that we run the callback functions in order */
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark kcondvar_t netstack_cv;
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark#endif
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh};
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dhtypedef struct netstack netstack_t;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh/* netstack_flags values */
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark#define NSF_UNINIT 0x01 /* Not initialized */
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark#define NSF_CLOSING 0x02 /* Going away */
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark#define NSF_ZONE_CREATE 0x04 /* create callbacks inprog */
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark#define NSF_ZONE_SHUTDOWN 0x08 /* shutdown callbacks */
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark#define NSF_ZONE_DESTROY 0x10 /* destroy callbacks */
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark#define NSF_ZONE_INPROGRESS \
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark (NSF_ZONE_CREATE|NSF_ZONE_SHUTDOWN|NSF_ZONE_DESTROY)
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh/*
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * One for each of the NS_* values.
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh */
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dhstruct netstack_registry {
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh int nr_flags; /* 0 if nothing registered */
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh void *(*nr_create)(netstackid_t, netstack_t *);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh void (*nr_shutdown)(netstackid_t, void *);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh void (*nr_destroy)(netstackid_t, void *);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh};
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh/* nr_flags values */
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh#define NRF_REGISTERED 0x01
bd41d0a82bd89bc81d63ae5dfc2ba4245f74ea6cnordmark#define NRF_DYING 0x02 /* No new creates */
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh/*
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * To support kstat_create_netstack() using kstat_add_zone we need
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * to track both
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * - all zoneids that use the global/shared stack
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * - all kstats that have been added for the shared stack
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh */
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dhextern void netstack_init(void);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dhextern void netstack_hold(netstack_t *);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dhextern void netstack_rele(netstack_t *);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dhextern netstack_t *netstack_find_by_cred(const cred_t *);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dhextern netstack_t *netstack_find_by_stackid(netstackid_t);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dhextern netstack_t *netstack_find_by_zoneid(zoneid_t);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dhextern zoneid_t netstackid_to_zoneid(netstackid_t);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dhextern netstackid_t zoneid_to_netstackid(zoneid_t);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
fd00680555e8f4173d02435c3b015e23cb232c49nordmarkextern netstack_t *netstack_get_current(void);
fd00680555e8f4173d02435c3b015e23cb232c49nordmark
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh/*
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * Register interest in changes to the set of netstacks.
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * The createfn and destroyfn are required, but the shutdownfn can be
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * NULL.
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * Note that due to the current zsd implementation, when the create
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * function is called the zone isn't fully present, thus functions
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * like zone_find_by_* will fail, hence the create function can not
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * use many zones kernel functions including zcmn_err().
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh */
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dhextern void netstack_register(int,
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh void *(*)(netstackid_t, netstack_t *),
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh void (*)(netstackid_t, void *),
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh void (*)(netstackid_t, void *));
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dhextern void netstack_unregister(int);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dhextern kstat_t *kstat_create_netstack(char *, int, char *, char *, uchar_t,
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh uint_t, uchar_t, netstackid_t);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dhextern void kstat_delete_netstack(kstat_t *, netstackid_t);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh/*
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * Simple support for walking all the netstacks.
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * The caller of netstack_next() needs to call netstack_rele() when
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh * done with a netstack.
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh */
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dhtypedef int netstack_handle_t;
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dhextern void netstack_next_init(netstack_handle_t *);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dhextern void netstack_next_fini(netstack_handle_t *);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dhextern netstack_t *netstack_next(netstack_handle_t *);
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh#ifdef __cplusplus
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh}
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh#endif
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh#endif /* _SYS_NETSTACK_H */