diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/core/dev.c | 28 | ||||
-rw-r--r-- | net/core/dev_mcast.c | 26 | ||||
-rw-r--r-- | net/netlink/af_netlink.c | 33 | ||||
-rw-r--r-- | net/packet/af_packet.c | 26 | ||||
-rw-r--r-- | net/unix/af_unix.c | 31 | ||||
-rw-r--r-- | net/wireless/wext.c | 24 |
6 files changed, 29 insertions, 139 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index 0879f52115eb..d0e23d8310ff 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -2364,7 +2364,7 @@ static int dev_ifconf(struct net *net, char __user *arg) | |||
2364 | */ | 2364 | */ |
2365 | void *dev_seq_start(struct seq_file *seq, loff_t *pos) | 2365 | void *dev_seq_start(struct seq_file *seq, loff_t *pos) |
2366 | { | 2366 | { |
2367 | struct net *net = seq->private; | 2367 | struct net *net = seq_file_net(seq); |
2368 | loff_t off; | 2368 | loff_t off; |
2369 | struct net_device *dev; | 2369 | struct net_device *dev; |
2370 | 2370 | ||
@@ -2382,7 +2382,7 @@ void *dev_seq_start(struct seq_file *seq, loff_t *pos) | |||
2382 | 2382 | ||
2383 | void *dev_seq_next(struct seq_file *seq, void *v, loff_t *pos) | 2383 | void *dev_seq_next(struct seq_file *seq, void *v, loff_t *pos) |
2384 | { | 2384 | { |
2385 | struct net *net = seq->private; | 2385 | struct net *net = seq_file_net(seq); |
2386 | ++*pos; | 2386 | ++*pos; |
2387 | return v == SEQ_START_TOKEN ? | 2387 | return v == SEQ_START_TOKEN ? |
2388 | first_net_device(net) : next_net_device((struct net_device *)v); | 2388 | first_net_device(net) : next_net_device((struct net_device *)v); |
@@ -2481,26 +2481,8 @@ static const struct seq_operations dev_seq_ops = { | |||
2481 | 2481 | ||
2482 | static int dev_seq_open(struct inode *inode, struct file *file) | 2482 | static int dev_seq_open(struct inode *inode, struct file *file) |
2483 | { | 2483 | { |
2484 | struct seq_file *seq; | 2484 | return seq_open_net(inode, file, &dev_seq_ops, |
2485 | int res; | 2485 | sizeof(struct seq_net_private)); |
2486 | res = seq_open(file, &dev_seq_ops); | ||
2487 | if (!res) { | ||
2488 | seq = file->private_data; | ||
2489 | seq->private = get_proc_net(inode); | ||
2490 | if (!seq->private) { | ||
2491 | seq_release(inode, file); | ||
2492 | res = -ENXIO; | ||
2493 | } | ||
2494 | } | ||
2495 | return res; | ||
2496 | } | ||
2497 | |||
2498 | static int dev_seq_release(struct inode *inode, struct file *file) | ||
2499 | { | ||
2500 | struct seq_file *seq = file->private_data; | ||
2501 | struct net *net = seq->private; | ||
2502 | put_net(net); | ||
2503 | return seq_release(inode, file); | ||
2504 | } | 2486 | } |
2505 | 2487 | ||
2506 | static const struct file_operations dev_seq_fops = { | 2488 | static const struct file_operations dev_seq_fops = { |
@@ -2508,7 +2490,7 @@ static const struct file_operations dev_seq_fops = { | |||
2508 | .open = dev_seq_open, | 2490 | .open = dev_seq_open, |
2509 | .read = seq_read, | 2491 | .read = seq_read, |
2510 | .llseek = seq_lseek, | 2492 | .llseek = seq_lseek, |
2511 | .release = dev_seq_release, | 2493 | .release = seq_release_net, |
2512 | }; | 2494 | }; |
2513 | 2495 | ||
2514 | static const struct seq_operations softnet_seq_ops = { | 2496 | static const struct seq_operations softnet_seq_ops = { |
diff --git a/net/core/dev_mcast.c b/net/core/dev_mcast.c index 69fff16ece10..63f0b33d7ced 100644 --- a/net/core/dev_mcast.c +++ b/net/core/dev_mcast.c | |||
@@ -187,7 +187,7 @@ EXPORT_SYMBOL(dev_mc_unsync); | |||
187 | #ifdef CONFIG_PROC_FS | 187 | #ifdef CONFIG_PROC_FS |
188 | static void *dev_mc_seq_start(struct seq_file *seq, loff_t *pos) | 188 | static void *dev_mc_seq_start(struct seq_file *seq, loff_t *pos) |
189 | { | 189 | { |
190 | struct net *net = seq->private; | 190 | struct net *net = seq_file_net(seq); |
191 | struct net_device *dev; | 191 | struct net_device *dev; |
192 | loff_t off = 0; | 192 | loff_t off = 0; |
193 | 193 | ||
@@ -241,26 +241,8 @@ static const struct seq_operations dev_mc_seq_ops = { | |||
241 | 241 | ||
242 | static int dev_mc_seq_open(struct inode *inode, struct file *file) | 242 | static int dev_mc_seq_open(struct inode *inode, struct file *file) |
243 | { | 243 | { |
244 | struct seq_file *seq; | 244 | return seq_open_net(inode, file, &dev_mc_seq_ops, |
245 | int res; | 245 | sizeof(struct seq_net_private)); |
246 | res = seq_open(file, &dev_mc_seq_ops); | ||
247 | if (!res) { | ||
248 | seq = file->private_data; | ||
249 | seq->private = get_proc_net(inode); | ||
250 | if (!seq->private) { | ||
251 | seq_release(inode, file); | ||
252 | res = -ENXIO; | ||
253 | } | ||
254 | } | ||
255 | return res; | ||
256 | } | ||
257 | |||
258 | static int dev_mc_seq_release(struct inode *inode, struct file *file) | ||
259 | { | ||
260 | struct seq_file *seq = file->private_data; | ||
261 | struct net *net = seq->private; | ||
262 | put_net(net); | ||
263 | return seq_release(inode, file); | ||
264 | } | 246 | } |
265 | 247 | ||
266 | static const struct file_operations dev_mc_seq_fops = { | 248 | static const struct file_operations dev_mc_seq_fops = { |
@@ -268,7 +250,7 @@ static const struct file_operations dev_mc_seq_fops = { | |||
268 | .open = dev_mc_seq_open, | 250 | .open = dev_mc_seq_open, |
269 | .read = seq_read, | 251 | .read = seq_read, |
270 | .llseek = seq_lseek, | 252 | .llseek = seq_lseek, |
271 | .release = dev_mc_seq_release, | 253 | .release = seq_release_net, |
272 | }; | 254 | }; |
273 | 255 | ||
274 | #endif | 256 | #endif |
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index de3988ba1f46..1518244ffad9 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c | |||
@@ -1681,7 +1681,7 @@ int nlmsg_notify(struct sock *sk, struct sk_buff *skb, u32 pid, | |||
1681 | 1681 | ||
1682 | #ifdef CONFIG_PROC_FS | 1682 | #ifdef CONFIG_PROC_FS |
1683 | struct nl_seq_iter { | 1683 | struct nl_seq_iter { |
1684 | struct net *net; | 1684 | struct seq_net_private p; |
1685 | int link; | 1685 | int link; |
1686 | int hash_idx; | 1686 | int hash_idx; |
1687 | }; | 1687 | }; |
@@ -1699,7 +1699,7 @@ static struct sock *netlink_seq_socket_idx(struct seq_file *seq, loff_t pos) | |||
1699 | 1699 | ||
1700 | for (j = 0; j <= hash->mask; j++) { | 1700 | for (j = 0; j <= hash->mask; j++) { |
1701 | sk_for_each(s, node, &hash->table[j]) { | 1701 | sk_for_each(s, node, &hash->table[j]) { |
1702 | if (iter->net != s->sk_net) | 1702 | if (iter->p.net != s->sk_net) |
1703 | continue; | 1703 | continue; |
1704 | if (off == pos) { | 1704 | if (off == pos) { |
1705 | iter->link = i; | 1705 | iter->link = i; |
@@ -1734,7 +1734,7 @@ static void *netlink_seq_next(struct seq_file *seq, void *v, loff_t *pos) | |||
1734 | s = v; | 1734 | s = v; |
1735 | do { | 1735 | do { |
1736 | s = sk_next(s); | 1736 | s = sk_next(s); |
1737 | } while (s && (iter->net != s->sk_net)); | 1737 | } while (s && (iter->p.net != s->sk_net)); |
1738 | if (s) | 1738 | if (s) |
1739 | return s; | 1739 | return s; |
1740 | 1740 | ||
@@ -1746,7 +1746,7 @@ static void *netlink_seq_next(struct seq_file *seq, void *v, loff_t *pos) | |||
1746 | 1746 | ||
1747 | for (; j <= hash->mask; j++) { | 1747 | for (; j <= hash->mask; j++) { |
1748 | s = sk_head(&hash->table[j]); | 1748 | s = sk_head(&hash->table[j]); |
1749 | while (s && (iter->net != s->sk_net)) | 1749 | while (s && (iter->p.net != s->sk_net)) |
1750 | s = sk_next(s); | 1750 | s = sk_next(s); |
1751 | if (s) { | 1751 | if (s) { |
1752 | iter->link = i; | 1752 | iter->link = i; |
@@ -1802,27 +1802,8 @@ static const struct seq_operations netlink_seq_ops = { | |||
1802 | 1802 | ||
1803 | static int netlink_seq_open(struct inode *inode, struct file *file) | 1803 | static int netlink_seq_open(struct inode *inode, struct file *file) |
1804 | { | 1804 | { |
1805 | struct nl_seq_iter *iter; | 1805 | return seq_open_net(inode, file, &netlink_seq_ops, |
1806 | 1806 | sizeof(struct nl_seq_iter)); | |
1807 | iter = __seq_open_private(file, &netlink_seq_ops, sizeof(*iter)); | ||
1808 | if (!iter) | ||
1809 | return -ENOMEM; | ||
1810 | |||
1811 | iter->net = get_proc_net(inode); | ||
1812 | if (!iter->net) { | ||
1813 | seq_release_private(inode, file); | ||
1814 | return -ENXIO; | ||
1815 | } | ||
1816 | |||
1817 | return 0; | ||
1818 | } | ||
1819 | |||
1820 | static int netlink_seq_release(struct inode *inode, struct file *file) | ||
1821 | { | ||
1822 | struct seq_file *seq = file->private_data; | ||
1823 | struct nl_seq_iter *iter = seq->private; | ||
1824 | put_net(iter->net); | ||
1825 | return seq_release_private(inode, file); | ||
1826 | } | 1807 | } |
1827 | 1808 | ||
1828 | static const struct file_operations netlink_seq_fops = { | 1809 | static const struct file_operations netlink_seq_fops = { |
@@ -1830,7 +1811,7 @@ static const struct file_operations netlink_seq_fops = { | |||
1830 | .open = netlink_seq_open, | 1811 | .open = netlink_seq_open, |
1831 | .read = seq_read, | 1812 | .read = seq_read, |
1832 | .llseek = seq_lseek, | 1813 | .llseek = seq_lseek, |
1833 | .release = netlink_seq_release, | 1814 | .release = seq_release_net, |
1834 | }; | 1815 | }; |
1835 | 1816 | ||
1836 | #endif | 1817 | #endif |
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 45e3cbcb2763..ace29f1c4c5b 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c | |||
@@ -1871,7 +1871,7 @@ static inline struct sock *packet_seq_idx(struct net *net, loff_t off) | |||
1871 | 1871 | ||
1872 | static void *packet_seq_start(struct seq_file *seq, loff_t *pos) | 1872 | static void *packet_seq_start(struct seq_file *seq, loff_t *pos) |
1873 | { | 1873 | { |
1874 | struct net *net = seq->private; | 1874 | struct net *net = seq_file_net(seq); |
1875 | read_lock(&net->packet_sklist_lock); | 1875 | read_lock(&net->packet_sklist_lock); |
1876 | return *pos ? packet_seq_idx(net, *pos - 1) : SEQ_START_TOKEN; | 1876 | return *pos ? packet_seq_idx(net, *pos - 1) : SEQ_START_TOKEN; |
1877 | } | 1877 | } |
@@ -1924,26 +1924,8 @@ static const struct seq_operations packet_seq_ops = { | |||
1924 | 1924 | ||
1925 | static int packet_seq_open(struct inode *inode, struct file *file) | 1925 | static int packet_seq_open(struct inode *inode, struct file *file) |
1926 | { | 1926 | { |
1927 | struct seq_file *seq; | 1927 | return seq_open_net(inode, file, &packet_seq_ops, |
1928 | int res; | 1928 | sizeof(struct seq_net_private)); |
1929 | res = seq_open(file, &packet_seq_ops); | ||
1930 | if (!res) { | ||
1931 | seq = file->private_data; | ||
1932 | seq->private = get_proc_net(inode); | ||
1933 | if (!seq->private) { | ||
1934 | seq_release(inode, file); | ||
1935 | res = -ENXIO; | ||
1936 | } | ||
1937 | } | ||
1938 | return res; | ||
1939 | } | ||
1940 | |||
1941 | static int packet_seq_release(struct inode *inode, struct file *file) | ||
1942 | { | ||
1943 | struct seq_file *seq= file->private_data; | ||
1944 | struct net *net = seq->private; | ||
1945 | put_net(net); | ||
1946 | return seq_release(inode, file); | ||
1947 | } | 1929 | } |
1948 | 1930 | ||
1949 | static const struct file_operations packet_seq_fops = { | 1931 | static const struct file_operations packet_seq_fops = { |
@@ -1951,7 +1933,7 @@ static const struct file_operations packet_seq_fops = { | |||
1951 | .open = packet_seq_open, | 1933 | .open = packet_seq_open, |
1952 | .read = seq_read, | 1934 | .read = seq_read, |
1953 | .llseek = seq_lseek, | 1935 | .llseek = seq_lseek, |
1954 | .release = packet_seq_release, | 1936 | .release = seq_release_net, |
1955 | }; | 1937 | }; |
1956 | 1938 | ||
1957 | #endif | 1939 | #endif |
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index ecad42b72ad6..eacddb21a9b4 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c | |||
@@ -2018,7 +2018,7 @@ static unsigned int unix_poll(struct file * file, struct socket *sock, poll_tabl | |||
2018 | 2018 | ||
2019 | #ifdef CONFIG_PROC_FS | 2019 | #ifdef CONFIG_PROC_FS |
2020 | struct unix_iter_state { | 2020 | struct unix_iter_state { |
2021 | struct net *net; | 2021 | struct seq_net_private p; |
2022 | int i; | 2022 | int i; |
2023 | }; | 2023 | }; |
2024 | static struct sock *unix_seq_idx(struct unix_iter_state *iter, loff_t pos) | 2024 | static struct sock *unix_seq_idx(struct unix_iter_state *iter, loff_t pos) |
@@ -2027,7 +2027,7 @@ static struct sock *unix_seq_idx(struct unix_iter_state *iter, loff_t pos) | |||
2027 | struct sock *s; | 2027 | struct sock *s; |
2028 | 2028 | ||
2029 | for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) { | 2029 | for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) { |
2030 | if (s->sk_net != iter->net) | 2030 | if (s->sk_net != iter->p.net) |
2031 | continue; | 2031 | continue; |
2032 | if (off == pos) | 2032 | if (off == pos) |
2033 | return s; | 2033 | return s; |
@@ -2054,7 +2054,7 @@ static void *unix_seq_next(struct seq_file *seq, void *v, loff_t *pos) | |||
2054 | sk = first_unix_socket(&iter->i); | 2054 | sk = first_unix_socket(&iter->i); |
2055 | else | 2055 | else |
2056 | sk = next_unix_socket(&iter->i, sk); | 2056 | sk = next_unix_socket(&iter->i, sk); |
2057 | while (sk && (sk->sk_net != iter->net)) | 2057 | while (sk && (sk->sk_net != iter->p.net)) |
2058 | sk = next_unix_socket(&iter->i, sk); | 2058 | sk = next_unix_socket(&iter->i, sk); |
2059 | return sk; | 2059 | return sk; |
2060 | } | 2060 | } |
@@ -2118,27 +2118,8 @@ static const struct seq_operations unix_seq_ops = { | |||
2118 | 2118 | ||
2119 | static int unix_seq_open(struct inode *inode, struct file *file) | 2119 | static int unix_seq_open(struct inode *inode, struct file *file) |
2120 | { | 2120 | { |
2121 | struct unix_iter_state *it; | 2121 | return seq_open_net(inode, file, &unix_seq_ops, |
2122 | 2122 | sizeof(struct unix_iter_state)); | |
2123 | it = __seq_open_private(file, &unix_seq_ops, | ||
2124 | sizeof(struct unix_iter_state)); | ||
2125 | if (it == NULL) | ||
2126 | return -ENOMEM; | ||
2127 | |||
2128 | it->net = get_proc_net(inode); | ||
2129 | if (it->net == NULL) { | ||
2130 | seq_release_private(inode, file); | ||
2131 | return -ENXIO; | ||
2132 | } | ||
2133 | return 0; | ||
2134 | } | ||
2135 | |||
2136 | static int unix_seq_release(struct inode *inode, struct file *file) | ||
2137 | { | ||
2138 | struct seq_file *seq = file->private_data; | ||
2139 | struct unix_iter_state *iter = seq->private; | ||
2140 | put_net(iter->net); | ||
2141 | return seq_release_private(inode, file); | ||
2142 | } | 2123 | } |
2143 | 2124 | ||
2144 | static const struct file_operations unix_seq_fops = { | 2125 | static const struct file_operations unix_seq_fops = { |
@@ -2146,7 +2127,7 @@ static const struct file_operations unix_seq_fops = { | |||
2146 | .open = unix_seq_open, | 2127 | .open = unix_seq_open, |
2147 | .read = seq_read, | 2128 | .read = seq_read, |
2148 | .llseek = seq_lseek, | 2129 | .llseek = seq_lseek, |
2149 | .release = unix_seq_release, | 2130 | .release = seq_release_net, |
2150 | }; | 2131 | }; |
2151 | 2132 | ||
2152 | #endif | 2133 | #endif |
diff --git a/net/wireless/wext.c b/net/wireless/wext.c index db03ed5ce055..1e4cf615f878 100644 --- a/net/wireless/wext.c +++ b/net/wireless/wext.c | |||
@@ -673,26 +673,8 @@ static const struct seq_operations wireless_seq_ops = { | |||
673 | 673 | ||
674 | static int wireless_seq_open(struct inode *inode, struct file *file) | 674 | static int wireless_seq_open(struct inode *inode, struct file *file) |
675 | { | 675 | { |
676 | struct seq_file *seq; | 676 | return seq_open_net(inode, file, &wireless_seq_ops, |
677 | int res; | 677 | sizeof(struct seq_net_private)); |
678 | res = seq_open(file, &wireless_seq_ops); | ||
679 | if (!res) { | ||
680 | seq = file->private_data; | ||
681 | seq->private = get_proc_net(inode); | ||
682 | if (!seq->private) { | ||
683 | seq_release(inode, file); | ||
684 | res = -ENXIO; | ||
685 | } | ||
686 | } | ||
687 | return res; | ||
688 | } | ||
689 | |||
690 | static int wireless_seq_release(struct inode *inode, struct file *file) | ||
691 | { | ||
692 | struct seq_file *seq = file->private_data; | ||
693 | struct net *net = seq->private; | ||
694 | put_net(net); | ||
695 | return seq_release(inode, file); | ||
696 | } | 678 | } |
697 | 679 | ||
698 | static const struct file_operations wireless_seq_fops = { | 680 | static const struct file_operations wireless_seq_fops = { |
@@ -700,7 +682,7 @@ static const struct file_operations wireless_seq_fops = { | |||
700 | .open = wireless_seq_open, | 682 | .open = wireless_seq_open, |
701 | .read = seq_read, | 683 | .read = seq_read, |
702 | .llseek = seq_lseek, | 684 | .llseek = seq_lseek, |
703 | .release = wireless_seq_release, | 685 | .release = seq_release_net, |
704 | }; | 686 | }; |
705 | 687 | ||
706 | int wext_proc_init(struct net *net) | 688 | int wext_proc_init(struct net *net) |