forked from Minki/linux
Merge branch 'nh-flushing'
Ido Schimmel says: ==================== nexthop: Support large scale nexthop flushing Patch #1 fixes a day-one bug in the nexthop code and allows "ip nexthop flush" to work correctly with large number of nexthops that do not fit in a single-part dump. Patch #2 adds a test case. Targeting at net-next since this use case never worked, the flow is pretty obscure and such a large number of nexthops is unlikely to be used in any real-world scenario. Tested with fib_nexthops.sh: Tests passed: 219 Tests failed: 0 ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
commit
c589fa10f1
@ -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;
|
||||
}
|
||||
|
||||
|
@ -1933,6 +1933,21 @@ basic()
|
||||
log_test $? 2 "Nexthop group and blackhole"
|
||||
|
||||
$IP nexthop flush >/dev/null 2>&1
|
||||
|
||||
# Test to ensure that flushing with a multi-part nexthop dump works as
|
||||
# expected.
|
||||
local batch_file=$(mktemp)
|
||||
|
||||
for i in $(seq 1 $((64 * 1024))); do
|
||||
echo "nexthop add id $i blackhole" >> $batch_file
|
||||
done
|
||||
|
||||
$IP -b $batch_file
|
||||
$IP nexthop flush >/dev/null 2>&1
|
||||
[[ $($IP nexthop | wc -l) -eq 0 ]]
|
||||
log_test $? 0 "Large scale nexthop flushing"
|
||||
|
||||
rm $batch_file
|
||||
}
|
||||
|
||||
check_nexthop_buckets_balance()
|
||||
|
Loading…
Reference in New Issue
Block a user