diff options
author | Gautam Kachroo <gk@aristanetworks.com> | 2009-02-06 03:52:04 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-02-06 03:52:04 -0500 |
commit | efc683fc2a692735029067b4f939af2a3625e31d (patch) | |
tree | d1961466cef6bae0cfa44f656a909ef8349b56c6 /net | |
parent | 684de409acff8b1fe8bf188d75ff2f99c624387d (diff) |
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: Gautam Kachroo <gk@aristanetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/core/neighbour.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/net/core/neighbour.c b/net/core/neighbour.c index f66c58df8953..278a142d1047 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c | |||
@@ -1994,8 +1994,8 @@ static int neightbl_dump_info(struct sk_buff *skb, struct netlink_callback *cb) | |||
1994 | if (!net_eq(neigh_parms_net(p), net)) | 1994 | if (!net_eq(neigh_parms_net(p), net)) |
1995 | continue; | 1995 | continue; |
1996 | 1996 | ||
1997 | if (nidx++ < neigh_skip) | 1997 | if (nidx < neigh_skip) |
1998 | continue; | 1998 | goto next; |
1999 | 1999 | ||
2000 | if (neightbl_fill_param_info(skb, tbl, p, | 2000 | if (neightbl_fill_param_info(skb, tbl, p, |
2001 | NETLINK_CB(cb->skb).pid, | 2001 | NETLINK_CB(cb->skb).pid, |
@@ -2003,6 +2003,8 @@ static int neightbl_dump_info(struct sk_buff *skb, struct netlink_callback *cb) | |||
2003 | RTM_NEWNEIGHTBL, | 2003 | RTM_NEWNEIGHTBL, |
2004 | NLM_F_MULTI) <= 0) | 2004 | NLM_F_MULTI) <= 0) |
2005 | goto out; | 2005 | goto out; |
2006 | next: | ||
2007 | nidx++; | ||
2006 | } | 2008 | } |
2007 | 2009 | ||
2008 | neigh_skip = 0; | 2010 | neigh_skip = 0; |
@@ -2082,12 +2084,10 @@ static int neigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb, | |||
2082 | if (h > s_h) | 2084 | if (h > s_h) |
2083 | s_idx = 0; | 2085 | s_idx = 0; |
2084 | for (n = tbl->hash_buckets[h], idx = 0; n; n = n->next) { | 2086 | for (n = tbl->hash_buckets[h], idx = 0; n; n = n->next) { |
2085 | int lidx; | ||
2086 | if (dev_net(n->dev) != net) | 2087 | if (dev_net(n->dev) != net) |
2087 | continue; | 2088 | continue; |
2088 | lidx = idx++; | 2089 | if (idx < s_idx) |
2089 | if (lidx < s_idx) | 2090 | goto next; |
2090 | continue; | ||
2091 | if (neigh_fill_info(skb, n, NETLINK_CB(cb->skb).pid, | 2091 | if (neigh_fill_info(skb, n, NETLINK_CB(cb->skb).pid, |
2092 | cb->nlh->nlmsg_seq, | 2092 | cb->nlh->nlmsg_seq, |
2093 | RTM_NEWNEIGH, | 2093 | RTM_NEWNEIGH, |
@@ -2096,6 +2096,8 @@ static int neigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb, | |||
2096 | rc = -1; | 2096 | rc = -1; |
2097 | goto out; | 2097 | goto out; |
2098 | } | 2098 | } |
2099 | next: | ||
2100 | idx++; | ||
2099 | } | 2101 | } |
2100 | } | 2102 | } |
2101 | read_unlock_bh(&tbl->lock); | 2103 | read_unlock_bh(&tbl->lock); |