diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2007-04-26 23:43:56 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2007-04-26 23:43:56 -0400 |
commit | 295f4a1fa3ecdf816b18393ef7bcd37c032df2fa (patch) | |
tree | 231c71578608e46b45dd36006dd1112a6bc6c39a /net | |
parent | 11433ee450eb4a320f46ce5ed51410b52803ffcc (diff) |
[WEXT]: Clean up how wext is called.
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>
Diffstat (limited to 'net')
-rw-r--r-- | net/core/dev.c | 34 | ||||
-rw-r--r-- | net/wireless/wext.c | 28 |
2 files changed, 28 insertions, 34 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index 700e4b5081b6..d5e42d13bd67 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -109,7 +109,7 @@ | |||
109 | #include <linux/netpoll.h> | 109 | #include <linux/netpoll.h> |
110 | #include <linux/rcupdate.h> | 110 | #include <linux/rcupdate.h> |
111 | #include <linux/delay.h> | 111 | #include <linux/delay.h> |
112 | #include <linux/wireless.h> | 112 | #include <net/wext.h> |
113 | #include <net/iw_handler.h> | 113 | #include <net/iw_handler.h> |
114 | #include <asm/current.h> | 114 | #include <asm/current.h> |
115 | #include <linux/audit.h> | 115 | #include <linux/audit.h> |
@@ -2348,12 +2348,6 @@ static const struct file_operations ptype_seq_fops = { | |||
2348 | }; | 2348 | }; |
2349 | 2349 | ||
2350 | 2350 | ||
2351 | #ifdef CONFIG_WIRELESS_EXT | ||
2352 | extern int wireless_proc_init(void); | ||
2353 | #else | ||
2354 | #define wireless_proc_init() 0 | ||
2355 | #endif | ||
2356 | |||
2357 | static int __init dev_proc_init(void) | 2351 | static int __init dev_proc_init(void) |
2358 | { | 2352 | { |
2359 | int rc = -ENOMEM; | 2353 | int rc = -ENOMEM; |
@@ -2365,7 +2359,7 @@ static int __init dev_proc_init(void) | |||
2365 | if (!proc_net_fops_create("ptype", S_IRUGO, &ptype_seq_fops)) | 2359 | if (!proc_net_fops_create("ptype", S_IRUGO, &ptype_seq_fops)) |
2366 | goto out_dev2; | 2360 | goto out_dev2; |
2367 | 2361 | ||
2368 | if (wireless_proc_init()) | 2362 | if (wext_proc_init()) |
2369 | goto out_softnet; | 2363 | goto out_softnet; |
2370 | rc = 0; | 2364 | rc = 0; |
2371 | out: | 2365 | out: |
@@ -2923,29 +2917,9 @@ int dev_ioctl(unsigned int cmd, void __user *arg) | |||
2923 | ret = -EFAULT; | 2917 | ret = -EFAULT; |
2924 | return ret; | 2918 | return ret; |
2925 | } | 2919 | } |
2926 | #ifdef CONFIG_WIRELESS_EXT | ||
2927 | /* Take care of Wireless Extensions */ | 2920 | /* Take care of Wireless Extensions */ |
2928 | if (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST) { | 2921 | if (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST) |
2929 | /* If command is `set a parameter', or | 2922 | return wext_handle_ioctl(&ifr, cmd, arg); |
2930 | * `get the encoding parameters', check if | ||
2931 | * the user has the right to do it */ | ||
2932 | if (IW_IS_SET(cmd) || cmd == SIOCGIWENCODE | ||
2933 | || cmd == SIOCGIWENCODEEXT) { | ||
2934 | if (!capable(CAP_NET_ADMIN)) | ||
2935 | return -EPERM; | ||
2936 | } | ||
2937 | dev_load(ifr.ifr_name); | ||
2938 | rtnl_lock(); | ||
2939 | /* Follow me in net/wireless/wext.c */ | ||
2940 | ret = wireless_process_ioctl(&ifr, cmd); | ||
2941 | rtnl_unlock(); | ||
2942 | if (IW_IS_GET(cmd) && | ||
2943 | copy_to_user(arg, &ifr, | ||
2944 | sizeof(struct ifreq))) | ||
2945 | ret = -EFAULT; | ||
2946 | return ret; | ||
2947 | } | ||
2948 | #endif /* CONFIG_WIRELESS_EXT */ | ||
2949 | return -EINVAL; | 2923 | return -EINVAL; |
2950 | } | 2924 | } |
2951 | } | 2925 | } |
diff --git a/net/wireless/wext.c b/net/wireless/wext.c index fba295e05e7a..a6cf1034e07c 100644 --- a/net/wireless/wext.c +++ b/net/wireless/wext.c | |||
@@ -97,6 +97,7 @@ | |||
97 | #include <linux/wireless.h> /* Pretty obvious */ | 97 | #include <linux/wireless.h> /* Pretty obvious */ |
98 | #include <net/iw_handler.h> /* New driver API */ | 98 | #include <net/iw_handler.h> /* New driver API */ |
99 | #include <net/netlink.h> | 99 | #include <net/netlink.h> |
100 | #include <net/wext.h> | ||
100 | 101 | ||
101 | #include <asm/uaccess.h> /* copy_to_user() */ | 102 | #include <asm/uaccess.h> /* copy_to_user() */ |
102 | 103 | ||
@@ -696,7 +697,7 @@ static const struct file_operations wireless_seq_fops = { | |||
696 | .release = seq_release, | 697 | .release = seq_release, |
697 | }; | 698 | }; |
698 | 699 | ||
699 | int __init wireless_proc_init(void) | 700 | int __init wext_proc_init(void) |
700 | { | 701 | { |
701 | /* Create /proc/net/wireless entry */ | 702 | /* Create /proc/net/wireless entry */ |
702 | if (!proc_net_fops_create("wireless", S_IRUGO, &wireless_seq_fops)) | 703 | 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, | |||
1075 | 1076 | ||
1076 | /* ---------------------------------------------------------------- */ | 1077 | /* ---------------------------------------------------------------- */ |
1077 | /* | 1078 | /* |
1078 | * Main IOCTl dispatcher. Called from the main networking code | 1079 | * Main IOCTl dispatcher. |
1079 | * (dev_ioctl() in net/core/dev.c). | ||
1080 | * Check the type of IOCTL and call the appropriate wrapper... | 1080 | * Check the type of IOCTL and call the appropriate wrapper... |
1081 | */ | 1081 | */ |
1082 | int wireless_process_ioctl(struct ifreq *ifr, unsigned int cmd) | 1082 | static int wireless_process_ioctl(struct ifreq *ifr, unsigned int cmd) |
1083 | { | 1083 | { |
1084 | struct net_device *dev; | 1084 | struct net_device *dev; |
1085 | iw_handler handler; | 1085 | iw_handler handler; |
@@ -1143,6 +1143,26 @@ int wireless_process_ioctl(struct ifreq *ifr, unsigned int cmd) | |||
1143 | return -EINVAL; | 1143 | return -EINVAL; |
1144 | } | 1144 | } |
1145 | 1145 | ||
1146 | /* entry point from dev ioctl */ | ||
1147 | int wext_handle_ioctl(struct ifreq *ifr, unsigned int cmd, | ||
1148 | void __user *arg) | ||
1149 | { | ||
1150 | int ret; | ||
1151 | |||
1152 | /* If command is `set a parameter', or | ||
1153 | * `get the encoding parameters', check if | ||
1154 | * the user has the right to do it */ | ||
1155 | if (IW_IS_SET(cmd) || cmd == SIOCGIWENCODE || cmd == SIOCGIWENCODEEXT) | ||
1156 | if (!capable(CAP_NET_ADMIN)) | ||
1157 | return -EPERM; | ||
1158 | dev_load(ifr->ifr_name); | ||
1159 | rtnl_lock(); | ||
1160 | ret = wireless_process_ioctl(ifr, cmd); | ||
1161 | rtnl_unlock(); | ||
1162 | if (IW_IS_GET(cmd) && copy_to_user(arg, ifr, sizeof(struct ifreq))) | ||
1163 | return -EFAULT; | ||
1164 | return ret; | ||
1165 | } | ||
1146 | 1166 | ||
1147 | /************************* EVENT PROCESSING *************************/ | 1167 | /************************* EVENT PROCESSING *************************/ |
1148 | /* | 1168 | /* |