aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>2008-03-25 13:36:06 -0400
committerYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>2008-03-25 15:39:56 -0400
commit1218854afa6f659be90b748cf1bc7badee954a35 (patch)
tree78b83e3941fa7e5a03c04e2e4f6ddb1a08ea38a0
parent3b1e0a655f8eba44ab1ee2a1068d169ccfb853b9 (diff)
[NET] NETNS: Omit seq_net_private->net without CONFIG_NET_NS.
Without CONFIG_NET_NS, no namespace other than &init_net exists, no need to store net in seq_net_private. Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
-rw-r--r--fs/proc/proc_net.c6
-rw-r--r--include/linux/seq_file.h7
-rw-r--r--net/core/neighbour.c8
-rw-r--r--net/ipv4/fib_hash.c5
-rw-r--r--net/ipv4/fib_trie.c13
-rw-r--r--net/ipv4/raw.c4
-rw-r--r--net/ipv4/route.c29
-rw-r--r--net/ipv6/addrconf.c4
-rw-r--r--net/ipv6/mcast.c4
-rw-r--r--net/netfilter/x_tables.c4
-rw-r--r--net/netlink/af_netlink.c6
-rw-r--r--net/unix/af_unix.c10
12 files changed, 53 insertions, 47 deletions
diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
index 4caa5f774fb7..13cd7835d0df 100644
--- a/fs/proc/proc_net.c
+++ b/fs/proc/proc_net.c
@@ -44,7 +44,9 @@ int seq_open_net(struct inode *ino, struct file *f,
44 put_net(net); 44 put_net(net);
45 return -ENOMEM; 45 return -ENOMEM;
46 } 46 }
47#ifdef CONFIG_NET_NS
47 p->net = net; 48 p->net = net;
49#endif
48 return 0; 50 return 0;
49} 51}
50EXPORT_SYMBOL_GPL(seq_open_net); 52EXPORT_SYMBOL_GPL(seq_open_net);
@@ -52,12 +54,10 @@ EXPORT_SYMBOL_GPL(seq_open_net);
52int seq_release_net(struct inode *ino, struct file *f) 54int seq_release_net(struct inode *ino, struct file *f)
53{ 55{
54 struct seq_file *seq; 56 struct seq_file *seq;
55 struct seq_net_private *p;
56 57
57 seq = f->private_data; 58 seq = f->private_data;
58 p = seq->private;
59 59
60 put_net(p->net); 60 put_net(seq_file_net(seq));
61 seq_release_private(ino, f); 61 seq_release_private(ino, f);
62 return 0; 62 return 0;
63} 63}
diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
index 67c2563961f3..d870a8253769 100644
--- a/include/linux/seq_file.h
+++ b/include/linux/seq_file.h
@@ -5,6 +5,7 @@
5#include <linux/types.h> 5#include <linux/types.h>
6#include <linux/string.h> 6#include <linux/string.h>
7#include <linux/mutex.h> 7#include <linux/mutex.h>
8#include <net/net_namespace.h>
8 9
9struct seq_operations; 10struct seq_operations;
10struct file; 11struct file;
@@ -64,7 +65,9 @@ extern struct list_head *seq_list_next(void *v, struct list_head *head,
64 65
65struct net; 66struct net;
66struct seq_net_private { 67struct seq_net_private {
68#ifdef CONFIG_NET_NS
67 struct net *net; 69 struct net *net;
70#endif
68}; 71};
69 72
70int seq_open_net(struct inode *, struct file *, 73int seq_open_net(struct inode *, struct file *,
@@ -72,7 +75,11 @@ int seq_open_net(struct inode *, struct file *,
72int seq_release_net(struct inode *, struct file *); 75int seq_release_net(struct inode *, struct file *);
73static inline struct net *seq_file_net(struct seq_file *seq) 76static inline struct net *seq_file_net(struct seq_file *seq)
74{ 77{
78#ifdef CONFIG_NET_NS
75 return ((struct seq_net_private *)seq->private)->net; 79 return ((struct seq_net_private *)seq->private)->net;
80#else
81 return &init_net;
82#endif
76} 83}
77 84
78#endif 85#endif
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 065fbac7ecd3..b8d491fb4b42 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -2145,7 +2145,7 @@ EXPORT_SYMBOL(__neigh_for_each_release);
2145static struct neighbour *neigh_get_first(struct seq_file *seq) 2145static struct neighbour *neigh_get_first(struct seq_file *seq)
2146{ 2146{
2147 struct neigh_seq_state *state = seq->private; 2147 struct neigh_seq_state *state = seq->private;
2148 struct net *net = state->p.net; 2148 struct net *net = seq_file_net(seq);
2149 struct neigh_table *tbl = state->tbl; 2149 struct neigh_table *tbl = state->tbl;
2150 struct neighbour *n = NULL; 2150 struct neighbour *n = NULL;
2151 int bucket = state->bucket; 2151 int bucket = state->bucket;
@@ -2186,7 +2186,7 @@ static struct neighbour *neigh_get_next(struct seq_file *seq,
2186 loff_t *pos) 2186 loff_t *pos)
2187{ 2187{
2188 struct neigh_seq_state *state = seq->private; 2188 struct neigh_seq_state *state = seq->private;
2189 struct net *net = state->p.net; 2189 struct net *net = seq_file_net(seq);
2190 struct neigh_table *tbl = state->tbl; 2190 struct neigh_table *tbl = state->tbl;
2191 2191
2192 if (state->neigh_sub_iter) { 2192 if (state->neigh_sub_iter) {
@@ -2246,7 +2246,7 @@ static struct neighbour *neigh_get_idx(struct seq_file *seq, loff_t *pos)
2246static struct pneigh_entry *pneigh_get_first(struct seq_file *seq) 2246static struct pneigh_entry *pneigh_get_first(struct seq_file *seq)
2247{ 2247{
2248 struct neigh_seq_state *state = seq->private; 2248 struct neigh_seq_state *state = seq->private;
2249 struct net * net = state->p.net; 2249 struct net *net = seq_file_net(seq);
2250 struct neigh_table *tbl = state->tbl; 2250 struct neigh_table *tbl = state->tbl;
2251 struct pneigh_entry *pn = NULL; 2251 struct pneigh_entry *pn = NULL;
2252 int bucket = state->bucket; 2252 int bucket = state->bucket;
@@ -2269,7 +2269,7 @@ static struct pneigh_entry *pneigh_get_next(struct seq_file *seq,
2269 loff_t *pos) 2269 loff_t *pos)
2270{ 2270{
2271 struct neigh_seq_state *state = seq->private; 2271 struct neigh_seq_state *state = seq->private;
2272 struct net * net = state->p.net; 2272 struct net *net = seq_file_net(seq);
2273 struct neigh_table *tbl = state->tbl; 2273 struct neigh_table *tbl = state->tbl;
2274 2274
2275 pn = pn->next; 2275 pn = pn->next;
diff --git a/net/ipv4/fib_hash.c b/net/ipv4/fib_hash.c
index 8d58d85dfac6..02088deb0461 100644
--- a/net/ipv4/fib_hash.c
+++ b/net/ipv4/fib_hash.c
@@ -821,7 +821,7 @@ static struct fib_alias *fib_get_first(struct seq_file *seq)
821 struct fib_table *main_table; 821 struct fib_table *main_table;
822 struct fn_hash *table; 822 struct fn_hash *table;
823 823
824 main_table = fib_get_table(iter->p.net, RT_TABLE_MAIN); 824 main_table = fib_get_table(seq_file_net(seq), RT_TABLE_MAIN);
825 table = (struct fn_hash *)main_table->tb_data; 825 table = (struct fn_hash *)main_table->tb_data;
826 826
827 iter->bucket = 0; 827 iter->bucket = 0;
@@ -959,11 +959,10 @@ static struct fib_alias *fib_get_idx(struct seq_file *seq, loff_t pos)
959static void *fib_seq_start(struct seq_file *seq, loff_t *pos) 959static void *fib_seq_start(struct seq_file *seq, loff_t *pos)
960 __acquires(fib_hash_lock) 960 __acquires(fib_hash_lock)
961{ 961{
962 struct fib_iter_state *iter = seq->private;
963 void *v = NULL; 962 void *v = NULL;
964 963
965 read_lock(&fib_hash_lock); 964 read_lock(&fib_hash_lock);
966 if (fib_get_table(iter->p.net, RT_TABLE_MAIN)) 965 if (fib_get_table(seq_file_net(seq), RT_TABLE_MAIN))
967 v = *pos ? fib_get_idx(seq, *pos - 1) : SEQ_START_TOKEN; 966 v = *pos ? fib_get_idx(seq, *pos - 1) : SEQ_START_TOKEN;
968 return v; 967 return v;
969} 968}
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index ce6cb34e28e1..9e491e70e855 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -2279,9 +2279,10 @@ static const struct file_operations fib_triestat_fops = {
2279 .release = fib_triestat_seq_release, 2279 .release = fib_triestat_seq_release,
2280}; 2280};
2281 2281
2282static struct node *fib_trie_get_idx(struct fib_trie_iter *iter, loff_t pos) 2282static struct node *fib_trie_get_idx(struct seq_file *seq, loff_t pos)
2283{ 2283{
2284 struct net *net = iter->p.net; 2284 struct fib_trie_iter *iter = seq->private;
2285 struct net *net = seq_file_net(seq);
2285 loff_t idx = 0; 2286 loff_t idx = 0;
2286 unsigned int h; 2287 unsigned int h;
2287 2288
@@ -2309,16 +2310,14 @@ static struct node *fib_trie_get_idx(struct fib_trie_iter *iter, loff_t pos)
2309static void *fib_trie_seq_start(struct seq_file *seq, loff_t *pos) 2310static void *fib_trie_seq_start(struct seq_file *seq, loff_t *pos)
2310 __acquires(RCU) 2311 __acquires(RCU)
2311{ 2312{
2312 struct fib_trie_iter *iter = seq->private;
2313
2314 rcu_read_lock(); 2313 rcu_read_lock();
2315 return fib_trie_get_idx(iter, *pos); 2314 return fib_trie_get_idx(seq, *pos);
2316} 2315}
2317 2316
2318static void *fib_trie_seq_next(struct seq_file *seq, void *v, loff_t *pos) 2317static void *fib_trie_seq_next(struct seq_file *seq, void *v, loff_t *pos)
2319{ 2318{
2320 struct fib_trie_iter *iter = seq->private; 2319 struct fib_trie_iter *iter = seq->private;
2321 struct net *net = iter->p.net; 2320 struct net *net = seq_file_net(seq);
2322 struct fib_table *tb = iter->tb; 2321 struct fib_table *tb = iter->tb;
2323 struct hlist_node *tb_node; 2322 struct hlist_node *tb_node;
2324 unsigned int h; 2323 unsigned int h;
@@ -2513,7 +2512,7 @@ static void *fib_route_seq_start(struct seq_file *seq, loff_t *pos)
2513 struct fib_table *tb; 2512 struct fib_table *tb;
2514 2513
2515 rcu_read_lock(); 2514 rcu_read_lock();
2516 tb = fib_get_table(iter->p.net, RT_TABLE_MAIN); 2515 tb = fib_get_table(seq_file_net(seq), RT_TABLE_MAIN);
2517 if (!tb) 2516 if (!tb)
2518 return NULL; 2517 return NULL;
2519 2518
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index be19a4048d7c..25dc8b38cac3 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -856,7 +856,7 @@ static struct sock *raw_get_first(struct seq_file *seq)
856 struct hlist_node *node; 856 struct hlist_node *node;
857 857
858 sk_for_each(sk, node, &state->h->ht[state->bucket]) 858 sk_for_each(sk, node, &state->h->ht[state->bucket])
859 if (sock_net(sk) == state->p.net) 859 if (sock_net(sk) == seq_file_net(seq))
860 goto found; 860 goto found;
861 } 861 }
862 sk = NULL; 862 sk = NULL;
@@ -872,7 +872,7 @@ static struct sock *raw_get_next(struct seq_file *seq, struct sock *sk)
872 sk = sk_next(sk); 872 sk = sk_next(sk);
873try_again: 873try_again:
874 ; 874 ;
875 } while (sk && sock_net(sk) != state->p.net); 875 } while (sk && sock_net(sk) != seq_file_net(seq));
876 876
877 if (!sk && ++state->bucket < RAW_HTABLE_SIZE) { 877 if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
878 sk = sk_head(&state->h->ht[state->bucket]); 878 sk = sk_head(&state->h->ht[state->bucket]);
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 194f5cca3121..eab8d75e5222 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -276,15 +276,16 @@ struct rt_cache_iter_state {
276 int genid; 276 int genid;
277}; 277};
278 278
279static struct rtable *rt_cache_get_first(struct rt_cache_iter_state *st) 279static struct rtable *rt_cache_get_first(struct seq_file *seq)
280{ 280{
281 struct rt_cache_iter_state *st = seq->private;
281 struct rtable *r = NULL; 282 struct rtable *r = NULL;
282 283
283 for (st->bucket = rt_hash_mask; st->bucket >= 0; --st->bucket) { 284 for (st->bucket = rt_hash_mask; st->bucket >= 0; --st->bucket) {
284 rcu_read_lock_bh(); 285 rcu_read_lock_bh();
285 r = rcu_dereference(rt_hash_table[st->bucket].chain); 286 r = rcu_dereference(rt_hash_table[st->bucket].chain);
286 while (r) { 287 while (r) {
287 if (dev_net(r->u.dst.dev) == st->p.net && 288 if (dev_net(r->u.dst.dev) == seq_file_net(seq) &&
288 r->rt_genid == st->genid) 289 r->rt_genid == st->genid)
289 return r; 290 return r;
290 r = rcu_dereference(r->u.dst.rt_next); 291 r = rcu_dereference(r->u.dst.rt_next);
@@ -294,9 +295,10 @@ static struct rtable *rt_cache_get_first(struct rt_cache_iter_state *st)
294 return r; 295 return r;
295} 296}
296 297
297static struct rtable *__rt_cache_get_next(struct rt_cache_iter_state *st, 298static struct rtable *__rt_cache_get_next(struct seq_file *seq,
298 struct rtable *r) 299 struct rtable *r)
299{ 300{
301 struct rt_cache_iter_state *st = seq->private;
300 r = r->u.dst.rt_next; 302 r = r->u.dst.rt_next;
301 while (!r) { 303 while (!r) {
302 rcu_read_unlock_bh(); 304 rcu_read_unlock_bh();
@@ -308,11 +310,12 @@ static struct rtable *__rt_cache_get_next(struct rt_cache_iter_state *st,
308 return rcu_dereference(r); 310 return rcu_dereference(r);
309} 311}
310 312
311static struct rtable *rt_cache_get_next(struct rt_cache_iter_state *st, 313static struct rtable *rt_cache_get_next(struct seq_file *seq,
312 struct rtable *r) 314 struct rtable *r)
313{ 315{
314 while ((r = __rt_cache_get_next(st, r)) != NULL) { 316 struct rt_cache_iter_state *st = seq->private;
315 if (dev_net(r->u.dst.dev) != st->p.net) 317 while ((r = __rt_cache_get_next(seq, r)) != NULL) {
318 if (dev_net(r->u.dst.dev) != seq_file_net(seq))
316 continue; 319 continue;
317 if (r->rt_genid == st->genid) 320 if (r->rt_genid == st->genid)
318 break; 321 break;
@@ -320,12 +323,12 @@ static struct rtable *rt_cache_get_next(struct rt_cache_iter_state *st,
320 return r; 323 return r;
321} 324}
322 325
323static struct rtable *rt_cache_get_idx(struct rt_cache_iter_state *st, loff_t pos) 326static struct rtable *rt_cache_get_idx(struct seq_file *seq, loff_t pos)
324{ 327{
325 struct rtable *r = rt_cache_get_first(st); 328 struct rtable *r = rt_cache_get_first(seq);
326 329
327 if (r) 330 if (r)
328 while (pos && (r = rt_cache_get_next(st, r))) 331 while (pos && (r = rt_cache_get_next(seq, r)))
329 --pos; 332 --pos;
330 return pos ? NULL : r; 333 return pos ? NULL : r;
331} 334}
@@ -333,9 +336,8 @@ static struct rtable *rt_cache_get_idx(struct rt_cache_iter_state *st, loff_t po
333static void *rt_cache_seq_start(struct seq_file *seq, loff_t *pos) 336static void *rt_cache_seq_start(struct seq_file *seq, loff_t *pos)
334{ 337{
335 struct rt_cache_iter_state *st = seq->private; 338 struct rt_cache_iter_state *st = seq->private;
336
337 if (*pos) 339 if (*pos)
338 return rt_cache_get_idx(st, *pos - 1); 340 return rt_cache_get_idx(seq, *pos - 1);
339 st->genid = atomic_read(&rt_genid); 341 st->genid = atomic_read(&rt_genid);
340 return SEQ_START_TOKEN; 342 return SEQ_START_TOKEN;
341} 343}
@@ -343,12 +345,11 @@ static void *rt_cache_seq_start(struct seq_file *seq, loff_t *pos)
343static void *rt_cache_seq_next(struct seq_file *seq, void *v, loff_t *pos) 345static void *rt_cache_seq_next(struct seq_file *seq, void *v, loff_t *pos)
344{ 346{
345 struct rtable *r; 347 struct rtable *r;
346 struct rt_cache_iter_state *st = seq->private;
347 348
348 if (v == SEQ_START_TOKEN) 349 if (v == SEQ_START_TOKEN)
349 r = rt_cache_get_first(st); 350 r = rt_cache_get_first(seq);
350 else 351 else
351 r = rt_cache_get_next(st, v); 352 r = rt_cache_get_next(seq, v);
352 ++*pos; 353 ++*pos;
353 return r; 354 return r;
354} 355}
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index f2c90f145cbb..ac5d4f4b6312 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -2766,7 +2766,7 @@ static struct inet6_ifaddr *if6_get_first(struct seq_file *seq)
2766{ 2766{
2767 struct inet6_ifaddr *ifa = NULL; 2767 struct inet6_ifaddr *ifa = NULL;
2768 struct if6_iter_state *state = seq->private; 2768 struct if6_iter_state *state = seq->private;
2769 struct net *net = state->p.net; 2769 struct net *net = seq_file_net(seq);
2770 2770
2771 for (state->bucket = 0; state->bucket < IN6_ADDR_HSIZE; ++state->bucket) { 2771 for (state->bucket = 0; state->bucket < IN6_ADDR_HSIZE; ++state->bucket) {
2772 ifa = inet6_addr_lst[state->bucket]; 2772 ifa = inet6_addr_lst[state->bucket];
@@ -2782,7 +2782,7 @@ static struct inet6_ifaddr *if6_get_first(struct seq_file *seq)
2782static struct inet6_ifaddr *if6_get_next(struct seq_file *seq, struct inet6_ifaddr *ifa) 2782static struct inet6_ifaddr *if6_get_next(struct seq_file *seq, struct inet6_ifaddr *ifa)
2783{ 2783{
2784 struct if6_iter_state *state = seq->private; 2784 struct if6_iter_state *state = seq->private;
2785 struct net *net = state->p.net; 2785 struct net *net = seq_file_net(seq);
2786 2786
2787 ifa = ifa->lst_next; 2787 ifa = ifa->lst_next;
2788try_again: 2788try_again:
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index 20a3d8e2f6c6..d810cff818cf 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -2355,7 +2355,7 @@ static inline struct ifmcaddr6 *igmp6_mc_get_first(struct seq_file *seq)
2355{ 2355{
2356 struct ifmcaddr6 *im = NULL; 2356 struct ifmcaddr6 *im = NULL;
2357 struct igmp6_mc_iter_state *state = igmp6_mc_seq_private(seq); 2357 struct igmp6_mc_iter_state *state = igmp6_mc_seq_private(seq);
2358 struct net *net = state->p.net; 2358 struct net *net = seq_file_net(seq);
2359 2359
2360 state->idev = NULL; 2360 state->idev = NULL;
2361 for_each_netdev(net, state->dev) { 2361 for_each_netdev(net, state->dev) {
@@ -2486,7 +2486,7 @@ static inline struct ip6_sf_list *igmp6_mcf_get_first(struct seq_file *seq)
2486 struct ip6_sf_list *psf = NULL; 2486 struct ip6_sf_list *psf = NULL;
2487 struct ifmcaddr6 *im = NULL; 2487 struct ifmcaddr6 *im = NULL;
2488 struct igmp6_mcf_iter_state *state = igmp6_mcf_seq_private(seq); 2488 struct igmp6_mcf_iter_state *state = igmp6_mcf_seq_private(seq);
2489 struct net *net = state->p.net; 2489 struct net *net = seq_file_net(seq);
2490 2490
2491 state->idev = NULL; 2491 state->idev = NULL;
2492 state->im = NULL; 2492 state->im = NULL;
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index a6792089fcf9..0bd95680a494 100644
--- a/net/netfilter/x_tables.c
+++ b/net/netfilter/x_tables.c
@@ -727,7 +727,7 @@ struct xt_names_priv {
727static void *xt_table_seq_start(struct seq_file *seq, loff_t *pos) 727static void *xt_table_seq_start(struct seq_file *seq, loff_t *pos)
728{ 728{
729 struct xt_names_priv *priv = seq->private; 729 struct xt_names_priv *priv = seq->private;
730 struct net *net = priv->p.net; 730 struct net *net = seq_file_net(seq);
731 int af = priv->af; 731 int af = priv->af;
732 732
733 mutex_lock(&xt[af].mutex); 733 mutex_lock(&xt[af].mutex);
@@ -737,7 +737,7 @@ static void *xt_table_seq_start(struct seq_file *seq, loff_t *pos)
737static void *xt_table_seq_next(struct seq_file *seq, void *v, loff_t *pos) 737static void *xt_table_seq_next(struct seq_file *seq, void *v, loff_t *pos)
738{ 738{
739 struct xt_names_priv *priv = seq->private; 739 struct xt_names_priv *priv = seq->private;
740 struct net *net = priv->p.net; 740 struct net *net = seq_file_net(seq);
741 int af = priv->af; 741 int af = priv->af;
742 742
743 return seq_list_next(v, &net->xt.tables[af], pos); 743 return seq_list_next(v, &net->xt.tables[af], pos);
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 712a7bff8560..1d16d95dfaaf 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -1758,7 +1758,7 @@ static struct sock *netlink_seq_socket_idx(struct seq_file *seq, loff_t pos)
1758 1758
1759 for (j = 0; j <= hash->mask; j++) { 1759 for (j = 0; j <= hash->mask; j++) {
1760 sk_for_each(s, node, &hash->table[j]) { 1760 sk_for_each(s, node, &hash->table[j]) {
1761 if (sock_net(s) != iter->p.net) 1761 if (sock_net(s) != seq_file_net(seq))
1762 continue; 1762 continue;
1763 if (off == pos) { 1763 if (off == pos) {
1764 iter->link = i; 1764 iter->link = i;
@@ -1794,7 +1794,7 @@ static void *netlink_seq_next(struct seq_file *seq, void *v, loff_t *pos)
1794 s = v; 1794 s = v;
1795 do { 1795 do {
1796 s = sk_next(s); 1796 s = sk_next(s);
1797 } while (s && (sock_net(s) != iter->p.net)); 1797 } while (s && sock_net(s) != seq_file_net(seq));
1798 if (s) 1798 if (s)
1799 return s; 1799 return s;
1800 1800
@@ -1806,7 +1806,7 @@ static void *netlink_seq_next(struct seq_file *seq, void *v, loff_t *pos)
1806 1806
1807 for (; j <= hash->mask; j++) { 1807 for (; j <= hash->mask; j++) {
1808 s = sk_head(&hash->table[j]); 1808 s = sk_head(&hash->table[j]);
1809 while (s && sock_net(s) != iter->p.net) 1809 while (s && sock_net(s) != seq_file_net(seq))
1810 s = sk_next(s); 1810 s = sk_next(s);
1811 if (s) { 1811 if (s) {
1812 iter->link = i; 1812 iter->link = i;
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index cb9d0cb5f270..4a4793051bcb 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -2016,13 +2016,14 @@ struct unix_iter_state {
2016 struct seq_net_private p; 2016 struct seq_net_private p;
2017 int i; 2017 int i;
2018}; 2018};
2019static struct sock *unix_seq_idx(struct unix_iter_state *iter, loff_t pos) 2019static struct sock *unix_seq_idx(struct seq_file *seq, loff_t pos)
2020{ 2020{
2021 struct unix_iter_state *iter = seq->private;
2021 loff_t off = 0; 2022 loff_t off = 0;
2022 struct sock *s; 2023 struct sock *s;
2023 2024
2024 for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) { 2025 for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) {
2025 if (sock_net(s) != iter->p.net) 2026 if (sock_net(s) != seq_file_net(seq))
2026 continue; 2027 continue;
2027 if (off == pos) 2028 if (off == pos)
2028 return s; 2029 return s;
@@ -2035,9 +2036,8 @@ static struct sock *unix_seq_idx(struct unix_iter_state *iter, loff_t pos)
2035static void *unix_seq_start(struct seq_file *seq, loff_t *pos) 2036static void *unix_seq_start(struct seq_file *seq, loff_t *pos)
2036 __acquires(unix_table_lock) 2037 __acquires(unix_table_lock)
2037{ 2038{
2038 struct unix_iter_state *iter = seq->private;
2039 spin_lock(&unix_table_lock); 2039 spin_lock(&unix_table_lock);
2040 return *pos ? unix_seq_idx(iter, *pos - 1) : ((void *) 1); 2040 return *pos ? unix_seq_idx(seq, *pos - 1) : ((void *) 1);
2041} 2041}
2042 2042
2043static void *unix_seq_next(struct seq_file *seq, void *v, loff_t *pos) 2043static void *unix_seq_next(struct seq_file *seq, void *v, loff_t *pos)
@@ -2050,7 +2050,7 @@ static void *unix_seq_next(struct seq_file *seq, void *v, loff_t *pos)
2050 sk = first_unix_socket(&iter->i); 2050 sk = first_unix_socket(&iter->i);
2051 else 2051 else
2052 sk = next_unix_socket(&iter->i, sk); 2052 sk = next_unix_socket(&iter->i, sk);
2053 while (sk && (sock_net(sk) != iter->p.net)) 2053 while (sk && (sock_net(sk) != seq_file_net(seq)))
2054 sk = next_unix_socket(&iter->i, sk); 2054 sk = next_unix_socket(&iter->i, sk);
2055 return sk; 2055 return sk;
2056} 2056}