diff options
author | Chris Larson <clarson@mvista.com> | 2008-08-03 04:10:55 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-08-03 04:10:55 -0400 |
commit | 745e203164a9057e0de769ff4649e6e455daf753 (patch) | |
tree | 477d9342196113fdbbeceebcbf4968aafe463646 /net | |
parent | bff69732c9947f821a64a8477f7dcaa9c30e6a69 (diff) |
net: fix missing pneigh entries in the neighbor seq_file code
When pneigh entries exist, but the user's read buffer isn't sufficient to
hold them all, one of the pneigh entries will be missing from the results.
In neigh_get_idx_any, the number of elements which neigh_get_idx
encountered is not correctly subtracted from the position number before
the call to pneigh_get_idx. neigh_get_idx reduces the position by 1 for
each call to neigh_get_next, but it does not reduce it by one for the
first element (neigh_get_first). The patch alters the neigh_get_idx and
pneigh_get_idx functions to subtract one from pos, for the first element,
when pos is non-zero.
Signed-off-by: Chris Larson <clarson@mvista.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/core/neighbour.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/net/core/neighbour.c b/net/core/neighbour.c index a57de755c8cc..9d92e41826e7 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c | |||
@@ -2281,6 +2281,7 @@ static struct neighbour *neigh_get_idx(struct seq_file *seq, loff_t *pos) | |||
2281 | struct neighbour *n = neigh_get_first(seq); | 2281 | struct neighbour *n = neigh_get_first(seq); |
2282 | 2282 | ||
2283 | if (n) { | 2283 | if (n) { |
2284 | --(*pos); | ||
2284 | while (*pos) { | 2285 | while (*pos) { |
2285 | n = neigh_get_next(seq, n, pos); | 2286 | n = neigh_get_next(seq, n, pos); |
2286 | if (!n) | 2287 | if (!n) |
@@ -2341,6 +2342,7 @@ static struct pneigh_entry *pneigh_get_idx(struct seq_file *seq, loff_t *pos) | |||
2341 | struct pneigh_entry *pn = pneigh_get_first(seq); | 2342 | struct pneigh_entry *pn = pneigh_get_first(seq); |
2342 | 2343 | ||
2343 | if (pn) { | 2344 | if (pn) { |
2345 | --(*pos); | ||
2344 | while (*pos) { | 2346 | while (*pos) { |
2345 | pn = pneigh_get_next(seq, pn, pos); | 2347 | pn = pneigh_get_next(seq, pn, pos); |
2346 | if (!pn) | 2348 | if (!pn) |
@@ -2354,10 +2356,11 @@ static void *neigh_get_idx_any(struct seq_file *seq, loff_t *pos) | |||
2354 | { | 2356 | { |
2355 | struct neigh_seq_state *state = seq->private; | 2357 | struct neigh_seq_state *state = seq->private; |
2356 | void *rc; | 2358 | void *rc; |
2359 | loff_t idxpos = *pos; | ||
2357 | 2360 | ||
2358 | rc = neigh_get_idx(seq, pos); | 2361 | rc = neigh_get_idx(seq, &idxpos); |
2359 | if (!rc && !(state->flags & NEIGH_SEQ_NEIGH_ONLY)) | 2362 | if (!rc && !(state->flags & NEIGH_SEQ_NEIGH_ONLY)) |
2360 | rc = pneigh_get_idx(seq, pos); | 2363 | rc = pneigh_get_idx(seq, &idxpos); |
2361 | 2364 | ||
2362 | return rc; | 2365 | return rc; |
2363 | } | 2366 | } |
@@ -2366,7 +2369,6 @@ void *neigh_seq_start(struct seq_file *seq, loff_t *pos, struct neigh_table *tbl | |||
2366 | __acquires(tbl->lock) | 2369 | __acquires(tbl->lock) |
2367 | { | 2370 | { |
2368 | struct neigh_seq_state *state = seq->private; | 2371 | struct neigh_seq_state *state = seq->private; |
2369 | loff_t pos_minus_one; | ||
2370 | 2372 | ||
2371 | state->tbl = tbl; | 2373 | state->tbl = tbl; |
2372 | state->bucket = 0; | 2374 | state->bucket = 0; |
@@ -2374,8 +2376,7 @@ void *neigh_seq_start(struct seq_file *seq, loff_t *pos, struct neigh_table *tbl | |||
2374 | 2376 | ||
2375 | read_lock_bh(&tbl->lock); | 2377 | read_lock_bh(&tbl->lock); |
2376 | 2378 | ||
2377 | pos_minus_one = *pos - 1; | 2379 | return *pos ? neigh_get_idx_any(seq, pos) : SEQ_START_TOKEN; |
2378 | return *pos ? neigh_get_idx_any(seq, &pos_minus_one) : SEQ_START_TOKEN; | ||
2379 | } | 2380 | } |
2380 | EXPORT_SYMBOL(neigh_seq_start); | 2381 | EXPORT_SYMBOL(neigh_seq_start); |
2381 | 2382 | ||