diff options
| author | ad <ad@NetBSD.org> | 2008-11-12 12:35:50 +0000 |
|---|---|---|
| committer | ad <ad@NetBSD.org> | 2008-11-12 12:35:50 +0000 |
| commit | 0efea177e37295fed654875d875160c47500d6bd (patch) | |
| tree | 9d0589344a5d07b9a511a2e81ebbd701744d03b5 /sys/netinet | |
| parent | 0f81d3e0a26c2833cd085c472a4a77c325486b75 (diff) | |
Remove LKMs and switch to the module framework, pass 1.
Proposed on tech-kern@.
Diffstat (limited to 'sys/netinet')
| -rw-r--r-- | sys/netinet/accf_data.c | 52 | ||||
| -rw-r--r-- | sys/netinet/accf_http.c | 84 | ||||
| -rw-r--r-- | sys/netinet/ip_ecn.h | 4 |
3 files changed, 65 insertions, 75 deletions
diff --git a/sys/netinet/accf_data.c b/sys/netinet/accf_data.c index b435c5397f8..aebad5bcabb 100644 --- a/sys/netinet/accf_data.c +++ b/sys/netinet/accf_data.c @@ -1,4 +1,4 @@ -/* $NetBSD: accf_data.c,v 1.2 2008/10/14 13:05:44 ad Exp $ */ +/* $NetBSD: accf_data.c,v 1.3 2008/11/12 12:36:28 ad Exp $ */ /*- * Copyright (c) 2000 Alfred Perlstein <alfred@FreeBSD.org> @@ -27,19 +27,21 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: accf_data.c,v 1.2 2008/10/14 13:05:44 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: accf_data.c,v 1.3 2008/11/12 12:36:28 ad Exp $"); #define ACCEPT_FILTER_MOD #include <sys/param.h> #include <sys/kernel.h> -#include <sys/lkm.h> +#include <sys/module.h> #include <sys/sysctl.h> #include <sys/signalvar.h> #include <sys/socketvar.h> #include <netinet/accept_filter.h> +MODULE(MODULE_CLASS_MISC, accf_data, NULL); + /* accept filter that holds a socket until data arrives */ static void sohasdata(struct socket *so, void *arg, int waitflag); @@ -49,40 +51,30 @@ static struct accept_filter accf_data_filter = { .accf_callback = sohasdata, }; -void accf_dataattach(int); -void accf_dataattach(int num) +/* XXX pseudo-device */ +void accf_dataattach(int); + +void +accf_dataattach(int junk) { - accept_filt_generic_mod_event(NULL, LKM_E_LOAD, &accf_data_filter); -} -/* - * This code is to make DATA ready accept filer as LKM. - * To compile as LKM we need to move this set of code into - * another file and include this file for compilation when - * making LKM - */ +} -#ifdef _LKM -static int accf_data_handle(struct lkm_table * lkmtp, int cmd); -int accf_data_lkmentry(struct lkm_table * lkmtp, int cmd, int ver); +static int +accf_data_modcmd(modcmd_t cmd, void *arg) +{ -MOD_MISC("accf_data"); + switch (cmd) { + case MODULE_CMD_INIT: + return accept_filt_add(&accf_data_filter); -static int accf_data_handle(struct lkm_table * lkmtp, int cmd) -{ - return accept_filt_generic_mod_event(lkmtp, cmd, &accf_data_filter); -} + case MODULE_CMD_FINI: + return accept_filt_del(&accf_data_filter); -/* - * the module entry point. - */ -int -accf_data_lkmentry(struct lkm_table *lkmtp, int cmd, int ver) -{ - DISPATCH(lkmtp, cmd, ver, accf_data_handle, accf_data_handle, - accf_data_handle) + default: + return ENOTTY; + } } -#endif static void sohasdata(struct socket *so, void *arg, int waitflag) diff --git a/sys/netinet/accf_http.c b/sys/netinet/accf_http.c index b61bf9eb7cc..86efbbb9f79 100644 --- a/sys/netinet/accf_http.c +++ b/sys/netinet/accf_http.c @@ -1,4 +1,4 @@ -/* $NetBSD: accf_http.c,v 1.2 2008/10/14 13:05:44 ad Exp $ */ +/* $NetBSD: accf_http.c,v 1.3 2008/11/12 12:36:28 ad Exp $ */ /*- * Copyright (c) 2000 Paycounter, Inc. @@ -28,14 +28,14 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: accf_http.c,v 1.2 2008/10/14 13:05:44 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: accf_http.c,v 1.3 2008/11/12 12:36:28 ad Exp $"); #define ACCEPT_FILTER_MOD #include <sys/param.h> #include <sys/kernel.h> #include <sys/mbuf.h> -#include <sys/lkm.h> +#include <sys/module.h> #include <sys/signalvar.h> #include <sys/sysctl.h> #include <sys/socket.h> @@ -43,6 +43,8 @@ __KERNEL_RCSID(0, "$NetBSD: accf_http.c,v 1.2 2008/10/14 13:05:44 ad Exp $"); #include <netinet/accept_filter.h> +MODULE(MODULE_CLASS_MISC, accf_http, NULL); + /* check for GET/HEAD */ static void sohashttpget(struct socket *so, void *arg, int waitflag); /* check for HTTP/1.0 or HTTP/1.1 */ @@ -70,30 +72,49 @@ static struct accept_filter accf_http_filter = { static int parse_http_version = 1; -SYSCTL_SETUP(sysctl_net_inet_accf__http_setup, "sysctl net.inet.accf.http subtree setup") +/* XXX pseudo-device */ +void accf_httpattach(int); + +void +accf_httpattach(int junk) +{ + +} + +static int +accf_http_modcmd(modcmd_t cmd, void *arg) { - sysctl_createv(clog, 0, NULL, NULL, + static struct sysctllog *clog; + int error; + + switch (cmd) { + case MODULE_CMD_INIT: + error = accept_filt_add(&accf_http_filter); + if (error != 0) { + return error; + } + sysctl_createv(&clog, 0, NULL, NULL, CTLFLAG_PERMANENT, CTLTYPE_NODE, "net", NULL, NULL, 0, NULL, 0, CTL_NET, CTL_EOL); - sysctl_createv(clog, 0, NULL, NULL, + sysctl_createv(&clog, 0, NULL, NULL, CTLFLAG_PERMANENT, CTLTYPE_NODE, "inet", NULL, NULL, 0, NULL, 0, CTL_NET, PF_INET, CTL_EOL); - sysctl_createv(clog, 0, NULL, NULL, + sysctl_createv(&clog, 0, NULL, NULL, CTLFLAG_PERMANENT, CTLTYPE_NODE, "accf", NULL, NULL, 0, NULL, 0, CTL_NET, PF_INET, SO_ACCEPTFILTER, CTL_EOL); - sysctl_createv(clog, 0, NULL, NULL, + sysctl_createv(&clog, 0, NULL, NULL, CTLFLAG_PERMANENT, CTLTYPE_NODE, "http", SYSCTL_DESCR("HTTP accept filter"), NULL, 0, NULL, 0, CTL_NET, PF_INET, SO_ACCEPTFILTER, ACCF_HTTP, CTL_EOL); - sysctl_createv(clog, 0, NULL, NULL, + sysctl_createv(&clog, 0, NULL, NULL, CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT, "parsehttpversion", SYSCTL_DESCR("Parse http version so that non " @@ -101,43 +122,20 @@ SYSCTL_SETUP(sysctl_net_inet_accf__http_setup, "sysctl net.inet.accf.http subtre NULL, 0, &parse_http_version, 0, CTL_NET, PF_INET, SO_ACCEPTFILTER, ACCF_HTTP, ACCFCTL_PARSEVER, CTL_EOL); -} - -void accf_httpattach(int); -void accf_httpattach(int num) -{ - accept_filt_generic_mod_event(NULL, LKM_E_LOAD, &accf_http_filter); -} - -/* - * This code is to make HTTP ready accept filer as LKM. - * To compile as LKM we need to move this set of code into - * another file and include this file for compilation when - * making LKM - */ - -#ifdef _LKM -static int accf_http_handle(struct lkm_table * lkmtp, int cmd); -int accf_http_lkmentry(struct lkm_table * lkmtp, int cmd, int ver); - -MOD_MISC("accf_http"); + return 0; -static int accf_http_handle(struct lkm_table * lkmtp, int cmd) -{ - - return accept_filt_generic_mod_event(lkmtp, cmd, &accf_http_filter); -} + case MODULE_CMD_FINI: + error = accept_filt_del(&accf_http_filter); + if (error != 0) { + return error; + } + sysctl_teardown(&clog); + return 0; -/* - * the module entry point. - */ -int -accf_http_lkmentry(struct lkm_table *lkmtp, int cmd, int ver) -{ - DISPATCH(lkmtp, cmd, ver, accf_http_handle, accf_http_handle, - accf_http_handle) + default: + return ENOTTY; + } } -#endif #ifdef ACCF_HTTP_DEBUG #define DPRINT(fmt, args...) \ diff --git a/sys/netinet/ip_ecn.h b/sys/netinet/ip_ecn.h index 63bccc2e347..a9612efa55a 100644 --- a/sys/netinet/ip_ecn.h +++ b/sys/netinet/ip_ecn.h @@ -1,4 +1,4 @@ -/* $NetBSD: ip_ecn.h,v 1.11 2005/12/10 23:36:23 elad Exp $ */ +/* $NetBSD: ip_ecn.h,v 1.12 2008/11/12 12:36:28 ad Exp $ */ /* $KAME: ip_ecn.h,v 1.6 2001/05/03 14:51:48 itojun Exp $ */ /* @@ -39,7 +39,7 @@ #define _NETINET_IP_ECN_H_ #if (defined(__FreeBSD__) && __FreeBSD__ >= 3) || defined(__NetBSD__) -#if defined(_KERNEL) && !defined(_LKM) +#if defined(_KERNEL_OPT) #include "opt_inet.h" #endif #endif |
