2002-10-16 02:10:08 +00:00
|
|
|
/* $FreeBSD$ */
|
|
|
|
/* $KAME: keysock.c,v 1.25 2001/08/13 20:07:41 itojun Exp $ */
|
|
|
|
|
2005-01-07 01:45:51 +00:00
|
|
|
/*-
|
2002-10-16 02:10:08 +00:00
|
|
|
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. Neither the name of the project nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "opt_ipsec.h"
|
|
|
|
|
|
|
|
/* This code has derived from sys/net/rtsock.c on FreeBSD2.2.5 */
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/domain.h>
|
|
|
|
#include <sys/errno.h>
|
|
|
|
#include <sys/kernel.h>
|
2004-06-23 01:58:22 +00:00
|
|
|
#include <sys/lock.h>
|
2002-10-16 02:10:08 +00:00
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/mbuf.h>
|
2004-06-23 01:58:22 +00:00
|
|
|
#include <sys/mutex.h>
|
2007-11-12 23:47:48 +00:00
|
|
|
#include <sys/priv.h>
|
2002-10-16 02:10:08 +00:00
|
|
|
#include <sys/protosw.h>
|
|
|
|
#include <sys/signalvar.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/socketvar.h>
|
|
|
|
#include <sys/sysctl.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
|
Step 1.5 of importing the network stack virtualization infrastructure
from the vimage project, as per plan established at devsummit 08/08:
http://wiki.freebsd.org/Image/Notes200808DevSummit
Introduce INIT_VNET_*() initializer macros, VNET_FOREACH() iterator
macros, and CURVNET_SET() context setting macros, all currently
resolving to NOPs.
Prepare for virtualization of selected SYSCTL objects by introducing a
family of SYSCTL_V_*() macros, currently resolving to their global
counterparts, i.e. SYSCTL_V_INT() == SYSCTL_INT().
Move selected #defines from sys/sys/vimage.h to newly introduced header
files specific to virtualized subsystems (sys/net/vnet.h,
sys/netinet/vinet.h etc.).
All the changes are verified to have zero functional impact at this
point in time by doing MD5 comparision between pre- and post-change
object files(*).
(*) netipsec/keysock.c did not validate depending on compile time options.
Implemented by: julian, bz, brooks, zec
Reviewed by: julian, bz, brooks, kris, rwatson, ...
Approved by: julian (mentor)
Obtained from: //depot/projects/vimage-commit2/...
X-MFC after: never
Sponsored by: NLnet Foundation, The FreeBSD Foundation
2008-10-02 15:37:58 +00:00
|
|
|
#include <net/if.h>
|
2013-10-26 18:18:50 +00:00
|
|
|
#include <net/vnet.h>
|
2002-10-16 02:10:08 +00:00
|
|
|
#include <net/raw_cb.h>
|
|
|
|
|
Step 1.5 of importing the network stack virtualization infrastructure
from the vimage project, as per plan established at devsummit 08/08:
http://wiki.freebsd.org/Image/Notes200808DevSummit
Introduce INIT_VNET_*() initializer macros, VNET_FOREACH() iterator
macros, and CURVNET_SET() context setting macros, all currently
resolving to NOPs.
Prepare for virtualization of selected SYSCTL objects by introducing a
family of SYSCTL_V_*() macros, currently resolving to their global
counterparts, i.e. SYSCTL_V_INT() == SYSCTL_INT().
Move selected #defines from sys/sys/vimage.h to newly introduced header
files specific to virtualized subsystems (sys/net/vnet.h,
sys/netinet/vinet.h etc.).
All the changes are verified to have zero functional impact at this
point in time by doing MD5 comparision between pre- and post-change
object files(*).
(*) netipsec/keysock.c did not validate depending on compile time options.
Implemented by: julian, bz, brooks, zec
Reviewed by: julian, bz, brooks, kris, rwatson, ...
Approved by: julian (mentor)
Obtained from: //depot/projects/vimage-commit2/...
X-MFC after: never
Sponsored by: NLnet Foundation, The FreeBSD Foundation
2008-10-02 15:37:58 +00:00
|
|
|
#include <netinet/in.h>
|
|
|
|
|
2002-10-16 02:10:08 +00:00
|
|
|
#include <net/pfkeyv2.h>
|
|
|
|
#include <netipsec/key.h>
|
|
|
|
#include <netipsec/keysock.h>
|
|
|
|
#include <netipsec/key_debug.h>
|
Step 1.5 of importing the network stack virtualization infrastructure
from the vimage project, as per plan established at devsummit 08/08:
http://wiki.freebsd.org/Image/Notes200808DevSummit
Introduce INIT_VNET_*() initializer macros, VNET_FOREACH() iterator
macros, and CURVNET_SET() context setting macros, all currently
resolving to NOPs.
Prepare for virtualization of selected SYSCTL objects by introducing a
family of SYSCTL_V_*() macros, currently resolving to their global
counterparts, i.e. SYSCTL_V_INT() == SYSCTL_INT().
Move selected #defines from sys/sys/vimage.h to newly introduced header
files specific to virtualized subsystems (sys/net/vnet.h,
sys/netinet/vinet.h etc.).
All the changes are verified to have zero functional impact at this
point in time by doing MD5 comparision between pre- and post-change
object files(*).
(*) netipsec/keysock.c did not validate depending on compile time options.
Implemented by: julian, bz, brooks, zec
Reviewed by: julian, bz, brooks, kris, rwatson, ...
Approved by: julian (mentor)
Obtained from: //depot/projects/vimage-commit2/...
X-MFC after: never
Sponsored by: NLnet Foundation, The FreeBSD Foundation
2008-10-02 15:37:58 +00:00
|
|
|
#include <netipsec/ipsec.h>
|
2002-10-16 02:10:08 +00:00
|
|
|
|
|
|
|
#include <machine/stdarg.h>
|
|
|
|
|
Build on Jeff Roberson's linker-set based dynamic per-CPU allocator
(DPCPU), as suggested by Peter Wemm, and implement a new per-virtual
network stack memory allocator. Modify vnet to use the allocator
instead of monolithic global container structures (vinet, ...). This
change solves many binary compatibility problems associated with
VIMAGE, and restores ELF symbols for virtualized global variables.
Each virtualized global variable exists as a "reference copy", and also
once per virtual network stack. Virtualized global variables are
tagged at compile-time, placing the in a special linker set, which is
loaded into a contiguous region of kernel memory. Virtualized global
variables in the base kernel are linked as normal, but those in modules
are copied and relocated to a reserved portion of the kernel's vnet
region with the help of a the kernel linker.
Virtualized global variables exist in per-vnet memory set up when the
network stack instance is created, and are initialized statically from
the reference copy. Run-time access occurs via an accessor macro, which
converts from the current vnet and requested symbol to a per-vnet
address. When "options VIMAGE" is not compiled into the kernel, normal
global ELF symbols will be used instead and indirection is avoided.
This change restores static initialization for network stack global
variables, restores support for non-global symbols and types, eliminates
the need for many subsystem constructors, eliminates large per-subsystem
structures that caused many binary compatibility issues both for
monitoring applications (netstat) and kernel modules, removes the
per-function INIT_VNET_*() macros throughout the stack, eliminates the
need for vnet_symmap ksym(2) munging, and eliminates duplicate
definitions of virtualized globals under VIMAGE_GLOBALS.
Bump __FreeBSD_version and update UPDATING.
Portions submitted by: bz
Reviewed by: bz, zec
Discussed with: gnn, jamie, jeff, jhb, julian, sam
Suggested by: peter
Approved by: re (kensmith)
2009-07-14 22:48:30 +00:00
|
|
|
struct key_cb {
|
|
|
|
int key_count;
|
|
|
|
int any_count;
|
|
|
|
};
|
2010-11-22 19:32:54 +00:00
|
|
|
static VNET_DEFINE(struct key_cb, key_cb);
|
2009-07-16 21:13:04 +00:00
|
|
|
#define V_key_cb VNET(key_cb)
|
2002-10-16 02:10:08 +00:00
|
|
|
|
Build on Jeff Roberson's linker-set based dynamic per-CPU allocator
(DPCPU), as suggested by Peter Wemm, and implement a new per-virtual
network stack memory allocator. Modify vnet to use the allocator
instead of monolithic global container structures (vinet, ...). This
change solves many binary compatibility problems associated with
VIMAGE, and restores ELF symbols for virtualized global variables.
Each virtualized global variable exists as a "reference copy", and also
once per virtual network stack. Virtualized global variables are
tagged at compile-time, placing the in a special linker set, which is
loaded into a contiguous region of kernel memory. Virtualized global
variables in the base kernel are linked as normal, but those in modules
are copied and relocated to a reserved portion of the kernel's vnet
region with the help of a the kernel linker.
Virtualized global variables exist in per-vnet memory set up when the
network stack instance is created, and are initialized statically from
the reference copy. Run-time access occurs via an accessor macro, which
converts from the current vnet and requested symbol to a per-vnet
address. When "options VIMAGE" is not compiled into the kernel, normal
global ELF symbols will be used instead and indirection is avoided.
This change restores static initialization for network stack global
variables, restores support for non-global symbols and types, eliminates
the need for many subsystem constructors, eliminates large per-subsystem
structures that caused many binary compatibility issues both for
monitoring applications (netstat) and kernel modules, removes the
per-function INIT_VNET_*() macros throughout the stack, eliminates the
need for vnet_symmap ksym(2) munging, and eliminates duplicate
definitions of virtualized globals under VIMAGE_GLOBALS.
Bump __FreeBSD_version and update UPDATING.
Portions submitted by: bz
Reviewed by: bz, zec
Discussed with: gnn, jamie, jeff, jhb, julian, sam
Suggested by: peter
Approved by: re (kensmith)
2009-07-14 22:48:30 +00:00
|
|
|
static struct sockaddr key_src = { 2, PF_KEY, };
|
2002-10-16 02:10:08 +00:00
|
|
|
|
2014-12-03 04:08:41 +00:00
|
|
|
static int key_sendup0(struct rawcb *, struct mbuf *, int);
|
2002-10-16 02:10:08 +00:00
|
|
|
|
2013-07-09 10:08:13 +00:00
|
|
|
VNET_PCPUSTAT_DEFINE(struct pfkeystat, pfkeystat);
|
|
|
|
VNET_PCPUSTAT_SYSINIT(pfkeystat);
|
|
|
|
|
|
|
|
#ifdef VIMAGE
|
|
|
|
VNET_PCPUSTAT_SYSUNINIT(pfkeystat);
|
|
|
|
#endif /* VIMAGE */
|
Build on Jeff Roberson's linker-set based dynamic per-CPU allocator
(DPCPU), as suggested by Peter Wemm, and implement a new per-virtual
network stack memory allocator. Modify vnet to use the allocator
instead of monolithic global container structures (vinet, ...). This
change solves many binary compatibility problems associated with
VIMAGE, and restores ELF symbols for virtualized global variables.
Each virtualized global variable exists as a "reference copy", and also
once per virtual network stack. Virtualized global variables are
tagged at compile-time, placing the in a special linker set, which is
loaded into a contiguous region of kernel memory. Virtualized global
variables in the base kernel are linked as normal, but those in modules
are copied and relocated to a reserved portion of the kernel's vnet
region with the help of a the kernel linker.
Virtualized global variables exist in per-vnet memory set up when the
network stack instance is created, and are initialized statically from
the reference copy. Run-time access occurs via an accessor macro, which
converts from the current vnet and requested symbol to a per-vnet
address. When "options VIMAGE" is not compiled into the kernel, normal
global ELF symbols will be used instead and indirection is avoided.
This change restores static initialization for network stack global
variables, restores support for non-global symbols and types, eliminates
the need for many subsystem constructors, eliminates large per-subsystem
structures that caused many binary compatibility issues both for
monitoring applications (netstat) and kernel modules, removes the
per-function INIT_VNET_*() macros throughout the stack, eliminates the
need for vnet_symmap ksym(2) munging, and eliminates duplicate
definitions of virtualized globals under VIMAGE_GLOBALS.
Bump __FreeBSD_version and update UPDATING.
Portions submitted by: bz
Reviewed by: bz, zec
Discussed with: gnn, jamie, jeff, jhb, julian, sam
Suggested by: peter
Approved by: re (kensmith)
2009-07-14 22:48:30 +00:00
|
|
|
|
2002-10-16 02:10:08 +00:00
|
|
|
/*
|
|
|
|
* key_output()
|
|
|
|
*/
|
|
|
|
int
|
2014-08-15 02:43:02 +00:00
|
|
|
key_output(struct mbuf *m, struct socket *so, ...)
|
2002-10-16 02:10:08 +00:00
|
|
|
{
|
|
|
|
struct sadb_msg *msg;
|
|
|
|
int len, error = 0;
|
|
|
|
|
2016-04-15 17:30:33 +00:00
|
|
|
if (m == NULL)
|
2003-09-29 22:57:43 +00:00
|
|
|
panic("%s: NULL pointer was passed.\n", __func__);
|
2002-10-16 02:10:08 +00:00
|
|
|
|
2013-06-20 11:44:16 +00:00
|
|
|
PFKEYSTAT_INC(out_total);
|
|
|
|
PFKEYSTAT_ADD(out_bytes, m->m_pkthdr.len);
|
2002-10-16 02:10:08 +00:00
|
|
|
|
|
|
|
len = m->m_pkthdr.len;
|
|
|
|
if (len < sizeof(struct sadb_msg)) {
|
2013-06-20 11:44:16 +00:00
|
|
|
PFKEYSTAT_INC(out_tooshort);
|
2002-10-16 02:10:08 +00:00
|
|
|
error = EINVAL;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m->m_len < sizeof(struct sadb_msg)) {
|
2016-04-15 17:30:33 +00:00
|
|
|
if ((m = m_pullup(m, sizeof(struct sadb_msg))) == NULL) {
|
2013-06-20 11:44:16 +00:00
|
|
|
PFKEYSTAT_INC(out_nomem);
|
2002-10-16 02:10:08 +00:00
|
|
|
error = ENOBUFS;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-04-08 14:25:47 +00:00
|
|
|
M_ASSERTPKTHDR(m);
|
2002-10-16 02:10:08 +00:00
|
|
|
|
2017-02-06 08:49:57 +00:00
|
|
|
KEYDBG(KEY_DUMP, kdebug_mbuf(m));
|
2002-10-16 02:10:08 +00:00
|
|
|
|
|
|
|
msg = mtod(m, struct sadb_msg *);
|
2013-06-20 11:44:16 +00:00
|
|
|
PFKEYSTAT_INC(out_msgtype[msg->sadb_msg_type]);
|
2002-10-16 02:10:08 +00:00
|
|
|
if (len != PFKEY_UNUNIT64(msg->sadb_msg_len)) {
|
2013-06-20 11:44:16 +00:00
|
|
|
PFKEYSTAT_INC(out_invlen);
|
2002-10-16 02:10:08 +00:00
|
|
|
error = EINVAL;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = key_parse(m, so);
|
|
|
|
m = NULL;
|
|
|
|
end:
|
|
|
|
if (m)
|
|
|
|
m_freem(m);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* send message to the socket.
|
|
|
|
*/
|
|
|
|
static int
|
2014-12-03 03:50:54 +00:00
|
|
|
key_sendup0(struct rawcb *rp, struct mbuf *m, int promisc)
|
2002-10-16 02:10:08 +00:00
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
|
|
|
if (promisc) {
|
|
|
|
struct sadb_msg *pmsg;
|
|
|
|
|
2012-12-05 08:04:20 +00:00
|
|
|
M_PREPEND(m, sizeof(struct sadb_msg), M_NOWAIT);
|
2014-12-04 05:02:12 +00:00
|
|
|
if (m == NULL) {
|
2013-06-20 11:44:16 +00:00
|
|
|
PFKEYSTAT_INC(in_nomem);
|
2014-12-04 05:02:12 +00:00
|
|
|
return (ENOBUFS);
|
2002-10-16 02:10:08 +00:00
|
|
|
}
|
|
|
|
pmsg = mtod(m, struct sadb_msg *);
|
|
|
|
bzero(pmsg, sizeof(*pmsg));
|
|
|
|
pmsg->sadb_msg_version = PF_KEY_V2;
|
|
|
|
pmsg->sadb_msg_type = SADB_X_PROMISC;
|
|
|
|
pmsg->sadb_msg_len = PFKEY_UNIT64(m->m_pkthdr.len);
|
|
|
|
/* pid and seq? */
|
|
|
|
|
2013-06-20 11:44:16 +00:00
|
|
|
PFKEYSTAT_INC(in_msgtype[pmsg->sadb_msg_type]);
|
2002-10-16 02:10:08 +00:00
|
|
|
}
|
|
|
|
|
2008-11-26 22:32:07 +00:00
|
|
|
if (!sbappendaddr(&rp->rcb_socket->so_rcv, (struct sockaddr *)&key_src,
|
2002-10-16 02:10:08 +00:00
|
|
|
m, NULL)) {
|
2013-06-20 11:44:16 +00:00
|
|
|
PFKEYSTAT_INC(in_nomem);
|
2002-10-16 02:10:08 +00:00
|
|
|
m_freem(m);
|
|
|
|
error = ENOBUFS;
|
|
|
|
} else
|
|
|
|
error = 0;
|
|
|
|
sorwakeup(rp->rcb_socket);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX this interface should be obsoleted. */
|
|
|
|
int
|
2014-12-03 03:50:54 +00:00
|
|
|
key_sendup(struct socket *so, struct sadb_msg *msg, u_int len, int target)
|
2002-10-16 02:10:08 +00:00
|
|
|
{
|
|
|
|
struct mbuf *m, *n, *mprev;
|
|
|
|
int tlen;
|
|
|
|
|
|
|
|
/* sanity check */
|
2016-04-15 17:30:33 +00:00
|
|
|
if (so == NULL || msg == NULL)
|
2003-09-29 22:57:43 +00:00
|
|
|
panic("%s: NULL pointer was passed.\n", __func__);
|
2002-10-16 02:10:08 +00:00
|
|
|
|
2017-02-06 08:49:57 +00:00
|
|
|
KEYDBG(KEY_DUMP,
|
|
|
|
printf("%s: \n", __func__);
|
|
|
|
kdebug_sadb(msg));
|
2002-10-16 02:10:08 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* we increment statistics here, just in case we have ENOBUFS
|
|
|
|
* in this function.
|
|
|
|
*/
|
2013-06-20 11:44:16 +00:00
|
|
|
PFKEYSTAT_INC(in_total);
|
|
|
|
PFKEYSTAT_ADD(in_bytes, len);
|
|
|
|
PFKEYSTAT_INC(in_msgtype[msg->sadb_msg_type]);
|
2002-10-16 02:10:08 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Get mbuf chain whenever possible (not clusters),
|
|
|
|
* to save socket buffer. We'll be generating many SADB_ACQUIRE
|
|
|
|
* messages to listening key sockets. If we simply allocate clusters,
|
|
|
|
* sbappendaddr() will raise ENOBUFS due to too little sbspace().
|
|
|
|
* sbspace() computes # of actual data bytes AND mbuf region.
|
|
|
|
*
|
|
|
|
* TODO: SADB_ACQUIRE filters should be implemented.
|
|
|
|
*/
|
|
|
|
tlen = len;
|
|
|
|
m = mprev = NULL;
|
|
|
|
while (tlen > 0) {
|
|
|
|
if (tlen == len) {
|
2012-12-05 08:04:20 +00:00
|
|
|
MGETHDR(n, M_NOWAIT, MT_DATA);
|
2007-07-01 11:41:27 +00:00
|
|
|
if (n == NULL) {
|
2013-06-20 11:44:16 +00:00
|
|
|
PFKEYSTAT_INC(in_nomem);
|
2007-07-01 11:41:27 +00:00
|
|
|
return ENOBUFS;
|
|
|
|
}
|
2002-10-16 02:10:08 +00:00
|
|
|
n->m_len = MHLEN;
|
|
|
|
} else {
|
2012-12-05 08:04:20 +00:00
|
|
|
MGET(n, M_NOWAIT, MT_DATA);
|
2007-07-01 11:41:27 +00:00
|
|
|
if (n == NULL) {
|
2013-06-20 11:44:16 +00:00
|
|
|
PFKEYSTAT_INC(in_nomem);
|
2007-07-01 11:41:27 +00:00
|
|
|
return ENOBUFS;
|
|
|
|
}
|
2002-10-16 02:10:08 +00:00
|
|
|
n->m_len = MLEN;
|
|
|
|
}
|
|
|
|
if (tlen >= MCLBYTES) { /*XXX better threshold? */
|
2015-01-06 12:59:37 +00:00
|
|
|
if (!(MCLGET(n, M_NOWAIT))) {
|
2002-10-16 02:10:08 +00:00
|
|
|
m_free(n);
|
|
|
|
m_freem(m);
|
2013-06-20 11:44:16 +00:00
|
|
|
PFKEYSTAT_INC(in_nomem);
|
2002-10-16 02:10:08 +00:00
|
|
|
return ENOBUFS;
|
|
|
|
}
|
|
|
|
n->m_len = MCLBYTES;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tlen < n->m_len)
|
|
|
|
n->m_len = tlen;
|
|
|
|
n->m_next = NULL;
|
|
|
|
if (m == NULL)
|
|
|
|
m = mprev = n;
|
|
|
|
else {
|
|
|
|
mprev->m_next = n;
|
|
|
|
mprev = n;
|
|
|
|
}
|
|
|
|
tlen -= n->m_len;
|
|
|
|
n = NULL;
|
|
|
|
}
|
|
|
|
m->m_pkthdr.len = len;
|
|
|
|
m->m_pkthdr.rcvif = NULL;
|
|
|
|
m_copyback(m, 0, len, (caddr_t)msg);
|
|
|
|
|
|
|
|
/* avoid duplicated statistics */
|
2013-06-20 11:44:16 +00:00
|
|
|
PFKEYSTAT_ADD(in_total, -1);
|
|
|
|
PFKEYSTAT_ADD(in_bytes, -len);
|
|
|
|
PFKEYSTAT_ADD(in_msgtype[msg->sadb_msg_type], -1);
|
2002-10-16 02:10:08 +00:00
|
|
|
|
|
|
|
return key_sendup_mbuf(so, m, target);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* so can be NULL if target != KEY_SENDUP_ONE */
|
|
|
|
int
|
2014-12-03 03:50:54 +00:00
|
|
|
key_sendup_mbuf(struct socket *so, struct mbuf *m, int target)
|
2002-10-16 02:10:08 +00:00
|
|
|
{
|
|
|
|
struct mbuf *n;
|
|
|
|
struct keycb *kp;
|
|
|
|
int sendup;
|
|
|
|
struct rawcb *rp;
|
|
|
|
int error = 0;
|
|
|
|
|
|
|
|
if (m == NULL)
|
|
|
|
panic("key_sendup_mbuf: NULL pointer was passed.\n");
|
|
|
|
if (so == NULL && target == KEY_SENDUP_ONE)
|
2003-09-29 22:57:43 +00:00
|
|
|
panic("%s: NULL pointer was passed.\n", __func__);
|
2002-10-16 02:10:08 +00:00
|
|
|
|
2013-06-20 11:44:16 +00:00
|
|
|
PFKEYSTAT_INC(in_total);
|
|
|
|
PFKEYSTAT_ADD(in_bytes, m->m_pkthdr.len);
|
2002-10-16 02:10:08 +00:00
|
|
|
if (m->m_len < sizeof(struct sadb_msg)) {
|
|
|
|
m = m_pullup(m, sizeof(struct sadb_msg));
|
|
|
|
if (m == NULL) {
|
2013-06-20 11:44:16 +00:00
|
|
|
PFKEYSTAT_INC(in_nomem);
|
2002-10-16 02:10:08 +00:00
|
|
|
return ENOBUFS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (m->m_len >= sizeof(struct sadb_msg)) {
|
|
|
|
struct sadb_msg *msg;
|
|
|
|
msg = mtod(m, struct sadb_msg *);
|
2013-06-20 11:44:16 +00:00
|
|
|
PFKEYSTAT_INC(in_msgtype[msg->sadb_msg_type]);
|
2002-10-16 02:10:08 +00:00
|
|
|
}
|
2007-07-01 11:41:27 +00:00
|
|
|
mtx_lock(&rawcb_mtx);
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
LIST_FOREACH(rp, &V_rawcb_list, list)
|
2002-10-16 02:10:08 +00:00
|
|
|
{
|
|
|
|
if (rp->rcb_proto.sp_family != PF_KEY)
|
|
|
|
continue;
|
|
|
|
if (rp->rcb_proto.sp_protocol
|
|
|
|
&& rp->rcb_proto.sp_protocol != PF_KEY_V2) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
kp = (struct keycb *)rp;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If you are in promiscuous mode, and when you get broadcasted
|
|
|
|
* reply, you'll get two PF_KEY messages.
|
|
|
|
* (based on pf_key@inner.net message on 14 Oct 1998)
|
|
|
|
*/
|
|
|
|
if (((struct keycb *)rp)->kp_promisc) {
|
2016-09-15 07:41:48 +00:00
|
|
|
if ((n = m_copym(m, 0, M_COPYALL, M_NOWAIT)) != NULL) {
|
2002-10-16 02:10:08 +00:00
|
|
|
(void)key_sendup0(rp, n, 1);
|
|
|
|
n = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* the exact target will be processed later */
|
|
|
|
if (so && sotorawcb(so) == rp)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
sendup = 0;
|
|
|
|
switch (target) {
|
|
|
|
case KEY_SENDUP_ONE:
|
|
|
|
/* the statement has no effect */
|
|
|
|
if (so && sotorawcb(so) == rp)
|
|
|
|
sendup++;
|
|
|
|
break;
|
|
|
|
case KEY_SENDUP_ALL:
|
|
|
|
sendup++;
|
|
|
|
break;
|
|
|
|
case KEY_SENDUP_REGISTERED:
|
|
|
|
if (kp->kp_registered)
|
|
|
|
sendup++;
|
|
|
|
break;
|
|
|
|
}
|
2013-06-20 11:44:16 +00:00
|
|
|
PFKEYSTAT_INC(in_msgtarget[target]);
|
2002-10-16 02:10:08 +00:00
|
|
|
|
|
|
|
if (!sendup)
|
|
|
|
continue;
|
|
|
|
|
2016-09-15 07:41:48 +00:00
|
|
|
if ((n = m_copym(m, 0, M_COPYALL, M_NOWAIT)) == NULL) {
|
2002-10-16 02:10:08 +00:00
|
|
|
m_freem(m);
|
2013-06-20 11:44:16 +00:00
|
|
|
PFKEYSTAT_INC(in_nomem);
|
2007-07-01 11:41:27 +00:00
|
|
|
mtx_unlock(&rawcb_mtx);
|
2002-10-16 02:10:08 +00:00
|
|
|
return ENOBUFS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((error = key_sendup0(rp, n, 0)) != 0) {
|
|
|
|
m_freem(m);
|
2007-07-01 11:41:27 +00:00
|
|
|
mtx_unlock(&rawcb_mtx);
|
2002-10-16 02:10:08 +00:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
n = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (so) {
|
|
|
|
error = key_sendup0(sotorawcb(so), m, 0);
|
|
|
|
m = NULL;
|
|
|
|
} else {
|
|
|
|
error = 0;
|
|
|
|
m_freem(m);
|
|
|
|
}
|
2007-07-01 11:41:27 +00:00
|
|
|
mtx_unlock(&rawcb_mtx);
|
2002-10-16 02:10:08 +00:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* key_abort()
|
|
|
|
* derived from net/rtsock.c:rts_abort()
|
|
|
|
*/
|
2006-04-01 15:15:05 +00:00
|
|
|
static void
|
2002-10-16 02:10:08 +00:00
|
|
|
key_abort(struct socket *so)
|
|
|
|
{
|
2006-04-01 15:15:05 +00:00
|
|
|
raw_usrreqs.pru_abort(so);
|
2002-10-16 02:10:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* key_attach()
|
|
|
|
* derived from net/rtsock.c:rts_attach()
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
key_attach(struct socket *so, int proto, struct thread *td)
|
|
|
|
{
|
|
|
|
struct keycb *kp;
|
2007-07-01 11:41:27 +00:00
|
|
|
int error;
|
|
|
|
|
|
|
|
KASSERT(so->so_pcb == NULL, ("key_attach: so_pcb != NULL"));
|
2002-10-16 02:10:08 +00:00
|
|
|
|
2007-11-16 22:35:33 +00:00
|
|
|
if (td != NULL) {
|
|
|
|
error = priv_check(td, PRIV_NET_RAW);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2007-07-01 11:41:27 +00:00
|
|
|
/* XXX */
|
2008-10-23 15:53:51 +00:00
|
|
|
kp = malloc(sizeof *kp, M_PCB, M_WAITOK | M_ZERO);
|
2016-04-15 17:30:33 +00:00
|
|
|
if (kp == NULL)
|
2002-10-16 02:10:08 +00:00
|
|
|
return ENOBUFS;
|
|
|
|
|
|
|
|
so->so_pcb = (caddr_t)kp;
|
2007-07-01 11:41:27 +00:00
|
|
|
error = raw_attach(so, proto);
|
2002-10-16 02:10:08 +00:00
|
|
|
kp = (struct keycb *)sotorawcb(so);
|
|
|
|
if (error) {
|
|
|
|
free(kp, M_PCB);
|
|
|
|
so->so_pcb = (caddr_t) 0;
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
kp->kp_promisc = kp->kp_registered = 0;
|
|
|
|
|
|
|
|
if (kp->kp_raw.rcb_proto.sp_protocol == PF_KEY) /* XXX: AF_KEY */
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
V_key_cb.key_count++;
|
|
|
|
V_key_cb.any_count++;
|
2002-10-16 02:10:08 +00:00
|
|
|
soisconnected(so);
|
|
|
|
so->so_options |= SO_USELOOPBACK;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* key_bind()
|
|
|
|
* derived from net/rtsock.c:rts_bind()
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
key_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
|
|
|
|
{
|
2007-07-01 11:41:27 +00:00
|
|
|
return EINVAL;
|
2002-10-16 02:10:08 +00:00
|
|
|
}
|
|
|
|
|
2006-07-21 17:11:15 +00:00
|
|
|
/*
|
|
|
|
* key_close()
|
|
|
|
* derived from net/rtsock.c:rts_close().
|
|
|
|
*/
|
|
|
|
static void
|
2006-07-22 09:18:02 +00:00
|
|
|
key_close(struct socket *so)
|
2006-07-21 17:11:15 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
raw_usrreqs.pru_close(so);
|
|
|
|
}
|
|
|
|
|
2002-10-16 02:10:08 +00:00
|
|
|
/*
|
|
|
|
* key_connect()
|
|
|
|
* derived from net/rtsock.c:rts_connect()
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
key_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
|
|
|
|
{
|
2007-07-01 11:41:27 +00:00
|
|
|
return EINVAL;
|
2002-10-16 02:10:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* key_detach()
|
|
|
|
* derived from net/rtsock.c:rts_detach()
|
|
|
|
*/
|
Chance protocol switch method pru_detach() so that it returns void
rather than an error. Detaches do not "fail", they other occur or
the protocol flags SS_PROTOREF to take ownership of the socket.
soclose() no longer looks at so_pcb to see if it's NULL, relying
entirely on the protocol to decide whether it's time to free the
socket or not using SS_PROTOREF. so_pcb is now entirely owned and
managed by the protocol code. Likewise, no longer test so_pcb in
other socket functions, such as soreceive(), which have no business
digging into protocol internals.
Protocol detach routines no longer try to free the socket on detach,
this is performed in the socket code if the protocol permits it.
In rts_detach(), no longer test for rp != NULL in detach, and
likewise in other protocols that don't permit a NULL so_pcb, reduce
the incidence of testing for it during detach.
netinet and netinet6 are not fully updated to this change, which
will be in an upcoming commit. In their current state they may leak
memory or panic.
MFC after: 3 months
2006-04-01 15:42:02 +00:00
|
|
|
static void
|
2002-10-16 02:10:08 +00:00
|
|
|
key_detach(struct socket *so)
|
|
|
|
{
|
|
|
|
struct keycb *kp = (struct keycb *)sotorawcb(so);
|
|
|
|
|
Chance protocol switch method pru_detach() so that it returns void
rather than an error. Detaches do not "fail", they other occur or
the protocol flags SS_PROTOREF to take ownership of the socket.
soclose() no longer looks at so_pcb to see if it's NULL, relying
entirely on the protocol to decide whether it's time to free the
socket or not using SS_PROTOREF. so_pcb is now entirely owned and
managed by the protocol code. Likewise, no longer test so_pcb in
other socket functions, such as soreceive(), which have no business
digging into protocol internals.
Protocol detach routines no longer try to free the socket on detach,
this is performed in the socket code if the protocol permits it.
In rts_detach(), no longer test for rp != NULL in detach, and
likewise in other protocols that don't permit a NULL so_pcb, reduce
the incidence of testing for it during detach.
netinet and netinet6 are not fully updated to this change, which
will be in an upcoming commit. In their current state they may leak
memory or panic.
MFC after: 3 months
2006-04-01 15:42:02 +00:00
|
|
|
KASSERT(kp != NULL, ("key_detach: kp == NULL"));
|
|
|
|
if (kp->kp_raw.rcb_proto.sp_protocol
|
|
|
|
== PF_KEY) /* XXX: AF_KEY */
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
V_key_cb.key_count--;
|
|
|
|
V_key_cb.any_count--;
|
2002-10-16 02:10:08 +00:00
|
|
|
|
Chance protocol switch method pru_detach() so that it returns void
rather than an error. Detaches do not "fail", they other occur or
the protocol flags SS_PROTOREF to take ownership of the socket.
soclose() no longer looks at so_pcb to see if it's NULL, relying
entirely on the protocol to decide whether it's time to free the
socket or not using SS_PROTOREF. so_pcb is now entirely owned and
managed by the protocol code. Likewise, no longer test so_pcb in
other socket functions, such as soreceive(), which have no business
digging into protocol internals.
Protocol detach routines no longer try to free the socket on detach,
this is performed in the socket code if the protocol permits it.
In rts_detach(), no longer test for rp != NULL in detach, and
likewise in other protocols that don't permit a NULL so_pcb, reduce
the incidence of testing for it during detach.
netinet and netinet6 are not fully updated to this change, which
will be in an upcoming commit. In their current state they may leak
memory or panic.
MFC after: 3 months
2006-04-01 15:42:02 +00:00
|
|
|
key_freereg(so);
|
|
|
|
raw_usrreqs.pru_detach(so);
|
2002-10-16 02:10:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* key_disconnect()
|
|
|
|
* derived from net/rtsock.c:key_disconnect()
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
key_disconnect(struct socket *so)
|
|
|
|
{
|
2007-07-01 11:41:27 +00:00
|
|
|
return(raw_usrreqs.pru_disconnect(so));
|
2002-10-16 02:10:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* key_peeraddr()
|
|
|
|
* derived from net/rtsock.c:rts_peeraddr()
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
key_peeraddr(struct socket *so, struct sockaddr **nam)
|
|
|
|
{
|
2007-07-01 11:41:27 +00:00
|
|
|
return(raw_usrreqs.pru_peeraddr(so, nam));
|
2002-10-16 02:10:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* key_send()
|
|
|
|
* derived from net/rtsock.c:rts_send()
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
key_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam,
|
|
|
|
struct mbuf *control, struct thread *td)
|
|
|
|
{
|
2007-07-01 11:41:27 +00:00
|
|
|
return(raw_usrreqs.pru_send(so, flags, m, nam, control, td));
|
2002-10-16 02:10:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* key_shutdown()
|
|
|
|
* derived from net/rtsock.c:rts_shutdown()
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
key_shutdown(struct socket *so)
|
|
|
|
{
|
2007-07-01 11:41:27 +00:00
|
|
|
return(raw_usrreqs.pru_shutdown(so));
|
2002-10-16 02:10:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* key_sockaddr()
|
|
|
|
* derived from net/rtsock.c:rts_sockaddr()
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
key_sockaddr(struct socket *so, struct sockaddr **nam)
|
|
|
|
{
|
2007-07-01 11:41:27 +00:00
|
|
|
return(raw_usrreqs.pru_sockaddr(so, nam));
|
2002-10-16 02:10:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct pr_usrreqs key_usrreqs = {
|
2004-11-08 14:44:54 +00:00
|
|
|
.pru_abort = key_abort,
|
|
|
|
.pru_attach = key_attach,
|
|
|
|
.pru_bind = key_bind,
|
|
|
|
.pru_connect = key_connect,
|
|
|
|
.pru_detach = key_detach,
|
|
|
|
.pru_disconnect = key_disconnect,
|
|
|
|
.pru_peeraddr = key_peeraddr,
|
|
|
|
.pru_send = key_send,
|
|
|
|
.pru_shutdown = key_shutdown,
|
|
|
|
.pru_sockaddr = key_sockaddr,
|
2006-07-21 17:11:15 +00:00
|
|
|
.pru_close = key_close,
|
2002-10-16 02:10:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* sysctl */
|
|
|
|
SYSCTL_NODE(_net, PF_KEY, key, CTLFLAG_RW, 0, "Key Family");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Definitions of protocols supported in the KEY domain.
|
|
|
|
*/
|
|
|
|
|
|
|
|
extern struct domain keydomain;
|
|
|
|
|
|
|
|
struct protosw keysw[] = {
|
2005-11-09 13:29:16 +00:00
|
|
|
{
|
|
|
|
.pr_type = SOCK_RAW,
|
|
|
|
.pr_domain = &keydomain,
|
|
|
|
.pr_protocol = PF_KEY_V2,
|
|
|
|
.pr_flags = PR_ATOMIC|PR_ADDR,
|
2006-01-21 10:44:34 +00:00
|
|
|
.pr_output = key_output,
|
2005-11-09 13:29:16 +00:00
|
|
|
.pr_ctlinput = raw_ctlinput,
|
|
|
|
.pr_init = raw_init,
|
|
|
|
.pr_usrreqs = &key_usrreqs
|
2002-10-16 02:10:08 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
key_init0(void)
|
|
|
|
{
|
2008-11-19 09:39:34 +00:00
|
|
|
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
bzero((caddr_t)&V_key_cb, sizeof(V_key_cb));
|
2002-10-16 02:10:08 +00:00
|
|
|
key_init();
|
|
|
|
}
|
|
|
|
|
2005-11-09 13:29:16 +00:00
|
|
|
struct domain keydomain = {
|
|
|
|
.dom_family = PF_KEY,
|
|
|
|
.dom_name = "key",
|
|
|
|
.dom_init = key_init0,
|
Introduce an infrastructure for dismantling vnet instances.
Vnet modules and protocol domains may now register destructor
functions to clean up and release per-module state. The destructor
mechanisms can be triggered by invoking "vimage -d", or a future
equivalent command which will be provided via the new jail framework.
While this patch introduces numerous placeholder destructor functions,
many of those are currently incomplete, thus leaking memory or (even
worse) failing to stop all running timers. Many of such issues are
already known and will be incrementaly fixed over the next weeks in
smaller incremental commits.
Apart from introducing new fields in structs ifnet, domain, protosw
and vnet_net, which requires the kernel and modules to be rebuilt, this
change should have no impact on nooptions VIMAGE builds, since vnet
destructors can only be called in VIMAGE kernels. Moreover,
destructor functions should be in general compiled in only in
options VIMAGE builds, except for kernel modules which can be safely
kldunloaded at run time.
Bump __FreeBSD_version to 800097.
Reviewed by: bz, julian
Approved by: rwatson, kib (re), julian (mentor)
2009-06-08 17:15:40 +00:00
|
|
|
#ifdef VIMAGE
|
|
|
|
.dom_destroy = key_destroy,
|
|
|
|
#endif
|
2005-11-09 13:29:16 +00:00
|
|
|
.dom_protosw = keysw,
|
2016-04-19 23:48:27 +00:00
|
|
|
.dom_protoswNPROTOSW = &keysw[nitems(keysw)]
|
2005-11-09 13:29:16 +00:00
|
|
|
};
|
2002-10-16 02:10:08 +00:00
|
|
|
|
Introduce and use a sysinit-based initialization scheme for virtual
network stacks, VNET_SYSINIT:
- Add VNET_SYSINIT and VNET_SYSUNINIT macros to declare events that will
occur each time a network stack is instantiated and destroyed. In the
!VIMAGE case, these are simply mapped into regular SYSINIT/SYSUNINIT.
For the VIMAGE case, we instead use SYSINIT's to track their order and
properties on registration, using them for each vnet when created/
destroyed, or immediately on module load for already-started vnets.
- Remove vnet_modinfo mechanism that existed to serve this purpose
previously, as well as its dependency scheme: we now just use the
SYSINIT ordering scheme.
- Implement VNET_DOMAIN_SET() to allow protocol domains to declare that
they want init functions to be called for each virtual network stack
rather than just once at boot, compiling down to DOMAIN_SET() in the
non-VIMAGE case.
- Walk all virtualized kernel subsystems and make use of these instead
of modinfo or DOMAIN_SET() for init/uninit events. In some cases,
convert modular components from using modevent to using sysinit (where
appropriate). In some cases, do minor rejuggling of SYSINIT ordering
to make room for or better manage events.
Portions submitted by: jhb (VNET_SYSINIT), bz (cleanup)
Discussed with: jhb, bz, julian, zec
Reviewed by: bz
Approved by: re (VIMAGE blanket)
2009-07-23 20:46:49 +00:00
|
|
|
VNET_DOMAIN_SET(key);
|