aboutsummaryrefslogtreecommitdiffstats
path: root/net/wireless
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2007-09-17 14:56:21 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:49:10 -0400
commit881d966b48b035ab3f3aeaae0f3d3f9b584f45b2 (patch)
treec579d59a4107cbbe9e2b85939bc0d496b815c887 /net/wireless
parentb4b510290b056b86611757ce1175a230f1080f53 (diff)
[NET]: Make the device list and device lookups per namespace.
This patch makes most of the generic device layer network namespace safe. This patch makes dev_base_head a network namespace variable, and then it picks up a few associated variables. The functions: dev_getbyhwaddr dev_getfirsthwbytype dev_get_by_flags dev_get_by_name __dev_get_by_name dev_get_by_index __dev_get_by_index dev_ioctl dev_ethtool dev_load wireless_process_ioctl were modified to take a network namespace argument, and deal with it. vlan_ioctl_set and brioctl_set were modified so their hooks will receive a network namespace argument. So basically anthing in the core of the network stack that was affected to by the change of dev_base was modified to handle multiple network namespaces. The rest of the network stack was simply modified to explicitly use &init_net the initial network namespace. This can be fixed when those components of the network stack are modified to handle multiple network namespaces. For now the ifindex generator is left global. Fundametally ifindex numbers are per namespace, or else we will have corner case problems with migration when we get that far. At the same time there are assumptions in the network stack that the ifindex of a network device won't change. Making the ifindex number global seems a good compromise until the network stack can cope with ifindex changes when you change namespaces, and the like. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/wireless')
-rw-r--r--net/wireless/wext.c38
1 files changed, 29 insertions, 9 deletions
diff --git a/net/wireless/wext.c b/net/wireless/wext.c
index b8069afe0410..e8b3409d6c8b 100644
--- a/net/wireless/wext.c
+++ b/net/wireless/wext.c
@@ -673,7 +673,22 @@ static const struct seq_operations wireless_seq_ops = {
673 673
674static int wireless_seq_open(struct inode *inode, struct file *file) 674static int wireless_seq_open(struct inode *inode, struct file *file)
675{ 675{
676 return seq_open(file, &wireless_seq_ops); 676 struct seq_file *seq;
677 int res;
678 res = seq_open(file, &wireless_seq_ops);
679 if (!res) {
680 seq = file->private_data;
681 seq->private = get_net(PROC_NET(inode));
682 }
683 return res;
684}
685
686static int wireless_seq_release(struct inode *inode, struct file *file)
687{
688 struct seq_file *seq = file->private_data;
689 struct net *net = seq->private;
690 put_net(net);
691 return seq_release(inode, file);
677} 692}
678 693
679static const struct file_operations wireless_seq_fops = { 694static const struct file_operations wireless_seq_fops = {
@@ -681,17 +696,22 @@ static const struct file_operations wireless_seq_fops = {
681 .open = wireless_seq_open, 696 .open = wireless_seq_open,
682 .read = seq_read, 697 .read = seq_read,
683 .llseek = seq_lseek, 698 .llseek = seq_lseek,
684 .release = seq_release, 699 .release = wireless_seq_release,
685}; 700};
686 701
687int __init wext_proc_init(void) 702int wext_proc_init(struct net *net)
688{ 703{
689 /* Create /proc/net/wireless entry */ 704 /* Create /proc/net/wireless entry */
690 if (!proc_net_fops_create(&init_net, "wireless", S_IRUGO, &wireless_seq_fops)) 705 if (!proc_net_fops_create(net, "wireless", S_IRUGO, &wireless_seq_fops))
691 return -ENOMEM; 706 return -ENOMEM;
692 707
693 return 0; 708 return 0;
694} 709}
710
711void wext_proc_exit(struct net *net)
712{
713 proc_net_remove(net, "wireless");
714}
695#endif /* CONFIG_PROC_FS */ 715#endif /* CONFIG_PROC_FS */
696 716
697/************************** IOCTL SUPPORT **************************/ 717/************************** IOCTL SUPPORT **************************/
@@ -1011,7 +1031,7 @@ static int ioctl_private_call(struct net_device *dev, struct ifreq *ifr,
1011 * Main IOCTl dispatcher. 1031 * Main IOCTl dispatcher.
1012 * Check the type of IOCTL and call the appropriate wrapper... 1032 * Check the type of IOCTL and call the appropriate wrapper...
1013 */ 1033 */
1014static int wireless_process_ioctl(struct ifreq *ifr, unsigned int cmd) 1034static int wireless_process_ioctl(struct net *net, struct ifreq *ifr, unsigned int cmd)
1015{ 1035{
1016 struct net_device *dev; 1036 struct net_device *dev;
1017 iw_handler handler; 1037 iw_handler handler;
@@ -1020,7 +1040,7 @@ static int wireless_process_ioctl(struct ifreq *ifr, unsigned int cmd)
1020 * The copy_to/from_user() of ifr is also dealt with in there */ 1040 * The copy_to/from_user() of ifr is also dealt with in there */
1021 1041
1022 /* Make sure the device exist */ 1042 /* Make sure the device exist */
1023 if ((dev = __dev_get_by_name(ifr->ifr_name)) == NULL) 1043 if ((dev = __dev_get_by_name(net, ifr->ifr_name)) == NULL)
1024 return -ENODEV; 1044 return -ENODEV;
1025 1045
1026 /* A bunch of special cases, then the generic case... 1046 /* A bunch of special cases, then the generic case...
@@ -1054,7 +1074,7 @@ static int wireless_process_ioctl(struct ifreq *ifr, unsigned int cmd)
1054} 1074}
1055 1075
1056/* entry point from dev ioctl */ 1076/* entry point from dev ioctl */
1057int wext_handle_ioctl(struct ifreq *ifr, unsigned int cmd, 1077int wext_handle_ioctl(struct net *net, struct ifreq *ifr, unsigned int cmd,
1058 void __user *arg) 1078 void __user *arg)
1059{ 1079{
1060 int ret; 1080 int ret;
@@ -1066,9 +1086,9 @@ int wext_handle_ioctl(struct ifreq *ifr, unsigned int cmd,
1066 && !capable(CAP_NET_ADMIN)) 1086 && !capable(CAP_NET_ADMIN))
1067 return -EPERM; 1087 return -EPERM;
1068 1088
1069 dev_load(ifr->ifr_name); 1089 dev_load(net, ifr->ifr_name);
1070 rtnl_lock(); 1090 rtnl_lock();
1071 ret = wireless_process_ioctl(ifr, cmd); 1091 ret = wireless_process_ioctl(net, ifr, cmd);
1072 rtnl_unlock(); 1092 rtnl_unlock();
1073 if (IW_IS_GET(cmd) && copy_to_user(arg, ifr, sizeof(struct ifreq))) 1093 if (IW_IS_GET(cmd) && copy_to_user(arg, ifr, sizeof(struct ifreq)))
1074 return -EFAULT; 1094 return -EFAULT;