From: Johannes Berg <johannes-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
To: David Miller <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
jt-sDzT885Ts8HQT0dZR+AlfA@public.gmane.org
Subject: [PATCH 2/9] wext: clean up how wext is called
Date: Tue, 24 Apr 2007 20:07:34 +0200 [thread overview]
Message-ID: <20070424180847.533947000@sipsolutions.net> (raw)
In-Reply-To: 20070424180732.371620000@sipsolutions.net
[-- Attachment #1: cleanup-wext-call.patch --]
[-- Type: text/plain, Size: 5630 bytes --]
This patch cleans up the call paths from the core code into wext.
Signed-off-by: Johannes Berg <johannes-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
---
include/net/iw_handler.h | 11 +----------
include/net/wext.h | 24 ++++++++++++++++++++++++
net/core/dev.c | 34 ++++------------------------------
net/wireless/wext.c | 28 ++++++++++++++++++++++++----
4 files changed, 53 insertions(+), 44 deletions(-)
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ net-2.6.22/include/net/wext.h 2007-04-24 18:51:23.568804911 +0200
@@ -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 */
--- net-2.6.22.orig/net/core/dev.c 2007-04-24 18:50:45.888804911 +0200
+++ net-2.6.22/net/core/dev.c 2007-04-24 18:51:23.568804911 +0200
@@ -109,7 +109,7 @@
#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 ptyp
};
-#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 __u
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;
}
}
--- net-2.6.22.orig/include/net/iw_handler.h 2007-04-24 18:54:01.678804911 +0200
+++ net-2.6.22/include/net/iw_handler.h 2007-04-24 18:56:27.328804911 +0200
@@ -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,
--- net-2.6.22.orig/net/wireless/wext.c 2007-04-24 18:51:31.288804911 +0200
+++ net-2.6.22/net/wireless/wext.c 2007-04-24 19:04:20.818804911 +0200
@@ -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 wire
.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(str
/* ---------------------------------------------------------------- */
/*
- * 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
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 *************************/
/*
--
next prev parent reply other threads:[~2007-04-24 18:07 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-24 18:07 [PATCH 0/9] various wext cleanups Johannes Berg
2007-04-24 18:07 ` [PATCH 1/9] wext: move to net/wireless Johannes Berg
2007-04-24 18:07 ` Johannes Berg [this message]
2007-04-24 18:07 ` [PATCH 3/9] wext: remove dead debug code Johannes Berg
[not found] ` <20070424180847.982382000-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
2007-04-26 16:46 ` Jean Tourrilhes
[not found] ` <20070426164632.GA22576-yAE0UhLNZJawPNPzzlOzwdBPR1lH4CV8@public.gmane.org>
2007-04-27 0:55 ` John W. Linville
2007-04-24 18:07 ` [PATCH 4/9] wext: remove options Johannes Berg
2007-04-24 18:07 ` [PATCH 5/9] wext: cleanup early ioctl call path Johannes Berg
2007-04-24 18:07 ` [PATCH 6/9] wext: move EXPORT_SYMBOL statements where they belong Johannes Berg
2007-04-24 18:07 ` [PATCH 7/9] wext: reduce inline abuse Johannes Berg
2007-04-26 16:50 ` Jean Tourrilhes
2007-04-26 17:03 ` Michael Buesch
[not found] ` <200704261903.27932.mb-fseUSCV1ubazQB+pC5nmwQ@public.gmane.org>
2007-04-26 17:15 ` Jean Tourrilhes
2007-04-26 21:37 ` David Miller
[not found] ` <20070426165032.GB22576-yAE0UhLNZJawPNPzzlOzwdBPR1lH4CV8@public.gmane.org>
2007-04-26 17:14 ` Johannes Berg
2007-04-24 18:07 ` [PATCH 8/9] wext: misc code cleanups Johannes Berg
2007-04-24 18:07 ` [PATCH 9/9] net_device: dont include wext bits if not required Johannes Berg
[not found] ` <20070424180850.595757000-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
2007-04-26 16:53 ` Jean Tourrilhes
2007-04-26 17:08 ` Johannes Berg
[not found] ` <20070426165304.GC22576-yAE0UhLNZJawPNPzzlOzwdBPR1lH4CV8@public.gmane.org>
2007-04-27 0:50 ` John W. Linville
[not found] ` <20070424180732.371620000-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
2007-04-26 10:15 ` [PATCH 0/9] various wext cleanups Johannes Berg
2007-04-26 10:18 ` David Miller
[not found] ` <20070426.031842.17863787.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2007-04-26 11:05 ` Johannes Berg
2007-04-26 10:19 ` David Miller
[not found] ` <20070426.031921.133286083.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2007-04-27 1:12 ` John W. Linville
2007-04-27 2:36 ` David Miller
2007-04-27 3:48 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070424180847.533947000@sipsolutions.net \
--to=johannes-cdvu00un1vgdhxzaddlk8q@public.gmane.org \
--cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
--cc=jt-sDzT885Ts8HQT0dZR+AlfA@public.gmane.org \
--cc=linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).