Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 642d6318 authored by Denis V. Lunev's avatar Denis V. Lunev Committed by David S. Miller
Browse files

[IPV4]: rt_cache_get_next should take rt_genid into account.



In the other case /proc/net/rt_cache will look inconsistent in respect to
genid.

Signed-off-by: default avatarDenis V. Lunev <den@openvz.org>
Acked-by: default avatarAlexey Kuznetsov <kuznet@ms2.inr.ac.ru>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 317805b8
Loading
Loading
Loading
Loading
+13 −5
Original line number Original line Diff line number Diff line
@@ -294,7 +294,8 @@ static struct rtable *rt_cache_get_first(struct rt_cache_iter_state *st)
	return r;
	return r;
}
}


static struct rtable *rt_cache_get_next(struct rt_cache_iter_state *st, struct rtable *r)
static struct rtable *__rt_cache_get_next(struct rt_cache_iter_state *st,
					  struct rtable *r)
{
{
	r = r->u.dst.rt_next;
	r = r->u.dst.rt_next;
	while (!r) {
	while (!r) {
@@ -307,16 +308,23 @@ static struct rtable *rt_cache_get_next(struct rt_cache_iter_state *st, struct r
	return rcu_dereference(r);
	return rcu_dereference(r);
}
}


static struct rtable *rt_cache_get_next(struct rt_cache_iter_state *st,
					struct rtable *r)
{
	while ((r = __rt_cache_get_next(st, r)) != NULL) {
		if (r->rt_genid == st->genid)
			break;
	}
	return r;
}

static struct rtable *rt_cache_get_idx(struct rt_cache_iter_state *st, loff_t pos)
static struct rtable *rt_cache_get_idx(struct rt_cache_iter_state *st, loff_t pos)
{
{
	struct rtable *r = rt_cache_get_first(st);
	struct rtable *r = rt_cache_get_first(st);


	if (r)
	if (r)
		while (pos && (r = rt_cache_get_next(st, r))) {
		while (pos && (r = rt_cache_get_next(st, r)))
			if (r->rt_genid != st->genid)
				continue;
			--pos;
			--pos;
		}
	return pos ? NULL : r;
	return pos ? NULL : r;
}
}