Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src-draft/trunk]: src/sys/net80211 Rework sysctl setup, in preparation for d...



details:   https://anonhg.NetBSD.org/src-all/rev/9a7230221ade
branches:  trunk
changeset: 360874:9a7230221ade
user:      Martin Husemann <martin%NetBSD.org@localhost>
date:      Thu Jul 09 19:12:43 2020 +0200

description:
Rework sysctl setup, in preparation for dynamic VAP creation.

diffstat:

 sys/net80211/ieee80211_netbsd.c |  77 ++++++++++++----------------------------
 1 files changed, 23 insertions(+), 54 deletions(-)

diffs (139 lines):

diff -r 7a8592be7512 -r 9a7230221ade sys/net80211/ieee80211_netbsd.c
--- a/sys/net80211/ieee80211_netbsd.c   Mon Jul 06 20:06:00 2020 +0200
+++ b/sys/net80211/ieee80211_netbsd.c   Thu Jul 09 19:12:43 2020 +0200
@@ -64,10 +64,6 @@
 #include <net80211/ieee80211_var.h>
 #include <net80211/ieee80211_input.h>
 
-static const struct sysctlnode *
-    ieee80211_sysctl_treetop(struct sysctllog **log);
-static void ieee80211_sysctl_setup(void);
-
 /* NNN in .h file? */
 #define SYSCTL_HANDLER_ARGS SYSCTLFN_ARGS
 
@@ -85,7 +81,6 @@
 int
 ieee80211_init0(void)
 {
-       ieee80211_sysctl_setup();
        return 0;
 }
 
@@ -335,32 +330,36 @@
 }
 
 /*
- * Setup sysctl(3) MIB, net.ieee80211.*
- *
- * TBD condition CTLFLAG_PERMANENT on being a module or not
+ * Setup sysctl(3) MIB, net.wlan.*
  */
-static struct sysctllog *ieee80211_sysctllog;
-static void
-ieee80211_sysctl_setup(void)
+static int32_t ctl_wlan;
+
+SYSCTL_SETUP(sysctl_net_wlan_setup, "sysctl net.wlan subtree setup")
 {
-#ifdef IEEE80211_DEBUG
        int rc;
-#endif
-       const struct sysctlnode *rnode;
+       const struct sysctlnode *wlan_node;
 
-       if ((rnode = ieee80211_sysctl_treetop(&ieee80211_sysctllog)) == NULL)
+       if (sysctl_createv(clog, 0, NULL, &wlan_node,
+           CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_NODE,
+           "wlan", SYSCTL_DESCR("ieee802.11 operation controll"),
+           NULL, 0, NULL, 0,
+           CTL_NET, CTL_CREATE, CTL_EOL) != 0)
                return;
 
+       /* remember the (dynamic) MIB so we can find this node later */
+       ctl_wlan = wlan_node->sysctl_num;
+
 #ifdef notyet
-       if ((rc = sysctl_createv(&ieee80211_sysctllog, 0, &rnode, NULL,
-           CTLFLAG_PERMANENT, CTLTYPE_NODE, "nodes", "client/peer stations",
+       if ((rc = sysctl_createv(clog, 0, &wlan_node, NULL,
+           CTLFLAG_PERMANENT, CTLTYPE_NODE,
+           "nodes", SYSCTL_DESCR("client/peer stations"),
            ieee80211_sysctl_node, 0, NULL, 0, CTL_CREATE, CTL_EOL)) != 0)
                goto err;
 #endif
 
 #ifdef IEEE80211_DEBUG
        /* control debugging printfs */
-       if ((rc = sysctl_createv(&ieee80211_sysctllog, 0, &rnode, NULL,
+       if ((rc = sysctl_createv(clog, 0, &wlan_node, NULL,
            CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT,
            "debug", SYSCTL_DESCR("control debugging printfs"),
            NULL, 0, &ieee80211_debug, 0, CTL_CREATE, CTL_EOL)) != 0)
@@ -368,7 +367,7 @@
 #endif
 
 #ifdef notyet
-       ieee80211_rssadapt_sysctl_setup(&ieee80211_sysctllog);
+       ieee80211_rssadapt_sysctl_setup(clog);
 #endif
 
        return;
@@ -378,52 +377,22 @@
 #endif
 }
 
-/*
- * Create or get top of sysctl tree net.link.ieee80211.
- */
-static const struct sysctlnode *
-ieee80211_sysctl_treetop(struct sysctllog **log)
-{
-       int rc;
-       const struct sysctlnode *rnode;
-
-       if ((rc = sysctl_createv(log, 0, NULL, &rnode,
-           CTLFLAG_PERMANENT, CTLTYPE_NODE, "link",
-           "link-layer statistics and controls",
-           NULL, 0, NULL, 0, CTL_NET, PF_LINK, CTL_EOL)) != 0)
-               goto err;
-
-       if ((rc = sysctl_createv(log, 0, &rnode, &rnode,
-           CTLFLAG_PERMANENT, CTLTYPE_NODE, "ieee80211",
-           "IEEE 802.11 WLAN statistics and controls",
-           NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL)) != 0)
-               goto err;
-
-       return rnode;
-err:
-       printf("%s: sysctl_createv failed, rc = %d\n", __func__, rc);
-       return NULL;
-}
-
 void
 ieee80211_sysctl_vattach(struct ieee80211vap *vap)
 {
        int rc;
-       const struct sysctlnode *cnode, *rnode;
+       const struct sysctlnode *rnode;
        char num[sizeof("vap") + 14];           /* sufficient for 32 bits */
 
-       if ((rnode = ieee80211_sysctl_treetop(NULL)) == NULL)
-               return;
-
        snprintf(num, sizeof(num), "vap%u", vap->iv_ifp->if_index);
 
-       if ((rc = sysctl_createv(&vap->iv_sysctllog, 0, &rnode, &rnode,
+       if ((rc = sysctl_createv(NULL, 0, NULL, &rnode,
            CTLFLAG_PERMANENT, CTLTYPE_NODE, num, SYSCTL_DESCR("virtual AP"),
-           NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL)) != 0)
+           NULL, 0, NULL, 0,
+           CTL_NET, ctl_wlan, CTL_CREATE, CTL_EOL)) != 0)
                goto err;
 
-       /* control debugging printfs */
-       if ((rc = sysctl_createv(&vap->iv_sysctllog, 0, &rnode, &cnode,
+       if ((rc = sysctl_createv(NULL, 0, &rnode, NULL,
            CTLFLAG_PERMANENT|CTLFLAG_READONLY, CTLTYPE_STRING,
            "parent", SYSCTL_DESCR("parent device"),
            ieee80211_sysctl_parent, 0, (void *)vap, IFNAMSIZ,



Home | Main Index | Thread Index | Old Index