Commit efc683fc authored by Gautam Kachroo's avatar Gautam Kachroo Committed by David S. Miller

neigh: some entries can be skipped during dumping

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: default avatarGautam Kachroo <gk@aristanetworks.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 684de409
...@@ -1994,8 +1994,8 @@ static int neightbl_dump_info(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -1994,8 +1994,8 @@ static int neightbl_dump_info(struct sk_buff *skb, struct netlink_callback *cb)
if (!net_eq(neigh_parms_net(p), net)) if (!net_eq(neigh_parms_net(p), net))
continue; continue;
if (nidx++ < neigh_skip) if (nidx < neigh_skip)
continue; goto next;
if (neightbl_fill_param_info(skb, tbl, p, if (neightbl_fill_param_info(skb, tbl, p,
NETLINK_CB(cb->skb).pid, NETLINK_CB(cb->skb).pid,
...@@ -2003,6 +2003,8 @@ static int neightbl_dump_info(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -2003,6 +2003,8 @@ static int neightbl_dump_info(struct sk_buff *skb, struct netlink_callback *cb)
RTM_NEWNEIGHTBL, RTM_NEWNEIGHTBL,
NLM_F_MULTI) <= 0) NLM_F_MULTI) <= 0)
goto out; goto out;
next:
nidx++;
} }
neigh_skip = 0; neigh_skip = 0;
...@@ -2082,12 +2084,10 @@ static int neigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb, ...@@ -2082,12 +2084,10 @@ static int neigh_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->hash_buckets[h], idx = 0; n; n = n->next) { for (n = tbl->hash_buckets[h], idx = 0; n; n = n->next) {
int lidx;
if (dev_net(n->dev) != net) if (dev_net(n->dev) != net)
continue; continue;
lidx = idx++; if (idx < s_idx)
if (lidx < s_idx) goto next;
continue;
if (neigh_fill_info(skb, n, NETLINK_CB(cb->skb).pid, if (neigh_fill_info(skb, n, NETLINK_CB(cb->skb).pid,
cb->nlh->nlmsg_seq, cb->nlh->nlmsg_seq,
RTM_NEWNEIGH, RTM_NEWNEIGH,
...@@ -2096,6 +2096,8 @@ static int neigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb, ...@@ -2096,6 +2096,8 @@ static int neigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb,
rc = -1; rc = -1;
goto out; goto out;
} }
next:
idx++;
} }
} }
read_unlock_bh(&tbl->lock); read_unlock_bh(&tbl->lock);
......
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