Skip to content

Commit

Permalink
nexthop: Restart nexthop dump based on last dumped nexthop identifier
Browse files Browse the repository at this point in the history
Currently, a multi-part nexthop dump is restarted based on the number of
nexthops that have been dumped so far. This can result in a lot of
nexthops not being dumped when nexthops are simultaneously deleted:

 # ip nexthop | wc -l
 65536
 # ip nexthop flush
 Dump was interrupted and may be inconsistent.
 Flushed 36040 nexthops
 # ip nexthop | wc -l
 29496

Instead, restart the dump based on the nexthop identifier (fixed number)
of the last successfully dumped nexthop:

 # ip nexthop | wc -l
 65536
 # ip nexthop flush
 Dump was interrupted and may be inconsistent.
 Flushed 65536 nexthops
 # ip nexthop | wc -l
 0

Reported-by: Maksym Yaremchuk <maksymy@nvidia.com>
Tested-by: Maksym Yaremchuk <maksymy@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Ido Schimmel authored and David S. Miller committed Apr 19, 2021
1 parent 56aa7b2 commit 9e46fb6
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions net/ipv4/nexthop.c
Original file line number Diff line number Diff line change
Expand Up @@ -3140,26 +3140,24 @@ static int rtm_dump_walk_nexthops(struct sk_buff *skb,
void *data)
{
struct rb_node *node;
int idx = 0, s_idx;
int s_idx;
int err;

s_idx = ctx->idx;
for (node = rb_first(root); node; node = rb_next(node)) {
struct nexthop *nh;

if (idx < s_idx)
goto cont;

nh = rb_entry(node, struct nexthop, rb_node);
ctx->idx = idx;
if (nh->id < s_idx)
continue;

ctx->idx = nh->id;
err = nh_cb(skb, cb, nh, data);
if (err)
return err;
cont:
idx++;
}

ctx->idx = idx;
ctx->idx++;
return 0;
}

Expand Down

0 comments on commit 9e46fb6

Please sign in to comment.