tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Modularizing net80211 (was: link_set info needed)
Folks,
I would like to commit the attached patches to modularize the net80211
code. The changes include:
1. Protecting the inclusion of "opt_inet.h" with #ifdef _KERNEL
2. Removing CTLFLAG_PERMANENT from all of the sysctl(8) variables
3. Replacing the use of link_set with direct calls to all of the
crypto/auth initializers.
At a future time, I propose to split the crypto/auth stuff out into
their own modules, but that will require a bit more planning and a lot
more testing. :)
I have tested the attached changes on my home system, using a modular
if_rum(4) driver (which I plan to commit separately).
Comments/feedback welcomed...
-------------------------------------------------------------------------
| Paul Goyette | PGP Key fingerprint: | E-mail addresses: |
| Customer Service | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com |
| Network Engineer | 0786 F758 55DE 53BA 7731 | pgoyette at juniper.net |
| Kernel Developer | | pgoyette at netbsd.org |
-------------------------------------------------------------------------
Index: ieee80211.c
===================================================================
RCS file: /cvsroot/src/sys/net80211/ieee80211.c,v
retrieving revision 1.53
diff -u -p -r1.53 ieee80211.c
--- ieee80211.c 5 Apr 2010 07:22:24 -0000 1.53
+++ ieee80211.c 27 Apr 2012 12:34:49 -0000
@@ -43,7 +43,9 @@ __KERNEL_RCSID(0, "$NetBSD: ieee80211.c,
* IEEE 802.11 generic handler
*/
+#if defined(_KERNEL_OPT)
#include "opt_inet.h"
+#endif
#include <sys/param.h>
#include <sys/systm.h>
Index: ieee80211_crypto.c
===================================================================
RCS file: /cvsroot/src/sys/net80211/ieee80211_crypto.c,v
retrieving revision 1.15
diff -u -p -r1.15 ieee80211_crypto.c
--- ieee80211_crypto.c 23 May 2011 15:37:36 -0000 1.15
+++ ieee80211_crypto.c 27 Apr 2012 12:34:49 -0000
@@ -39,7 +39,9 @@ __FBSDID("$FreeBSD: src/sys/net80211/iee
__KERNEL_RCSID(0, "$NetBSD: ieee80211_crypto.c,v 1.15 2011/05/23 15:37:36
drochner Exp $");
#endif
+#if defined(_KERNEL_OPT)
#include "opt_inet.h"
+#endif
/*
* IEEE 802.11 generic crypto support.
Index: ieee80211_input.c
===================================================================
RCS file: /cvsroot/src/sys/net80211/ieee80211_input.c,v
retrieving revision 1.72
diff -u -p -r1.72 ieee80211_input.c
--- ieee80211_input.c 31 Dec 2011 20:41:58 -0000 1.72
+++ ieee80211_input.c 27 Apr 2012 12:34:49 -0000
@@ -39,7 +39,9 @@ __FBSDID("$FreeBSD: src/sys/net80211/iee
__KERNEL_RCSID(0, "$NetBSD: ieee80211_input.c,v 1.72 2011/12/31 20:41:58
christos Exp $");
#endif
+#if defined(_KERNEL_OPT)
#include "opt_inet.h"
+#endif
#ifdef __NetBSD__
#endif /* __NetBSD__ */
Index: ieee80211_ioctl.c
===================================================================
RCS file: /cvsroot/src/sys/net80211/ieee80211_ioctl.c,v
retrieving revision 1.57
diff -u -p -r1.57 ieee80211_ioctl.c
--- ieee80211_ioctl.c 31 Dec 2011 20:41:58 -0000 1.57
+++ ieee80211_ioctl.c 27 Apr 2012 12:34:50 -0000
@@ -43,8 +43,10 @@ __KERNEL_RCSID(0, "$NetBSD: ieee80211_io
* IEEE 802.11 ioctl support (FreeBSD-specific)
*/
+#if defined(_KERNEL_OPT)
#include "opt_inet.h"
#include "opt_compat_netbsd.h"
+#endif
#include <sys/endian.h>
#include <sys/param.h>
Index: ieee80211_netbsd.c
===================================================================
RCS file: /cvsroot/src/sys/net80211/ieee80211_netbsd.c,v
retrieving revision 1.20
diff -u -p -r1.20 ieee80211_netbsd.c
--- ieee80211_netbsd.c 19 Nov 2011 22:51:25 -0000 1.20
+++ ieee80211_netbsd.c 27 Apr 2012 12:34:50 -0000
@@ -40,6 +40,7 @@ __KERNEL_RCSID(0, "$NetBSD: ieee80211_ne
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/mbuf.h>
+#include <sys/module.h>
#include <sys/proc.h>
#include <sys/sysctl.h>
#include <sys/once.h>
@@ -72,6 +73,8 @@ static int ieee80211_sysctl_node(SYSCTLF
int ieee80211_debug = 0;
#endif
+#ifdef NOTYET /* Currently we can't use link sets in modules */
+
typedef void (*ieee80211_setup_func)(void);
__link_set_decl(ieee80211_funcs, ieee80211_setup_func);
@@ -81,7 +84,7 @@ ieee80211_init0(void)
{
ieee80211_setup_func * const *ieee80211_setup, f;
- __link_set_foreach(ieee80211_setup, ieee80211_funcs) {
+ __link_set_foreach(ieee80211_setup, ieee80211_funcs) {
f = (void*)*ieee80211_setup;
(*f)();
}
@@ -96,6 +99,29 @@ ieee80211_init(void)
RUN_ONCE(&ieee80211_init_once, ieee80211_init0);
}
+#else
+/*
+ * One-time initialization
+ *
+ * XXX Make sure you update the list of CYPTO initializers if new
+ * XXX mechanisms are added!
+ */
+
+void ccmp_register(void);
+void tkip_register(void);
+void wep_register(void);
+void ieee80211_external_auth_setup(void);
+
+void
+ieee80211_init(void)
+{
+
+ ccmp_register();
+ tkip_register();
+ wep_register();
+ ieee80211_external_auth_setup();
+}
+#endif /* NOT_YET */
static int
ieee80211_sysctl_inact(SYSCTLFN_ARGS)
@@ -146,18 +172,18 @@ ieee80211_sysctl_treetop(struct sysctllo
const struct sysctlnode *rnode;
if ((rc = sysctl_createv(log, 0, NULL, &rnode,
- CTLFLAG_PERMANENT, CTLTYPE_NODE, "net", NULL,
+ 0, CTLTYPE_NODE, "net", NULL,
NULL, 0, NULL, 0, CTL_NET, CTL_EOL)) != 0)
goto err;
if ((rc = sysctl_createv(log, 0, &rnode, &rnode,
- CTLFLAG_PERMANENT, CTLTYPE_NODE, "link",
+ 0, CTLTYPE_NODE, "link",
"link-layer statistics and controls",
NULL, 0, NULL, 0, PF_LINK, CTL_EOL)) != 0)
goto err;
if ((rc = sysctl_createv(log, 0, &rnode, &rnode,
- CTLFLAG_PERMANENT, CTLTYPE_NODE, "ieee80211",
+ 0, CTLTYPE_NODE, "ieee80211",
"IEEE 802.11 WLAN statistics and controls",
NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL)) != 0)
goto err;
@@ -181,13 +207,13 @@ ieee80211_sysctl_attach(struct ieee80211
snprintf(num, sizeof(num), "vap%u", ic->ic_vap);
if ((rc = sysctl_createv(&ic->ic_sysctllog, 0, &rnode, &rnode,
- CTLFLAG_PERMANENT, CTLTYPE_NODE, num, SYSCTL_DESCR("virtual AP"),
+ 0, CTLTYPE_NODE, num, SYSCTL_DESCR("virtual AP"),
NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL)) != 0)
goto err;
/* control debugging printfs */
if ((rc = sysctl_createv(&ic->ic_sysctllog, 0, &rnode, &cnode,
- CTLFLAG_PERMANENT|CTLFLAG_READONLY, CTLTYPE_STRING,
+ CTLFLAG_READONLY, CTLTYPE_STRING,
"parent", SYSCTL_DESCR("parent device"),
ieee80211_sysctl_parent, 0, ic, IFNAMSIZ, CTL_CREATE,
CTL_EOL)) != 0)
@@ -196,7 +222,7 @@ ieee80211_sysctl_attach(struct ieee80211
#ifdef IEEE80211_DEBUG
/* control debugging printfs */
if ((rc = sysctl_createv(&ic->ic_sysctllog, 0, &rnode, &cnode,
- CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT,
+ CTLFLAG_READWRITE, CTLTYPE_INT,
"debug", SYSCTL_DESCR("control debugging printfs"),
NULL, ieee80211_debug, &ic->ic_debug, 0,
CTL_CREATE, CTL_EOL)) != 0)
@@ -204,39 +230,39 @@ ieee80211_sysctl_attach(struct ieee80211
#endif
/* XXX inherit from tunables */
if ((rc = sysctl_createv(&ic->ic_sysctllog, 0, &rnode, &cnode,
- CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT,
+ CTLFLAG_READWRITE, CTLTYPE_INT,
"inact_run", SYSCTL_DESCR("station inactivity timeout (sec)"),
ieee80211_sysctl_inact, 0, &ic->ic_inact_run, 0,
CTL_CREATE, CTL_EOL)) != 0)
goto err;
if ((rc = sysctl_createv(&ic->ic_sysctllog, 0, &rnode, &cnode,
- CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT,
+ CTLFLAG_READWRITE, CTLTYPE_INT,
"inact_probe",
SYSCTL_DESCR("station inactivity probe timeout (sec)"),
ieee80211_sysctl_inact, 0, &ic->ic_inact_probe, 0,
CTL_CREATE, CTL_EOL)) != 0)
goto err;
if ((rc = sysctl_createv(&ic->ic_sysctllog, 0, &rnode, &cnode,
- CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT,
+ CTLFLAG_READWRITE, CTLTYPE_INT,
"inact_auth",
SYSCTL_DESCR("station authentication timeout (sec)"),
ieee80211_sysctl_inact, 0, &ic->ic_inact_auth, 0,
CTL_CREATE, CTL_EOL)) != 0)
goto err;
if ((rc = sysctl_createv(&ic->ic_sysctllog, 0, &rnode, &cnode,
- CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT,
+ CTLFLAG_READWRITE, CTLTYPE_INT,
"inact_init",
SYSCTL_DESCR("station initial state timeout (sec)"),
ieee80211_sysctl_inact, 0, &ic->ic_inact_init, 0,
CTL_CREATE, CTL_EOL)) != 0)
goto err;
if ((rc = sysctl_createv(&ic->ic_sysctllog, 0, &rnode, &cnode,
- CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT,
+ CTLFLAG_READWRITE, CTLTYPE_INT,
"driver_caps", SYSCTL_DESCR("driver capabilities"),
NULL, 0, &ic->ic_caps, 0, CTL_CREATE, CTL_EOL)) != 0)
goto err;
if ((rc = sysctl_createv(&ic->ic_sysctllog, 0, &rnode, &cnode,
- CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT,
+ CTLFLAG_READWRITE, CTLTYPE_INT,
"bmiss_max", SYSCTL_DESCR("consecutive beacon misses before
scanning"),
NULL, 0, &ic->ic_bmiss_max, 0, CTL_CREATE, CTL_EOL)) != 0)
goto err;
@@ -457,8 +483,6 @@ cleanup:
/*
* Setup sysctl(3) MIB, net.ieee80211.*
- *
- * TBD condition CTLFLAG_PERMANENT on being a module or not
*/
SYSCTL_SETUP(sysctl_ieee80211, "sysctl ieee80211 subtree setup")
{
@@ -469,14 +493,14 @@ SYSCTL_SETUP(sysctl_ieee80211, "sysctl i
return;
if ((rc = sysctl_createv(clog, 0, &rnode, NULL,
- CTLFLAG_PERMANENT, CTLTYPE_NODE, "nodes", "client/peer stations",
+ 0, CTLTYPE_NODE, "nodes", "client/peer stations",
ieee80211_sysctl_node, 0, NULL, 0, CTL_CREATE, CTL_EOL)) != 0)
goto err;
#ifdef IEEE80211_DEBUG
/* control debugging printfs */
if ((rc = sysctl_createv(clog, 0, &rnode, &cnode,
- CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT,
+ CTLFLAG_READWRITE, CTLTYPE_INT,
"debug", SYSCTL_DESCR("control debugging printfs"),
NULL, 0, &ieee80211_debug, 0, CTL_CREATE, CTL_EOL)) != 0)
goto err;
@@ -769,3 +793,24 @@ ieee80211_load_module(const char *modnam
printf("%s: load the %s module by hand for now.\n", __func__, modname);
#endif
}
+
+MODULE(MODULE_CLASS_MISC, net80211, NULL);
+
+static int
+net80211_modcmd(modcmd_t cmd, void *aux)
+{
+ int error = 0;
+ static struct sysctllog *clog;
+
+ switch (cmd) {
+ case MODULE_CMD_INIT:
+ ieee80211_init();
+ sysctl_ieee80211(&clog);
+ return error;
+ case MODULE_CMD_FINI:
+ sysctl_teardown(&clog);
+ return error;
+ default:
+ return ENOTTY;
+ }
+}
Index: ieee80211_netbsd.h
===================================================================
RCS file: /cvsroot/src/sys/net80211/ieee80211_netbsd.h,v
retrieving revision 1.17
diff -u -p -r1.17 ieee80211_netbsd.h
--- ieee80211_netbsd.h 31 Dec 2011 20:41:58 -0000 1.17
+++ ieee80211_netbsd.h 27 Apr 2012 12:34:50 -0000
@@ -243,10 +243,18 @@ void ieee80211_sysctl_detach(struct ieee
void ieee80211_load_module(const char *);
void ieee80211_init(void);
+
+#ifdef NOT_YET /* We currently cannot use link sets in modules */
#define IEEE80211_CRYPTO_SETUP(name) \
static void name(void); \
__link_set_add_text(ieee80211_funcs, name); \
static void name(void)
-#endif
+#else
+#define IEEE80211_CRYPTO_SETUP(name) \
+ void name(void); \
+ void name(void)
+#endif /* NOT_YET */
+
+#endif /* _KERNEL */
#endif /* !_NET80211_IEEE80211_NETBSD_H_ */
Index: ieee80211_node.c
===================================================================
RCS file: /cvsroot/src/sys/net80211/ieee80211_node.c,v
retrieving revision 1.63
diff -u -p -r1.63 ieee80211_node.c
--- ieee80211_node.c 3 Jan 2009 03:43:23 -0000 1.63
+++ ieee80211_node.c 27 Apr 2012 12:34:50 -0000
@@ -39,7 +39,9 @@ __FBSDID("$FreeBSD: src/sys/net80211/iee
__KERNEL_RCSID(0, "$NetBSD: ieee80211_node.c,v 1.63 2009/01/03 03:43:23 yamt
Exp $");
#endif
+#if defined(_KERNEL_OPT)
#include "opt_inet.h"
+#endif
#include <sys/param.h>
#include <sys/systm.h>
Index: ieee80211_output.c
===================================================================
RCS file: /cvsroot/src/sys/net80211/ieee80211_output.c,v
retrieving revision 1.51
diff -u -p -r1.51 ieee80211_output.c
--- ieee80211_output.c 31 Dec 2011 20:41:58 -0000 1.51
+++ ieee80211_output.c 27 Apr 2012 12:34:50 -0000
@@ -39,7 +39,9 @@ __FBSDID("$FreeBSD: src/sys/net80211/iee
__KERNEL_RCSID(0, "$NetBSD: ieee80211_output.c,v 1.51 2011/12/31 20:41:58
christos Exp $");
#endif
+#if defined(_KERNEL_OPT)
#include "opt_inet.h"
+#endif
#ifdef __NetBSD__
#endif /* __NetBSD__ */
Index: ieee80211_proto.c
===================================================================
RCS file: /cvsroot/src/sys/net80211/ieee80211_proto.c,v
retrieving revision 1.29
diff -u -p -r1.29 ieee80211_proto.c
--- ieee80211_proto.c 13 Jan 2008 13:01:12 -0000 1.29
+++ ieee80211_proto.c 27 Apr 2012 12:34:50 -0000
@@ -43,7 +43,9 @@ __KERNEL_RCSID(0, "$NetBSD: ieee80211_pr
* IEEE 802.11 protocol support.
*/
+#if defined(_KERNEL_OPT)
#include "opt_inet.h"
+#endif
#include <sys/param.h>
#include <sys/kernel.h>
Home |
Main Index |
Thread Index |
Old Index