aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/route.c
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 /net/ipv4/route.c
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>
Diffstat (limited to 'net/ipv4/route.c')
-rw-r--r--net/ipv4/route.c29
1 files changed, 15 insertions, 14 deletions
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}