drm/bridge: adv7511: Switch to atomic operations
[drm/drm-misc.git] / tools / testing / selftests / net / xfrm_policy_add_speed.sh
blob2fab29d3cb91b5411c1964cf681cf4d4a2b0629c
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 source lib.sh
6 timeout=4m
7 ret=0
8 tmp=$(mktemp)
9 cleanup() {
10 cleanup_all_ns
11 rm -f "$tmp"
14 trap cleanup EXIT
16 maxpolicies=100000
17 [ "$KSFT_MACHINE_SLOW" = "yes" ] && maxpolicies=10000
19 do_dummies4() {
20 local dir="$1"
21 local max="$2"
23 local policies
24 local pfx
25 pfx=30
26 policies=0
28 ip netns exec "$ns" ip xfrm policy flush
30 for i in $(seq 1 100);do
31 local s
32 local d
33 for j in $(seq 1 255);do
34 s=$((i+0))
35 d=$((i+100))
37 for a in $(seq 1 8 255); do
38 policies=$((policies+1))
39 [ "$policies" -gt "$max" ] && return
40 echo xfrm policy add src 10.$s.$j.0/30 dst 10.$d.$j.$a/$pfx dir $dir action block
41 done
42 for a in $(seq 1 8 255); do
43 policies=$((policies+1))
44 [ "$policies" -gt "$max" ] && return
45 echo xfrm policy add src 10.$s.$j.$a/30 dst 10.$d.$j.0/$pfx dir $dir action block
46 done
47 done
48 done
51 setup_ns ns
53 do_bench()
55 local max="$1"
57 start=$(date +%s%3N)
58 do_dummies4 "out" "$max" > "$tmp"
59 if ! timeout "$timeout" ip netns exec "$ns" ip -batch "$tmp";then
60 echo "WARNING: policy insertion cancelled after $timeout"
61 ret=1
63 stop=$(date +%s%3N)
65 result=$((stop-start))
67 policies=$(wc -l < "$tmp")
68 printf "Inserted %-06s policies in $result ms\n" $policies
70 have=$(ip netns exec "$ns" ip xfrm policy show | grep "action block" | wc -l)
71 if [ "$have" -ne "$policies" ]; then
72 echo "WARNING: mismatch, have $have policies, expected $policies"
73 ret=1
77 p=100
78 while [ $p -le "$maxpolicies" ]; do
79 do_bench "$p"
80 p="${p}0"
81 done
83 exit $ret