aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-11 22:40:14 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-11 22:40:14 -0400
commit038a5008b2f395c85e6e71d6ddf3c684e7c405b0 (patch)
tree4735eab577e97e5a22c3141e3f60071c8065585e /fs
parentdd6d1844af33acb4edd0a40b1770d091a22c94be (diff)
parent266918303226cceac7eca38ced30f15f277bd89c (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
* 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6: (867 commits) [SKY2]: status polling loop (post merge) [NET]: Fix NAPI completion handling in some drivers. [TCP]: Limit processing lost_retrans loop to work-to-do cases [TCP]: Fix lost_retrans loop vs fastpath problems [TCP]: No need to re-count fackets_out/sacked_out at RTO [TCP]: Extract tcp_match_queue_to_sack from sacktag code [TCP]: Kill almost unused variable pcount from sacktag [TCP]: Fix mark_head_lost to ignore R-bit when trying to mark L [TCP]: Add bytes_acked (ABC) clearing to FRTO too [IPv6]: Update setsockopt(IPV6_MULTICAST_IF) to support RFC 3493, try2 [NETFILTER]: x_tables: add missing ip6t_modulename aliases [NETFILTER]: nf_conntrack_tcp: fix connection reopening [QETH]: fix qeth_main.c [NETLINK]: fib_frontend build fixes [IPv6]: Export userland ND options through netlink (RDNSS support) [9P]: build fix with !CONFIG_SYSCTL [NET]: Fix dev_put() and dev_hold() comments [NET]: make netlink user -> kernel interface synchronious [NET]: unify netlink kernel socket recognition [NET]: cleanup 3rd argument in netlink_sendskb ... Fix up conflicts manually in Documentation/feature-removal-schedule.txt and my new least favourite crap, the "mod_devicetable" support in the files include/linux/mod_devicetable.h and scripts/mod/file2alias.c. (The latter files seem to be explicitly _designed_ to get conflicts when different subsystems work with them - that have an absolutely horrid lack of subsystem separation!) Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/afs/netdevices.c5
-rw-r--r--fs/compat_ioctl.c21
-rw-r--r--fs/ecryptfs/netlink.c16
-rw-r--r--fs/proc/Makefile1
-rw-r--r--fs/proc/internal.h5
-rw-r--r--fs/proc/proc_net.c200
-rw-r--r--fs/proc/root.c8
-rw-r--r--fs/seq_file.c33
8 files changed, 257 insertions, 32 deletions
diff --git a/fs/afs/netdevices.c b/fs/afs/netdevices.c
index fc27d4b52e5f..49f189423063 100644
--- a/fs/afs/netdevices.c
+++ b/fs/afs/netdevices.c
@@ -8,6 +8,7 @@
8#include <linux/inetdevice.h> 8#include <linux/inetdevice.h>
9#include <linux/netdevice.h> 9#include <linux/netdevice.h>
10#include <linux/if_arp.h> 10#include <linux/if_arp.h>
11#include <net/net_namespace.h>
11#include "internal.h" 12#include "internal.h"
12 13
13/* 14/*
@@ -23,7 +24,7 @@ int afs_get_MAC_address(u8 *mac, size_t maclen)
23 BUG(); 24 BUG();
24 25
25 rtnl_lock(); 26 rtnl_lock();
26 dev = __dev_getfirstbyhwtype(ARPHRD_ETHER); 27 dev = __dev_getfirstbyhwtype(&init_net, ARPHRD_ETHER);
27 if (dev) { 28 if (dev) {
28 memcpy(mac, dev->dev_addr, maclen); 29 memcpy(mac, dev->dev_addr, maclen);
29 ret = 0; 30 ret = 0;
@@ -47,7 +48,7 @@ int afs_get_ipv4_interfaces(struct afs_interface *bufs, size_t maxbufs,
47 ASSERT(maxbufs > 0); 48 ASSERT(maxbufs > 0);
48 49
49 rtnl_lock(); 50 rtnl_lock();
50 for_each_netdev(dev) { 51 for_each_netdev(&init_net, dev) {
51 if (dev->type == ARPHRD_LOOPBACK && !wantloopback) 52 if (dev->type == ARPHRD_LOOPBACK && !wantloopback)
52 continue; 53 continue;
53 idev = __in_dev_get_rtnl(dev); 54 idev = __in_dev_get_rtnl(dev);
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index b9e3357bcc2e..9c3fd07f35e0 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -319,22 +319,21 @@ struct ifconf32 {
319 319
320static int dev_ifname32(unsigned int fd, unsigned int cmd, unsigned long arg) 320static int dev_ifname32(unsigned int fd, unsigned int cmd, unsigned long arg)
321{ 321{
322 struct net_device *dev; 322 struct ifreq __user *uifr;
323 struct ifreq32 ifr32;
324 int err; 323 int err;
325 324
326 if (copy_from_user(&ifr32, compat_ptr(arg), sizeof(ifr32))) 325 uifr = compat_alloc_user_space(sizeof(struct ifreq));
326 if (copy_in_user(uifr, compat_ptr(arg), sizeof(struct ifreq32)));
327 return -EFAULT; 327 return -EFAULT;
328 328
329 dev = dev_get_by_index(ifr32.ifr_ifindex); 329 err = sys_ioctl(fd, SIOCGIFNAME, (unsigned long)uifr);
330 if (!dev) 330 if (err)
331 return -ENODEV; 331 return err;
332 332
333 strlcpy(ifr32.ifr_name, dev->name, sizeof(ifr32.ifr_name)); 333 if (copy_in_user(compat_ptr(arg), uifr, sizeof(struct ifreq32)))
334 dev_put(dev); 334 return -EFAULT;
335 335
336 err = copy_to_user(compat_ptr(arg), &ifr32, sizeof(ifr32)); 336 return 0;
337 return (err ? -EFAULT : 0);
338} 337}
339 338
340static int dev_ifconf(unsigned int fd, unsigned int cmd, unsigned long arg) 339static int dev_ifconf(unsigned int fd, unsigned int cmd, unsigned long arg)
diff --git a/fs/ecryptfs/netlink.c b/fs/ecryptfs/netlink.c
index fe9186312d7c..9aa345121e09 100644
--- a/fs/ecryptfs/netlink.c
+++ b/fs/ecryptfs/netlink.c
@@ -165,22 +165,10 @@ static int ecryptfs_process_nl_quit(struct sk_buff *skb)
165 * it to its desired netlink context element and wake up the process 165 * it to its desired netlink context element and wake up the process
166 * that is waiting for a response. 166 * that is waiting for a response.
167 */ 167 */
168static void ecryptfs_receive_nl_message(struct sock *sk, int len) 168static void ecryptfs_receive_nl_message(struct sk_buff *skb)
169{ 169{
170 struct sk_buff *skb;
171 struct nlmsghdr *nlh; 170 struct nlmsghdr *nlh;
172 int rc = 0; /* skb_recv_datagram requires this */
173 171
174receive:
175 skb = skb_recv_datagram(sk, 0, 0, &rc);
176 if (rc == -EINTR)
177 goto receive;
178 else if (rc < 0) {
179 ecryptfs_printk(KERN_ERR, "Error occurred while "
180 "receiving eCryptfs netlink message; "
181 "rc = [%d]\n", rc);
182 return;
183 }
184 nlh = nlmsg_hdr(skb); 172 nlh = nlmsg_hdr(skb);
185 if (!NLMSG_OK(nlh, skb->len)) { 173 if (!NLMSG_OK(nlh, skb->len)) {
186 ecryptfs_printk(KERN_ERR, "Received corrupt netlink " 174 ecryptfs_printk(KERN_ERR, "Received corrupt netlink "
@@ -227,7 +215,7 @@ int ecryptfs_init_netlink(void)
227{ 215{
228 int rc; 216 int rc;
229 217
230 ecryptfs_nl_sock = netlink_kernel_create(NETLINK_ECRYPTFS, 0, 218 ecryptfs_nl_sock = netlink_kernel_create(&init_net, NETLINK_ECRYPTFS, 0,
231 ecryptfs_receive_nl_message, 219 ecryptfs_receive_nl_message,
232 NULL, THIS_MODULE); 220 NULL, THIS_MODULE);
233 if (!ecryptfs_nl_sock) { 221 if (!ecryptfs_nl_sock) {
diff --git a/fs/proc/Makefile b/fs/proc/Makefile
index bce38e3f06cb..ebaba0213546 100644
--- a/fs/proc/Makefile
+++ b/fs/proc/Makefile
@@ -11,6 +11,7 @@ proc-y += inode.o root.o base.o generic.o array.o \
11 proc_tty.o proc_misc.o 11 proc_tty.o proc_misc.o
12 12
13proc-$(CONFIG_PROC_SYSCTL) += proc_sysctl.o 13proc-$(CONFIG_PROC_SYSCTL) += proc_sysctl.o
14proc-$(CONFIG_NET) += proc_net.o
14proc-$(CONFIG_PROC_KCORE) += kcore.o 15proc-$(CONFIG_PROC_KCORE) += kcore.o
15proc-$(CONFIG_PROC_VMCORE) += vmcore.o 16proc-$(CONFIG_PROC_VMCORE) += vmcore.o
16proc-$(CONFIG_PROC_DEVICETREE) += proc_devtree.o 17proc-$(CONFIG_PROC_DEVICETREE) += proc_devtree.o
diff --git a/fs/proc/internal.h b/fs/proc/internal.h
index b215c3524fa6..1820eb2ef762 100644
--- a/fs/proc/internal.h
+++ b/fs/proc/internal.h
@@ -16,6 +16,11 @@ extern int proc_sys_init(void);
16#else 16#else
17static inline void proc_sys_init(void) { } 17static inline void proc_sys_init(void) { }
18#endif 18#endif
19#ifdef CONFIG_NET
20extern int proc_net_init(void);
21#else
22static inline int proc_net_init(void) { return 0; }
23#endif
19 24
20struct vmalloc_info { 25struct vmalloc_info {
21 unsigned long used; 26 unsigned long used;
diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
new file mode 100644
index 000000000000..2e91fb756e9a
--- /dev/null
+++ b/fs/proc/proc_net.c
@@ -0,0 +1,200 @@
1/*
2 * linux/fs/proc/net.c
3 *
4 * Copyright (C) 2007
5 *
6 * Author: Eric Biederman <ebiederm@xmission.com>
7 *
8 * proc net directory handling functions
9 */
10
11#include <asm/uaccess.h>
12
13#include <linux/errno.h>
14#include <linux/time.h>
15#include <linux/proc_fs.h>
16#include <linux/stat.h>
17#include <linux/init.h>
18#include <linux/sched.h>
19#include <linux/module.h>
20#include <linux/bitops.h>
21#include <linux/smp_lock.h>
22#include <linux/mount.h>
23#include <linux/nsproxy.h>
24#include <net/net_namespace.h>
25
26#include "internal.h"
27
28
29struct proc_dir_entry *proc_net_create(struct net *net,
30 const char *name, mode_t mode, get_info_t *get_info)
31{
32 return create_proc_info_entry(name,mode, net->proc_net, get_info);
33}
34EXPORT_SYMBOL_GPL(proc_net_create);
35
36struct proc_dir_entry *proc_net_fops_create(struct net *net,
37 const char *name, mode_t mode, const struct file_operations *fops)
38{
39 struct proc_dir_entry *res;
40
41 res = create_proc_entry(name, mode, net->proc_net);
42 if (res)
43 res->proc_fops = fops;
44 return res;
45}
46EXPORT_SYMBOL_GPL(proc_net_fops_create);
47
48void proc_net_remove(struct net *net, const char *name)
49{
50 remove_proc_entry(name, net->proc_net);
51}
52EXPORT_SYMBOL_GPL(proc_net_remove);
53
54struct net *get_proc_net(const struct inode *inode)
55{
56 return maybe_get_net(PDE_NET(PDE(inode)));
57}
58EXPORT_SYMBOL_GPL(get_proc_net);
59
60static struct proc_dir_entry *proc_net_shadow;
61
62static struct dentry *proc_net_shadow_dentry(struct dentry *parent,
63 struct proc_dir_entry *de)
64{
65 struct dentry *shadow = NULL;
66 struct inode *inode;
67 if (!de)
68 goto out;
69 de_get(de);
70 inode = proc_get_inode(parent->d_inode->i_sb, de->low_ino, de);
71 if (!inode)
72 goto out_de_put;
73 shadow = d_alloc_name(parent, de->name);
74 if (!shadow)
75 goto out_iput;
76 shadow->d_op = parent->d_op; /* proc_dentry_operations */
77 d_instantiate(shadow, inode);
78out:
79 return shadow;
80out_iput:
81 iput(inode);
82out_de_put:
83 de_put(de);
84 goto out;
85}
86
87static void *proc_net_follow_link(struct dentry *parent, struct nameidata *nd)
88{
89 struct net *net = current->nsproxy->net_ns;
90 struct dentry *shadow;
91 shadow = proc_net_shadow_dentry(parent, net->proc_net);
92 if (!shadow)
93 return ERR_PTR(-ENOENT);
94
95 dput(nd->dentry);
96 /* My dentry count is 1 and that should be enough as the
97 * shadow dentry is thrown away immediately.
98 */
99 nd->dentry = shadow;
100 return NULL;
101}
102
103static struct dentry *proc_net_lookup(struct inode *dir, struct dentry *dentry,
104 struct nameidata *nd)
105{
106 struct net *net = current->nsproxy->net_ns;
107 struct dentry *shadow;
108
109 shadow = proc_net_shadow_dentry(nd->dentry, net->proc_net);
110 if (!shadow)
111 return ERR_PTR(-ENOENT);
112
113 dput(nd->dentry);
114 nd->dentry = shadow;
115
116 return shadow->d_inode->i_op->lookup(shadow->d_inode, dentry, nd);
117}
118
119static int proc_net_setattr(struct dentry *dentry, struct iattr *iattr)
120{
121 struct net *net = current->nsproxy->net_ns;
122 struct dentry *shadow;
123 int ret;
124
125 shadow = proc_net_shadow_dentry(dentry->d_parent, net->proc_net);
126 if (!shadow)
127 return -ENOENT;
128 ret = shadow->d_inode->i_op->setattr(shadow, iattr);
129 dput(shadow);
130 return ret;
131}
132
133static const struct file_operations proc_net_dir_operations = {
134 .read = generic_read_dir,
135};
136
137static struct inode_operations proc_net_dir_inode_operations = {
138 .follow_link = proc_net_follow_link,
139 .lookup = proc_net_lookup,
140 .setattr = proc_net_setattr,
141};
142
143static __net_init int proc_net_ns_init(struct net *net)
144{
145 struct proc_dir_entry *root, *netd, *net_statd;
146 int err;
147
148 err = -ENOMEM;
149 root = kzalloc(sizeof(*root), GFP_KERNEL);
150 if (!root)
151 goto out;
152
153 err = -EEXIST;
154 netd = proc_mkdir("net", root);
155 if (!netd)
156 goto free_root;
157
158 err = -EEXIST;
159 net_statd = proc_mkdir("stat", netd);
160 if (!net_statd)
161 goto free_net;
162
163 root->data = net;
164 netd->data = net;
165 net_statd->data = net;
166
167 net->proc_net_root = root;
168 net->proc_net = netd;
169 net->proc_net_stat = net_statd;
170 err = 0;
171
172out:
173 return err;
174free_net:
175 remove_proc_entry("net", root);
176free_root:
177 kfree(root);
178 goto out;
179}
180
181static __net_exit void proc_net_ns_exit(struct net *net)
182{
183 remove_proc_entry("stat", net->proc_net);
184 remove_proc_entry("net", net->proc_net_root);
185 kfree(net->proc_net_root);
186}
187
188struct pernet_operations __net_initdata proc_net_ns_ops = {
189 .init = proc_net_ns_init,
190 .exit = proc_net_ns_exit,
191};
192
193int __init proc_net_init(void)
194{
195 proc_net_shadow = proc_mkdir("net", NULL);
196 proc_net_shadow->proc_iops = &proc_net_dir_inode_operations;
197 proc_net_shadow->proc_fops = &proc_net_dir_operations;
198
199 return register_pernet_subsys(&proc_net_ns_ops);
200}
diff --git a/fs/proc/root.c b/fs/proc/root.c
index 41f17037f738..cf3046638b09 100644
--- a/fs/proc/root.c
+++ b/fs/proc/root.c
@@ -21,7 +21,7 @@
21 21
22#include "internal.h" 22#include "internal.h"
23 23
24struct proc_dir_entry *proc_net, *proc_net_stat, *proc_bus, *proc_root_fs, *proc_root_driver; 24struct proc_dir_entry *proc_bus, *proc_root_fs, *proc_root_driver;
25 25
26static int proc_get_sb(struct file_system_type *fs_type, 26static int proc_get_sb(struct file_system_type *fs_type,
27 int flags, const char *dev_name, void *data, struct vfsmount *mnt) 27 int flags, const char *dev_name, void *data, struct vfsmount *mnt)
@@ -61,8 +61,8 @@ void __init proc_root_init(void)
61 return; 61 return;
62 } 62 }
63 proc_misc_init(); 63 proc_misc_init();
64 proc_net = proc_mkdir("net", NULL); 64
65 proc_net_stat = proc_mkdir("net/stat", NULL); 65 proc_net_init();
66 66
67#ifdef CONFIG_SYSVIPC 67#ifdef CONFIG_SYSVIPC
68 proc_mkdir("sysvipc", NULL); 68 proc_mkdir("sysvipc", NULL);
@@ -159,7 +159,5 @@ EXPORT_SYMBOL(create_proc_entry);
159EXPORT_SYMBOL(remove_proc_entry); 159EXPORT_SYMBOL(remove_proc_entry);
160EXPORT_SYMBOL(proc_root); 160EXPORT_SYMBOL(proc_root);
161EXPORT_SYMBOL(proc_root_fs); 161EXPORT_SYMBOL(proc_root_fs);
162EXPORT_SYMBOL(proc_net);
163EXPORT_SYMBOL(proc_net_stat);
164EXPORT_SYMBOL(proc_bus); 162EXPORT_SYMBOL(proc_bus);
165EXPORT_SYMBOL(proc_root_driver); 163EXPORT_SYMBOL(proc_root_driver);
diff --git a/fs/seq_file.c b/fs/seq_file.c
index bbb19be260ce..ca71c115bdaa 100644
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -429,6 +429,39 @@ int seq_release_private(struct inode *inode, struct file *file)
429} 429}
430EXPORT_SYMBOL(seq_release_private); 430EXPORT_SYMBOL(seq_release_private);
431 431
432void *__seq_open_private(struct file *f, const struct seq_operations *ops,
433 int psize)
434{
435 int rc;
436 void *private;
437 struct seq_file *seq;
438
439 private = kzalloc(psize, GFP_KERNEL);
440 if (private == NULL)
441 goto out;
442
443 rc = seq_open(f, ops);
444 if (rc < 0)
445 goto out_free;
446
447 seq = f->private_data;
448 seq->private = private;
449 return private;
450
451out_free:
452 kfree(private);
453out:
454 return NULL;
455}
456EXPORT_SYMBOL(__seq_open_private);
457
458int seq_open_private(struct file *filp, const struct seq_operations *ops,
459 int psize)
460{
461 return __seq_open_private(filp, ops, psize) ? 0 : -ENOMEM;
462}
463EXPORT_SYMBOL(seq_open_private);
464
432int seq_putc(struct seq_file *m, char c) 465int seq_putc(struct seq_file *m, char c)
433{ 466{
434 if (m->count < m->size) { 467 if (m->count < m->size) {