net: neighbour: fix neigh_dump_info()

Denys found out "ip neigh" output was truncated to
about 54 neighbours.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Denys Fedoryshchenko <denys@visp.net.lb>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Eric Dumazet
2012-06-07 04:58:35 +00:00
committed by David S. Miller
parent a06998b88b
commit 4bd6683bd4

View File

@@ -2219,9 +2219,7 @@ static int neigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb,
rcu_read_lock_bh(); rcu_read_lock_bh();
nht = rcu_dereference_bh(tbl->nht); nht = rcu_dereference_bh(tbl->nht);
for (h = 0; h < (1 << nht->hash_shift); h++) { for (h = s_h; h < (1 << nht->hash_shift); h++) {
if (h < s_h)
continue;
if (h > s_h) if (h > s_h)
s_idx = 0; s_idx = 0;
for (n = rcu_dereference_bh(nht->hash_buckets[h]), idx = 0; for (n = rcu_dereference_bh(nht->hash_buckets[h]), idx = 0;
@@ -2260,9 +2258,7 @@ static int pneigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb,
read_lock_bh(&tbl->lock); read_lock_bh(&tbl->lock);
for (h = 0; h <= PNEIGH_HASHMASK; h++) { for (h = s_h; h <= PNEIGH_HASHMASK; h++) {
if (h < s_h)
continue;
if (h > s_h) if (h > s_h)
s_idx = 0; s_idx = 0;
for (n = tbl->phash_buckets[h], idx = 0; n; n = n->next) { for (n = tbl->phash_buckets[h], idx = 0; n; n = n->next) {
@@ -2297,7 +2293,7 @@ static int neigh_dump_info(struct sk_buff *skb, struct netlink_callback *cb)
struct neigh_table *tbl; struct neigh_table *tbl;
int t, family, s_t; int t, family, s_t;
int proxy = 0; int proxy = 0;
int err = 0; int err;
read_lock(&neigh_tbl_lock); read_lock(&neigh_tbl_lock);
family = ((struct rtgenmsg *) nlmsg_data(cb->nlh))->rtgen_family; family = ((struct rtgenmsg *) nlmsg_data(cb->nlh))->rtgen_family;
@@ -2311,7 +2307,7 @@ static int neigh_dump_info(struct sk_buff *skb, struct netlink_callback *cb)
s_t = cb->args[0]; s_t = cb->args[0];
for (tbl = neigh_tables, t = 0; tbl && (err >= 0); for (tbl = neigh_tables, t = 0; tbl;
tbl = tbl->next, t++) { tbl = tbl->next, t++) {
if (t < s_t || (family && tbl->family != family)) if (t < s_t || (family && tbl->family != family))
continue; continue;
@@ -2322,6 +2318,8 @@ static int neigh_dump_info(struct sk_buff *skb, struct netlink_callback *cb)
err = pneigh_dump_table(tbl, skb, cb); err = pneigh_dump_table(tbl, skb, cb);
else else
err = neigh_dump_table(tbl, skb, cb); err = neigh_dump_table(tbl, skb, cb);
if (err < 0)
break;
} }
read_unlock(&neigh_tbl_lock); read_unlock(&neigh_tbl_lock);