Commit 18502acd authored by Zhang Shengju's avatar Zhang Shengju Committed by David S. Miller

neigh: remove duplicate check for same neigh

Currently loop index 'idx' is used as the index in the neigh list of interest.
It's increased only when the neigh is dumped. It's not the absolute index in
the list. Because there is no info to record which neigh has already be scanned
by previous loop. This will cause the filtered out neighs to be scanned mulitple
times.

This patch make idx as the absolute index in the list, it will increase no matter
whether the neigh is filtered. This will prevent the above problem.

And this is in line with other dump functions.

v2:
 - take David Ahern's advice to do simple change
Signed-off-by: default avatarZhang Shengju <zhangshengju@cmss.chinamobile.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9bee294f
...@@ -2291,13 +2291,10 @@ static int neigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb, ...@@ -2291,13 +2291,10 @@ static int neigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb,
for (n = rcu_dereference_bh(nht->hash_buckets[h]), idx = 0; for (n = rcu_dereference_bh(nht->hash_buckets[h]), idx = 0;
n != NULL; n != NULL;
n = rcu_dereference_bh(n->next)) { n = rcu_dereference_bh(n->next)) {
if (!net_eq(dev_net(n->dev), net)) if (idx < s_idx || !net_eq(dev_net(n->dev), net))
continue; goto next;
if (neigh_ifindex_filtered(n->dev, filter_idx)) if (neigh_ifindex_filtered(n->dev, filter_idx) ||
continue; neigh_master_filtered(n->dev, filter_master_idx))
if (neigh_master_filtered(n->dev, filter_master_idx))
continue;
if (idx < s_idx)
goto next; goto next;
if (neigh_fill_info(skb, n, NETLINK_CB(cb->skb).portid, if (neigh_fill_info(skb, n, NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq, cb->nlh->nlmsg_seq,
...@@ -2332,9 +2329,7 @@ static int pneigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb, ...@@ -2332,9 +2329,7 @@ static int pneigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb,
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) {
if (pneigh_net(n) != net) if (idx < s_idx || pneigh_net(n) != net)
continue;
if (idx < s_idx)
goto next; goto next;
if (pneigh_fill_info(skb, n, NETLINK_CB(cb->skb).portid, if (pneigh_fill_info(skb, n, NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq, cb->nlh->nlmsg_seq,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment