~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/net/xfrm_policy_add_speed.sh

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #!/bin/bash
  2 # SPDX-License-Identifier: GPL-2.0
  3 #
  4 source lib.sh
  5 
  6 timeout=4m
  7 ret=0
  8 tmp=$(mktemp)
  9 cleanup() {
 10         cleanup_all_ns
 11         rm -f "$tmp"
 12 }
 13 
 14 trap cleanup EXIT
 15 
 16 maxpolicies=100000
 17 [ "$KSFT_MACHINE_SLOW" = "yes" ] && maxpolicies=10000
 18 
 19 do_dummies4() {
 20         local dir="$1"
 21         local max="$2"
 22 
 23         local policies
 24         local pfx
 25         pfx=30
 26         policies=0
 27 
 28         ip netns exec "$ns" ip xfrm policy flush
 29 
 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))
 36 
 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
 49 }
 50 
 51 setup_ns ns
 52 
 53 do_bench()
 54 {
 55         local max="$1"
 56 
 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
 62         fi
 63         stop=$(date +%s%3N)
 64 
 65         result=$((stop-start))
 66 
 67         policies=$(wc -l < "$tmp")
 68         printf "Inserted %-06s policies in $result ms\n" $policies
 69 
 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
 74         fi
 75 }
 76 
 77 p=100
 78 while [ $p -le "$maxpolicies" ]; do
 79         do_bench "$p"
 80         p="${p}0"
 81 done
 82 
 83 exit $ret

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php