Skip to content

Commit

Permalink
neigh: some entries can be skipped during dumping
Browse files Browse the repository at this point in the history
neightbl_dump_info and neigh_dump_table  can skip entries if the
*fill*info functions return an error. This results in an incomplete
dump ((invoked by netlink requests for RTM_GETNEIGHTBL or
RTM_GETNEIGH)

nidx and idx should not be incremented if the current entry was not
placed in the output buffer

Signed-off-by: Gautam Kachroo <gk@aristanetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Gautam Kachroo authored and David S. Miller committed Feb 6, 2009
1 parent 684de40 commit efc683f
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions net/core/neighbour.c
Original file line number Diff line number Diff line change
Expand Up @@ -1994,15 +1994,17 @@ static int neightbl_dump_info(struct sk_buff *skb, struct netlink_callback *cb)
if (!net_eq(neigh_parms_net(p), net))
continue;

if (nidx++ < neigh_skip)
continue;
if (nidx < neigh_skip)
goto next;

if (neightbl_fill_param_info(skb, tbl, p,
NETLINK_CB(cb->skb).pid,
cb->nlh->nlmsg_seq,
RTM_NEWNEIGHTBL,
NLM_F_MULTI) <= 0)
goto out;
next:
nidx++;
}

neigh_skip = 0;
Expand Down Expand Up @@ -2082,12 +2084,10 @@ static int neigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb,
if (h > s_h)
s_idx = 0;
for (n = tbl->hash_buckets[h], idx = 0; n; n = n->next) {
int lidx;
if (dev_net(n->dev) != net)
continue;
lidx = idx++;
if (lidx < s_idx)
continue;
if (idx < s_idx)
goto next;
if (neigh_fill_info(skb, n, NETLINK_CB(cb->skb).pid,
cb->nlh->nlmsg_seq,
RTM_NEWNEIGH,
Expand All @@ -2096,6 +2096,8 @@ static int neigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb,
rc = -1;
goto out;
}
next:
idx++;
}
}
read_unlock_bh(&tbl->lock);
Expand Down

0 comments on commit efc683f

Please sign in to comment.