2006-06-13 17:52:39 +04:00
|
|
|
/* $NetBSD: uipc_domain.c,v 1.58 2006/06/13 13:52:39 yamt Exp $ */
|
1994-06-29 10:29:24 +04:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
1994-05-13 10:01:27 +04:00
|
|
|
* Copyright (c) 1982, 1986, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
1993-03-21 12:45:37 +03:00
|
|
|
*
|
|
|
|
* 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.
|
2003-08-07 20:26:28 +04:00
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
1993-03-21 12:45:37 +03:00
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
|
|
|
*
|
1998-03-01 05:20:01 +03:00
|
|
|
* @(#)uipc_domain.c 8.3 (Berkeley) 2/14/95
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
|
|
|
|
2001-11-12 18:25:01 +03:00
|
|
|
#include <sys/cdefs.h>
|
2006-06-13 17:52:39 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: uipc_domain.c,v 1.58 2006/06/13 13:52:39 yamt Exp $");
|
1998-07-05 04:51:04 +04:00
|
|
|
|
1993-12-18 07:21:37 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/socket.h>
|
2005-03-09 08:07:19 +03:00
|
|
|
#include <sys/socketvar.h>
|
1993-12-18 07:21:37 +03:00
|
|
|
#include <sys/protosw.h>
|
|
|
|
#include <sys/domain.h>
|
|
|
|
#include <sys/mbuf.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/kernel.h>
|
1994-05-13 10:01:27 +04:00
|
|
|
#include <sys/systm.h>
|
2000-03-23 09:30:07 +03:00
|
|
|
#include <sys/callout.h>
|
2005-01-23 21:41:56 +03:00
|
|
|
#include <sys/queue.h>
|
1994-05-07 04:46:28 +04:00
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/sysctl.h>
|
2005-03-09 08:07:19 +03:00
|
|
|
#include <sys/un.h>
|
|
|
|
#include <sys/unpcb.h>
|
|
|
|
#include <sys/file.h>
|
2006-05-15 01:15:11 +04:00
|
|
|
#include <sys/kauth.h>
|
1993-03-21 12:45:37 +03:00
|
|
|
|
2004-03-23 16:22:03 +03:00
|
|
|
void pffasttimo(void *);
|
|
|
|
void pfslowtimo(void *);
|
1994-05-13 10:01:27 +04:00
|
|
|
|
2005-01-23 21:41:56 +03:00
|
|
|
struct domainhead domains = STAILQ_HEAD_INITIALIZER(domains);
|
2002-05-13 00:36:58 +04:00
|
|
|
|
2000-03-23 09:30:07 +03:00
|
|
|
struct callout pffasttimo_ch, pfslowtimo_ch;
|
|
|
|
|
1998-05-06 05:11:46 +04:00
|
|
|
/*
|
|
|
|
* Current time values for fast and slow timeouts. We can use u_int
|
|
|
|
* relatively safely. The fast timer will roll over in 27 years and
|
|
|
|
* the slow timer in 68 years.
|
|
|
|
*/
|
|
|
|
u_int pfslowtimo_now;
|
|
|
|
u_int pffasttimo_now;
|
|
|
|
|
1993-06-27 10:01:27 +04:00
|
|
|
void
|
2005-12-08 06:10:12 +03:00
|
|
|
domaininit(void)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
2005-01-23 21:41:56 +03:00
|
|
|
__link_set_decl(domains, struct domain);
|
|
|
|
struct domain * const * dpp;
|
|
|
|
struct domain *rt_domain = NULL;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1999-07-01 12:12:45 +04:00
|
|
|
/*
|
2005-01-23 21:41:56 +03:00
|
|
|
* Add all of the domains. Make sure the PF_ROUTE
|
|
|
|
* domain is added last.
|
1999-07-01 12:12:45 +04:00
|
|
|
*/
|
2005-01-23 21:41:56 +03:00
|
|
|
__link_set_foreach(dpp, domains) {
|
|
|
|
if ((*dpp)->dom_family == PF_ROUTE)
|
|
|
|
rt_domain = *dpp;
|
|
|
|
else
|
|
|
|
domain_attach(*dpp);
|
|
|
|
}
|
|
|
|
if (rt_domain)
|
|
|
|
domain_attach(rt_domain);
|
|
|
|
|
|
|
|
callout_init(&pffasttimo_ch);
|
|
|
|
callout_init(&pfslowtimo_ch);
|
|
|
|
|
|
|
|
callout_reset(&pffasttimo_ch, 1, pffasttimo, NULL);
|
|
|
|
callout_reset(&pfslowtimo_ch, 1, pfslowtimo, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
domain_attach(struct domain *dp)
|
|
|
|
{
|
|
|
|
const struct protosw *pr;
|
|
|
|
|
|
|
|
STAILQ_INSERT_TAIL(&domains, dp, dom_link);
|
|
|
|
|
|
|
|
if (dp->dom_init)
|
|
|
|
(*dp->dom_init)();
|
1993-03-21 12:45:37 +03:00
|
|
|
|
2003-02-26 09:31:08 +03:00
|
|
|
#ifdef MBUFTRACE
|
2005-01-23 21:41:56 +03:00
|
|
|
if (dp->dom_mowner.mo_name[0] == '\0') {
|
|
|
|
strncpy(dp->dom_mowner.mo_name, dp->dom_name,
|
|
|
|
sizeof(dp->dom_mowner.mo_name));
|
|
|
|
MOWNER_ATTACH(&dp->dom_mowner);
|
|
|
|
}
|
2003-02-26 09:31:08 +03:00
|
|
|
#endif
|
2005-01-23 21:41:56 +03:00
|
|
|
for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) {
|
|
|
|
if (pr->pr_init)
|
|
|
|
(*pr->pr_init)();
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1996-08-14 09:43:35 +04:00
|
|
|
if (max_linkhdr < 16) /* XXX */
|
|
|
|
max_linkhdr = 16;
|
1993-03-21 12:45:37 +03:00
|
|
|
max_hdr = max_linkhdr + max_protohdr;
|
|
|
|
max_datalen = MHLEN - max_hdr;
|
|
|
|
}
|
|
|
|
|
2000-02-06 05:54:15 +03:00
|
|
|
struct domain *
|
2005-01-23 21:41:56 +03:00
|
|
|
pffinddomain(int family)
|
2000-02-06 05:54:15 +03:00
|
|
|
{
|
|
|
|
struct domain *dp;
|
|
|
|
|
2005-01-23 21:41:56 +03:00
|
|
|
DOMAIN_FOREACH(dp)
|
2000-02-06 05:54:15 +03:00
|
|
|
if (dp->dom_family == family)
|
|
|
|
return (dp);
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
2004-04-22 05:01:40 +04:00
|
|
|
const struct protosw *
|
2005-01-23 21:41:56 +03:00
|
|
|
pffindtype(int family, int type)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
2000-02-06 05:54:15 +03:00
|
|
|
struct domain *dp;
|
2004-04-22 05:01:40 +04:00
|
|
|
const struct protosw *pr;
|
2000-02-06 05:54:15 +03:00
|
|
|
|
|
|
|
dp = pffinddomain(family);
|
|
|
|
if (dp == NULL)
|
|
|
|
return (NULL);
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
|
|
|
|
if (pr->pr_type && pr->pr_type == type)
|
|
|
|
return (pr);
|
2000-02-06 05:54:15 +03:00
|
|
|
|
|
|
|
return (NULL);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
2004-04-22 05:01:40 +04:00
|
|
|
const struct protosw *
|
2005-01-23 21:41:56 +03:00
|
|
|
pffindproto(int family, int protocol, int type)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
2000-02-06 05:54:15 +03:00
|
|
|
struct domain *dp;
|
2004-04-22 05:01:40 +04:00
|
|
|
const struct protosw *pr;
|
|
|
|
const struct protosw *maybe = NULL;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
if (family == 0)
|
2000-02-06 05:54:15 +03:00
|
|
|
return (NULL);
|
|
|
|
|
|
|
|
dp = pffinddomain(family);
|
|
|
|
if (dp == NULL)
|
|
|
|
return (NULL);
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) {
|
|
|
|
if ((pr->pr_protocol == protocol) && (pr->pr_type == type))
|
|
|
|
return (pr);
|
|
|
|
|
|
|
|
if (type == SOCK_RAW && pr->pr_type == SOCK_RAW &&
|
2000-02-06 05:54:15 +03:00
|
|
|
pr->pr_protocol == 0 && maybe == NULL)
|
1993-03-21 12:45:37 +03:00
|
|
|
maybe = pr;
|
|
|
|
}
|
|
|
|
return (maybe);
|
|
|
|
}
|
|
|
|
|
2005-03-09 08:07:19 +03:00
|
|
|
/*
|
|
|
|
* sysctl helper to stuff PF_LOCAL pcbs into sysctl structures
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
sysctl_dounpcb(struct kinfo_pcb *pcb, const struct socket *so)
|
|
|
|
{
|
|
|
|
struct unpcb *unp = sotounpcb(so);
|
|
|
|
struct sockaddr_un *un = unp->unp_addr;
|
|
|
|
|
|
|
|
memset(pcb, 0, sizeof(*pcb));
|
|
|
|
|
|
|
|
pcb->ki_family = so->so_proto->pr_domain->dom_family;
|
|
|
|
pcb->ki_type = so->so_proto->pr_type;
|
|
|
|
pcb->ki_protocol = so->so_proto->pr_protocol;
|
|
|
|
pcb->ki_pflags = unp->unp_flags;
|
|
|
|
|
|
|
|
pcb->ki_pcbaddr = PTRTOUINT64(unp);
|
|
|
|
/* pcb->ki_ppcbaddr = unp has no ppcb... */
|
|
|
|
pcb->ki_sockaddr = PTRTOUINT64(so);
|
|
|
|
|
|
|
|
pcb->ki_sostate = so->so_state;
|
|
|
|
/* pcb->ki_prstate = unp has no state... */
|
|
|
|
|
|
|
|
pcb->ki_rcvq = so->so_rcv.sb_cc;
|
|
|
|
pcb->ki_sndq = so->so_snd.sb_cc;
|
|
|
|
|
|
|
|
un = (struct sockaddr_un *)&pcb->ki_src;
|
|
|
|
/*
|
|
|
|
* local domain sockets may bind without having a local
|
|
|
|
* endpoint. bleah!
|
|
|
|
*/
|
|
|
|
if (unp->unp_addr != NULL) {
|
|
|
|
un->sun_len = unp->unp_addr->sun_len;
|
|
|
|
un->sun_family = unp->unp_addr->sun_family;
|
|
|
|
strlcpy(un->sun_path, unp->unp_addr->sun_path,
|
|
|
|
sizeof(pcb->ki_s));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
un->sun_len = offsetof(struct sockaddr_un, sun_path);
|
|
|
|
un->sun_family = pcb->ki_family;
|
|
|
|
}
|
|
|
|
if (unp->unp_conn != NULL) {
|
|
|
|
un = (struct sockaddr_un *)&pcb->ki_dst;
|
|
|
|
if (unp->unp_conn->unp_addr != NULL) {
|
|
|
|
un->sun_len = unp->unp_conn->unp_addr->sun_len;
|
|
|
|
un->sun_family = unp->unp_conn->unp_addr->sun_family;
|
|
|
|
un->sun_family = unp->unp_conn->unp_addr->sun_family;
|
|
|
|
strlcpy(un->sun_path, unp->unp_conn->unp_addr->sun_path,
|
|
|
|
sizeof(pcb->ki_d));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
un->sun_len = offsetof(struct sockaddr_un, sun_path);
|
|
|
|
un->sun_family = pcb->ki_family;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pcb->ki_inode = unp->unp_ino;
|
|
|
|
pcb->ki_vnode = PTRTOUINT64(unp->unp_vnode);
|
|
|
|
pcb->ki_conn = PTRTOUINT64(unp->unp_conn);
|
|
|
|
pcb->ki_refs = PTRTOUINT64(unp->unp_refs);
|
|
|
|
pcb->ki_nextref = PTRTOUINT64(unp->unp_nextref);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
sysctl_unpcblist(SYSCTLFN_ARGS)
|
|
|
|
{
|
|
|
|
struct file *fp;
|
|
|
|
struct socket *so;
|
|
|
|
struct kinfo_pcb pcb;
|
|
|
|
char *dp;
|
|
|
|
u_int op, arg;
|
|
|
|
size_t len, needed, elem_size, out_size;
|
|
|
|
int error, elem_count, pf, type, pf2;
|
|
|
|
|
|
|
|
if (namelen == 1 && name[0] == CTL_QUERY)
|
2005-06-09 06:19:59 +04:00
|
|
|
return (sysctl_query(SYSCTLFN_CALL(rnode)));
|
2005-03-09 08:07:19 +03:00
|
|
|
|
|
|
|
if (namelen != 4)
|
|
|
|
return (EINVAL);
|
|
|
|
|
2006-04-15 08:41:52 +04:00
|
|
|
if (oldp != NULL) {
|
|
|
|
len = *oldlenp;
|
|
|
|
elem_size = name[2];
|
|
|
|
elem_count = name[3];
|
|
|
|
if (elem_size != sizeof(pcb))
|
|
|
|
return EINVAL;
|
|
|
|
} else {
|
|
|
|
len = 0;
|
|
|
|
elem_size = sizeof(pcb);
|
|
|
|
elem_count = INT_MAX;
|
|
|
|
}
|
2005-03-09 08:07:19 +03:00
|
|
|
error = 0;
|
|
|
|
dp = oldp;
|
|
|
|
op = name[0];
|
|
|
|
arg = name[1];
|
2006-04-15 08:41:52 +04:00
|
|
|
out_size = elem_size;
|
2005-03-09 08:07:19 +03:00
|
|
|
needed = 0;
|
|
|
|
|
|
|
|
if (name - oname != 4)
|
|
|
|
return (EINVAL);
|
|
|
|
|
|
|
|
pf = oname[1];
|
|
|
|
type = oname[2];
|
|
|
|
pf2 = (oldp == NULL) ? 0 : pf;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* there's no "list" of local domain sockets, so we have
|
|
|
|
* to walk the file list looking for them. :-/
|
|
|
|
*/
|
|
|
|
LIST_FOREACH(fp, &filehead, f_list) {
|
2006-06-13 17:52:39 +04:00
|
|
|
if (CURTAIN(kauth_cred_geteuid(l->l_proc->p_cred),
|
|
|
|
kauth_cred_geteuid(fp->f_cred)))
|
2005-09-07 21:38:44 +04:00
|
|
|
continue;
|
2005-03-09 08:07:19 +03:00
|
|
|
if (fp->f_type != DTYPE_SOCKET)
|
|
|
|
continue;
|
|
|
|
so = (struct socket *)fp->f_data;
|
|
|
|
if (so->so_type != type)
|
|
|
|
continue;
|
|
|
|
if (so->so_proto->pr_domain->dom_family != pf)
|
|
|
|
continue;
|
|
|
|
if (len >= elem_size && elem_count > 0) {
|
|
|
|
sysctl_dounpcb(&pcb, so);
|
|
|
|
error = copyout(&pcb, dp, out_size);
|
|
|
|
if (error)
|
|
|
|
break;
|
|
|
|
dp += elem_size;
|
|
|
|
len -= elem_size;
|
|
|
|
}
|
|
|
|
if (elem_count > 0) {
|
|
|
|
needed += elem_size;
|
|
|
|
if (elem_count != INT_MAX)
|
|
|
|
elem_count--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*oldlenp = needed;
|
|
|
|
if (oldp == NULL)
|
|
|
|
*oldlenp += PCB_SLOP * sizeof(struct kinfo_pcb);
|
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
Dynamic sysctl.
Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.
Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.
All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.
PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
2003-12-04 22:38:21 +03:00
|
|
|
SYSCTL_SETUP(sysctl_net_setup, "sysctl net subtree setup")
|
1994-05-07 04:46:28 +04:00
|
|
|
{
|
2004-03-24 18:34:46 +03:00
|
|
|
sysctl_createv(clog, 0, NULL, NULL,
|
|
|
|
CTLFLAG_PERMANENT,
|
Dynamic sysctl.
Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.
Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.
All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.
PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
2003-12-04 22:38:21 +03:00
|
|
|
CTLTYPE_NODE, "net", NULL,
|
|
|
|
NULL, 0, NULL, 0,
|
|
|
|
CTL_NET, CTL_EOL);
|
2004-03-24 18:34:46 +03:00
|
|
|
sysctl_createv(clog, 0, NULL, NULL,
|
|
|
|
CTLFLAG_PERMANENT,
|
2004-05-25 08:33:59 +04:00
|
|
|
CTLTYPE_NODE, "local",
|
|
|
|
SYSCTL_DESCR("PF_LOCAL related settings"),
|
Dynamic sysctl.
Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.
Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.
All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.
PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
2003-12-04 22:38:21 +03:00
|
|
|
NULL, 0, NULL, 0,
|
|
|
|
CTL_NET, PF_LOCAL, CTL_EOL);
|
2005-03-09 08:07:19 +03:00
|
|
|
sysctl_createv(clog, 0, NULL, NULL,
|
|
|
|
CTLFLAG_PERMANENT,
|
|
|
|
CTLTYPE_NODE, "stream",
|
|
|
|
SYSCTL_DESCR("SOCK_STREAM settings"),
|
|
|
|
NULL, 0, NULL, 0,
|
|
|
|
CTL_NET, PF_LOCAL, SOCK_STREAM, CTL_EOL);
|
|
|
|
sysctl_createv(clog, 0, NULL, NULL,
|
|
|
|
CTLFLAG_PERMANENT,
|
|
|
|
CTLTYPE_NODE, "dgram",
|
|
|
|
SYSCTL_DESCR("SOCK_DGRAM settings"),
|
|
|
|
NULL, 0, NULL, 0,
|
|
|
|
CTL_NET, PF_LOCAL, SOCK_DGRAM, CTL_EOL);
|
1994-05-07 04:46:28 +04:00
|
|
|
|
2005-03-09 08:07:19 +03:00
|
|
|
sysctl_createv(clog, 0, NULL, NULL,
|
|
|
|
CTLFLAG_PERMANENT,
|
|
|
|
CTLTYPE_STRUCT, "pcblist",
|
|
|
|
SYSCTL_DESCR("SOCK_STREAM protocol control block list"),
|
|
|
|
sysctl_unpcblist, 0, NULL, 0,
|
|
|
|
CTL_NET, PF_LOCAL, SOCK_STREAM, CTL_CREATE, CTL_EOL);
|
|
|
|
sysctl_createv(clog, 0, NULL, NULL,
|
|
|
|
CTLFLAG_PERMANENT,
|
|
|
|
CTLTYPE_STRUCT, "pcblist",
|
|
|
|
SYSCTL_DESCR("SOCK_DGRAM protocol control block list"),
|
|
|
|
sysctl_unpcblist, 0, NULL, 0,
|
|
|
|
CTL_NET, PF_LOCAL, SOCK_DGRAM, CTL_CREATE, CTL_EOL);
|
1994-05-07 04:46:28 +04:00
|
|
|
}
|
|
|
|
|
1993-06-27 10:01:27 +04:00
|
|
|
void
|
2005-01-23 21:41:56 +03:00
|
|
|
pfctlinput(int cmd, struct sockaddr *sa)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
2000-03-30 13:27:11 +04:00
|
|
|
struct domain *dp;
|
2004-04-22 05:01:40 +04:00
|
|
|
const struct protosw *pr;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
2005-01-23 21:41:56 +03:00
|
|
|
DOMAIN_FOREACH(dp)
|
1993-03-21 12:45:37 +03:00
|
|
|
for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
|
|
|
|
if (pr->pr_ctlinput)
|
1996-02-04 05:17:43 +03:00
|
|
|
(*pr->pr_ctlinput)(cmd, sa, NULL);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
2001-02-11 09:38:45 +03:00
|
|
|
void
|
2005-01-23 21:41:56 +03:00
|
|
|
pfctlinput2(int cmd, struct sockaddr *sa, void *ctlparam)
|
2001-02-11 09:38:45 +03:00
|
|
|
{
|
|
|
|
struct domain *dp;
|
2004-04-22 05:01:40 +04:00
|
|
|
const struct protosw *pr;
|
2001-02-11 09:38:45 +03:00
|
|
|
|
|
|
|
if (!sa)
|
|
|
|
return;
|
2005-01-23 21:41:56 +03:00
|
|
|
|
|
|
|
DOMAIN_FOREACH(dp) {
|
2001-02-11 09:38:45 +03:00
|
|
|
/*
|
|
|
|
* the check must be made by xx_ctlinput() anyways, to
|
|
|
|
* make sure we use data item pointed to by ctlparam in
|
|
|
|
* correct way. the following check is made just for safety.
|
|
|
|
*/
|
|
|
|
if (dp->dom_family != sa->sa_family)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
|
|
|
|
if (pr->pr_ctlinput)
|
|
|
|
(*pr->pr_ctlinput)(cmd, sa, ctlparam);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1993-06-27 10:01:27 +04:00
|
|
|
void
|
2005-01-23 21:41:56 +03:00
|
|
|
pfslowtimo(void *arg)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
2000-03-30 13:27:11 +04:00
|
|
|
struct domain *dp;
|
2004-04-22 05:01:40 +04:00
|
|
|
const struct protosw *pr;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1998-05-06 05:11:46 +04:00
|
|
|
pfslowtimo_now++;
|
|
|
|
|
2005-01-23 21:41:56 +03:00
|
|
|
DOMAIN_FOREACH(dp) {
|
1993-03-21 12:45:37 +03:00
|
|
|
for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
|
|
|
|
if (pr->pr_slowtimo)
|
|
|
|
(*pr->pr_slowtimo)();
|
2005-01-23 21:41:56 +03:00
|
|
|
}
|
2000-03-23 09:30:07 +03:00
|
|
|
callout_reset(&pfslowtimo_ch, hz / 2, pfslowtimo, NULL);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1993-06-27 10:01:27 +04:00
|
|
|
void
|
2005-01-23 21:41:56 +03:00
|
|
|
pffasttimo(void *arg)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
2000-03-30 13:27:11 +04:00
|
|
|
struct domain *dp;
|
2004-04-22 05:01:40 +04:00
|
|
|
const struct protosw *pr;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1998-05-06 05:11:46 +04:00
|
|
|
pffasttimo_now++;
|
|
|
|
|
2005-01-23 21:41:56 +03:00
|
|
|
DOMAIN_FOREACH(dp) {
|
1993-03-21 12:45:37 +03:00
|
|
|
for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
|
|
|
|
if (pr->pr_fasttimo)
|
|
|
|
(*pr->pr_fasttimo)();
|
2005-01-23 21:41:56 +03:00
|
|
|
}
|
2000-03-23 09:30:07 +03:00
|
|
|
callout_reset(&pffasttimo_ch, hz / 5, pffasttimo, NULL);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|