summaryrefslogtreecommitdiffstats
path: root/sys/kern/uipc_domain.c
diff options
context:
space:
mode:
authorjulian <julian@FreeBSD.org>1999-01-21 00:26:41 +0000
committerjulian <julian@FreeBSD.org>1999-01-21 00:26:41 +0000
commit85161a4534d35591d51d6a88b7e972dbdff49b09 (patch)
tree2319c3f52e829605d58e52bfd6ca95044077014c /sys/kern/uipc_domain.c
parent02f3c0dfeecb4e76bf41acc87322cfae6616ab19 (diff)
downloadFreeBSD-src-85161a4534d35591d51d6a88b7e972dbdff49b09.zip
FreeBSD-src-85161a4534d35591d51d6a88b7e972dbdff49b09.tar.gz
Minor rearranging of code to allow simple protocol domains to be
added as KLDs.
Diffstat (limited to 'sys/kern/uipc_domain.c')
-rw-r--r--sys/kern/uipc_domain.c95
1 files changed, 69 insertions, 26 deletions
diff --git a/sys/kern/uipc_domain.c b/sys/kern/uipc_domain.c
index 22078b1..929da87 100644
--- a/sys/kern/uipc_domain.c
+++ b/sys/kern/uipc_domain.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)uipc_domain.c 8.2 (Berkeley) 10/18/93
- * $Id: uipc_domain.c,v 1.18 1997/09/16 11:43:36 bde Exp $
+ * $Id: uipc_domain.c,v 1.19 1998/05/15 20:11:29 wollman Exp $
*/
#include <sys/param.h>
@@ -52,7 +52,7 @@
* want to call a registration function rather than being handled here
* in domaininit(). Probably this will look like:
*
- * SYSINIT(unique, SI_SUB_PROTO_DOMAI, SI_ORDER_ANY, domain_add, xxx)
+ * SYSINIT(unique, SI_SUB_PROTO_DOMAIN, SI_ORDER_ANY, domain_add, xxx)
*
* Where 'xxx' is replaced by the address of a parameter struct to be
* passed to the doamin_add() function.
@@ -71,21 +71,64 @@ static void pfslowtimo __P((void *));
struct domain *domains;
-#define ADDDOMAIN(x) { \
- __CONCAT(x,domain.dom_next) = domains; \
- domains = &__CONCAT(x,domain); \
+/*
+ * Add a new protocol domain to the list of supported domains
+ * Note: you cant unload it again because a socket may be using it.
+ * XXX can't fail at this time.
+ */
+static int
+net_init_domain(struct domain *dp)
+{
+ register struct protosw *pr;
+ int s;
+
+ s = splnet();
+ if (dp->dom_init)
+ (*dp->dom_init)();
+ for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++){
+ if (pr->pr_usrreqs == 0)
+ panic("domaininit: %ssw[%d] has no usrreqs!",
+ dp->dom_name,
+ (int)(pr - dp->dom_protosw));
+ if (pr->pr_init)
+ (*pr->pr_init)();
+ }
+ /*
+ * update global informatio about maximums
+ */
+ max_hdr = max_linkhdr + max_protohdr;
+ max_datalen = MHLEN - max_hdr;
+ splx(s);
+ return (0);
+}
+
+/*
+ * Add a new protocol domain to the list of supported domains
+ * Note: you cant unload it again because a socket may be using it.
+ * XXX can't fail at this time.
+ */
+int
+net_add_domain(struct domain *dp)
+{
+ int s, error;
+
+ s = splnet();
+ dp->dom_next = domains;
+ domains = dp;
+ splx(s);
+ error = net_init_domain(dp);
+ max_hdr = max_linkhdr + max_protohdr;
+ max_datalen = MHLEN - max_hdr;
+ return (error);
}
extern struct linker_set domain_set;
/* ARGSUSED*/
static void
-domaininit(dummy)
- void *dummy;
+domaininit(void *dummy)
{
register struct domain *dp, **dpp;
- register struct protosw *pr;
-
/*
* Before we do any setup, make sure to initialize the
* zone allocator we get struct sockets from. The obvious
@@ -101,33 +144,33 @@ domaininit(dummy)
socket_zone = zinit("socket", sizeof(struct socket), maxsockets,
ZONE_INTERRUPT, 0);
+ if (max_linkhdr < 16) /* XXX */
+ max_linkhdr = 16;
+
/*
* NB - local domain is always present.
*/
- ADDDOMAIN(local);
+ net_add_domain(&localdomain);
+ /*
+ * gather up as many protocols as we have statically linked.
+ * XXX we need to do this because when we ask the routing
+ * protocol to initialise it will want to examine all
+ * installed protocols. This needs fixing before protocols
+ * that use the standard routing can become modules.
+ */
for (dpp = (struct domain **)domain_set.ls_items; *dpp; dpp++) {
(**dpp).dom_next = domains;
domains = *dpp;
}
- for (dp = domains; dp; dp = dp->dom_next) {
- if (dp->dom_init)
- (*dp->dom_init)();
- for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++){
- if (pr->pr_usrreqs == 0)
- panic("domaininit: %ssw[%d] has no usrreqs!",
- dp->dom_name,
- (int)(pr - dp->dom_protosw));
- if (pr->pr_init)
- (*pr->pr_init)();
- }
- }
+ /*
+ * Now ask them all to init (XXX including the routing domain,
+ * see above)
+ */
+ for (dp = domains; dp; dp = dp->dom_next)
+ net_init_domain(dp);
- if (max_linkhdr < 16) /* XXX */
- max_linkhdr = 16;
- max_hdr = max_linkhdr + max_protohdr;
- max_datalen = MHLEN - max_hdr;
timeout(pffasttimo, (void *)0, 1);
timeout(pfslowtimo, (void *)0, 1);
}
OpenPOWER on IntegriCloud