[WEXT]: Clean up how wext is called.
authorJohannes Berg <johannes@sipsolutions.net>
Fri, 27 Apr 2007 03:43:56 +0000 (20:43 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 27 Apr 2007 03:43:56 +0000 (20:43 -0700)
This patch cleans up the call paths from the core code into wext.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/iw_handler.h
include/net/wext.h [new file with mode: 0644]
net/core/dev.c
net/wireless/wext.c

index 909ca87d13b7512fcd14a9a1cd95e8422c1c5154..f23d07ca7c59e060c38a8c4a1aa6a9c6c2e38474 100644 (file)
@@ -431,16 +431,7 @@ struct iw_public_data {
  * Those may be called only within the kernel.
  */
 
-/* First : function strictly used inside the kernel */
-
-/* Handle /proc/net/wireless, called in net/code/dev.c */
-extern int dev_get_wireless_info(char * buffer, char **start, off_t offset,
-                                int length);
-
-/* Handle IOCTLs, called in net/core/dev.c */
-extern int wireless_process_ioctl(struct ifreq *ifr, unsigned int cmd);
-
-/* Second : functions that may be called by driver modules */
+/* functions that may be called by driver modules */
 
 /* Send a single event to user space */
 extern void wireless_send_event(struct net_device *    dev,
diff --git a/include/net/wext.h b/include/net/wext.h
new file mode 100644 (file)
index 0000000..5574183
--- /dev/null
@@ -0,0 +1,24 @@
+#ifndef __NET_WEXT_H
+#define __NET_WEXT_H
+
+/*
+ * wireless extensions interface to the core code
+ */
+
+#ifdef CONFIG_WIRELESS_EXT
+extern int wext_proc_init(void);
+extern int wext_handle_ioctl(struct ifreq *ifr, unsigned int cmd,
+                            void __user *arg);
+#else
+static inline int wext_proc_init()
+{
+       return 0;
+}
+static inline int wext_handle_ioctl(struct ifreq *ifr, unsigned int cmd,
+                                   void __user *arg)
+{
+       return -EINVAL;
+}
+#endif
+
+#endif /* __NET_WEXT_H */
index 700e4b5081b6ee6da6fe1f49b53bc57dfd0f8f63..d5e42d13bd67d3c88846df035ba9576e1e2db53f 100644 (file)
 #include <linux/netpoll.h>
 #include <linux/rcupdate.h>
 #include <linux/delay.h>
-#include <linux/wireless.h>
+#include <net/wext.h>
 #include <net/iw_handler.h>
 #include <asm/current.h>
 #include <linux/audit.h>
@@ -2348,12 +2348,6 @@ static const struct file_operations ptype_seq_fops = {
 };
 
 
-#ifdef CONFIG_WIRELESS_EXT
-extern int wireless_proc_init(void);
-#else
-#define wireless_proc_init() 0
-#endif
-
 static int __init dev_proc_init(void)
 {
        int rc = -ENOMEM;
@@ -2365,7 +2359,7 @@ static int __init dev_proc_init(void)
        if (!proc_net_fops_create("ptype", S_IRUGO, &ptype_seq_fops))
                goto out_dev2;
 
-       if (wireless_proc_init())
+       if (wext_proc_init())
                goto out_softnet;
        rc = 0;
 out:
@@ -2923,29 +2917,9 @@ int dev_ioctl(unsigned int cmd, void __user *arg)
                                        ret = -EFAULT;
                                return ret;
                        }
-#ifdef CONFIG_WIRELESS_EXT
                        /* Take care of Wireless Extensions */
-                       if (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST) {
-                               /* If command is `set a parameter', or
-                                * `get the encoding parameters', check if
-                                * the user has the right to do it */
-                               if (IW_IS_SET(cmd) || cmd == SIOCGIWENCODE
-                                   || cmd == SIOCGIWENCODEEXT) {
-                                       if (!capable(CAP_NET_ADMIN))
-                                               return -EPERM;
-                               }
-                               dev_load(ifr.ifr_name);
-                               rtnl_lock();
-                               /* Follow me in net/wireless/wext.c */
-                               ret = wireless_process_ioctl(&ifr, cmd);
-                               rtnl_unlock();
-                               if (IW_IS_GET(cmd) &&
-                                   copy_to_user(arg, &ifr,
-                                                sizeof(struct ifreq)))
-                                       ret = -EFAULT;
-                               return ret;
-                       }
-#endif /* CONFIG_WIRELESS_EXT */
+                       if (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST)
+                               return wext_handle_ioctl(&ifr, cmd, arg);
                        return -EINVAL;
        }
 }
index fba295e05e7a97e075d8619757a796516c8f4f5f..a6cf1034e07c0f08cc12d1199fe9cf1a8b314416 100644 (file)
@@ -97,6 +97,7 @@
 #include <linux/wireless.h>            /* Pretty obvious */
 #include <net/iw_handler.h>            /* New driver API */
 #include <net/netlink.h>
+#include <net/wext.h>
 
 #include <asm/uaccess.h>               /* copy_to_user() */
 
@@ -696,7 +697,7 @@ static const struct file_operations wireless_seq_fops = {
        .release = seq_release,
 };
 
-int __init wireless_proc_init(void)
+int __init wext_proc_init(void)
 {
        /* Create /proc/net/wireless entry */
        if (!proc_net_fops_create("wireless", S_IRUGO, &wireless_seq_fops))
@@ -1075,11 +1076,10 @@ static inline int ioctl_private_call(struct net_device *        dev,
 
 /* ---------------------------------------------------------------- */
 /*
- * Main IOCTl dispatcher. Called from the main networking code
- * (dev_ioctl() in net/core/dev.c).
+ * Main IOCTl dispatcher.
  * Check the type of IOCTL and call the appropriate wrapper...
  */
-int wireless_process_ioctl(struct ifreq *ifr, unsigned int cmd)
+static int wireless_process_ioctl(struct ifreq *ifr, unsigned int cmd)
 {
        struct net_device *dev;
        iw_handler      handler;
@@ -1143,6 +1143,26 @@ int wireless_process_ioctl(struct ifreq *ifr, unsigned int cmd)
        return -EINVAL;
 }
 
+/* entry point from dev ioctl */
+int wext_handle_ioctl(struct ifreq *ifr, unsigned int cmd,
+                     void __user *arg)
+{
+       int ret;
+
+       /* If command is `set a parameter', or
+        * `get the encoding parameters', check if
+        * the user has the right to do it */
+       if (IW_IS_SET(cmd) || cmd == SIOCGIWENCODE || cmd == SIOCGIWENCODEEXT)
+               if (!capable(CAP_NET_ADMIN))
+                       return -EPERM;
+       dev_load(ifr->ifr_name);
+       rtnl_lock();
+       ret = wireless_process_ioctl(ifr, cmd);
+       rtnl_unlock();
+       if (IW_IS_GET(cmd) && copy_to_user(arg, ifr, sizeof(struct ifreq)))
+               return -EFAULT;
+       return ret;
+}
 
 /************************* EVENT PROCESSING *************************/
 /*