Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Johannes Berg and committed by
David S. Miller
295f4a1f 11433ee4

+53 -44
+1 -10
include/net/iw_handler.h
··· 431 431 * Those may be called only within the kernel. 432 432 */ 433 433 434 - /* First : function strictly used inside the kernel */ 435 - 436 - /* Handle /proc/net/wireless, called in net/code/dev.c */ 437 - extern int dev_get_wireless_info(char * buffer, char **start, off_t offset, 438 - int length); 439 - 440 - /* Handle IOCTLs, called in net/core/dev.c */ 441 - extern int wireless_process_ioctl(struct ifreq *ifr, unsigned int cmd); 442 - 443 - /* Second : functions that may be called by driver modules */ 434 + /* functions that may be called by driver modules */ 444 435 445 436 /* Send a single event to user space */ 446 437 extern void wireless_send_event(struct net_device * dev,
+24
include/net/wext.h
··· 1 + #ifndef __NET_WEXT_H 2 + #define __NET_WEXT_H 3 + 4 + /* 5 + * wireless extensions interface to the core code 6 + */ 7 + 8 + #ifdef CONFIG_WIRELESS_EXT 9 + extern int wext_proc_init(void); 10 + extern int wext_handle_ioctl(struct ifreq *ifr, unsigned int cmd, 11 + void __user *arg); 12 + #else 13 + static inline int wext_proc_init() 14 + { 15 + return 0; 16 + } 17 + static inline int wext_handle_ioctl(struct ifreq *ifr, unsigned int cmd, 18 + void __user *arg) 19 + { 20 + return -EINVAL; 21 + } 22 + #endif 23 + 24 + #endif /* __NET_WEXT_H */
+4 -30
net/core/dev.c
··· 109 109 #include <linux/netpoll.h> 110 110 #include <linux/rcupdate.h> 111 111 #include <linux/delay.h> 112 - #include <linux/wireless.h> 112 + #include <net/wext.h> 113 113 #include <net/iw_handler.h> 114 114 #include <asm/current.h> 115 115 #include <linux/audit.h> ··· 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 2351 static int __init dev_proc_init(void) 2358 2352 { 2359 2353 int rc = -ENOMEM; ··· 2359 2365 if (!proc_net_fops_create("ptype", S_IRUGO, &ptype_seq_fops)) 2360 2366 goto out_dev2; 2361 2367 2362 - if (wireless_proc_init()) 2368 + if (wext_proc_init()) 2363 2369 goto out_softnet; 2364 2370 rc = 0; 2365 2371 out: ··· 2917 2923 ret = -EFAULT; 2918 2924 return ret; 2919 2925 } 2920 - #ifdef CONFIG_WIRELESS_EXT 2921 2926 /* Take care of Wireless Extensions */ 2922 - if (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST) { 2923 - /* If command is `set a parameter', or 2924 - * `get the encoding parameters', check if 2925 - * the user has the right to do it */ 2926 - if (IW_IS_SET(cmd) || cmd == SIOCGIWENCODE 2927 - || cmd == SIOCGIWENCODEEXT) { 2928 - if (!capable(CAP_NET_ADMIN)) 2929 - return -EPERM; 2930 - } 2931 - dev_load(ifr.ifr_name); 2932 - rtnl_lock(); 2933 - /* Follow me in net/wireless/wext.c */ 2934 - ret = wireless_process_ioctl(&ifr, cmd); 2935 - rtnl_unlock(); 2936 - if (IW_IS_GET(cmd) && 2937 - copy_to_user(arg, &ifr, 2938 - sizeof(struct ifreq))) 2939 - ret = -EFAULT; 2940 - return ret; 2941 - } 2942 - #endif /* CONFIG_WIRELESS_EXT */ 2927 + if (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST) 2928 + return wext_handle_ioctl(&ifr, cmd, arg); 2943 2929 return -EINVAL; 2944 2930 } 2945 2931 }
+24 -4
net/wireless/wext.c
··· 97 97 #include <linux/wireless.h> /* Pretty obvious */ 98 98 #include <net/iw_handler.h> /* New driver API */ 99 99 #include <net/netlink.h> 100 + #include <net/wext.h> 100 101 101 102 #include <asm/uaccess.h> /* copy_to_user() */ 102 103 ··· 697 696 .release = seq_release, 698 697 }; 699 698 700 - int __init wireless_proc_init(void) 699 + int __init wext_proc_init(void) 701 700 { 702 701 /* Create /proc/net/wireless entry */ 703 702 if (!proc_net_fops_create("wireless", S_IRUGO, &wireless_seq_fops)) ··· 1076 1075 1077 1076 /* ---------------------------------------------------------------- */ 1078 1077 /* 1079 - * Main IOCTl dispatcher. Called from the main networking code 1080 - * (dev_ioctl() in net/core/dev.c). 1078 + * Main IOCTl dispatcher. 1081 1079 * Check the type of IOCTL and call the appropriate wrapper... 1082 1080 */ 1083 - int wireless_process_ioctl(struct ifreq *ifr, unsigned int cmd) 1081 + static int wireless_process_ioctl(struct ifreq *ifr, unsigned int cmd) 1084 1082 { 1085 1083 struct net_device *dev; 1086 1084 iw_handler handler; ··· 1143 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 1167 /************************* EVENT PROCESSING *************************/ 1148 1168 /*