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

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/bpf/test_tcp_check_syncookie.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/sh
  2 # SPDX-License-Identifier: GPL-2.0
  3 # Copyright (c) 2018 Facebook
  4 # Copyright (c) 2019 Cloudflare
  5 
  6 set -eu
  7 readonly NS1="ns1-$(mktemp -u XXXXXX)"
  8 
  9 wait_for_ip()
 10 {
 11         local _i
 12         printf "Wait for IP %s to become available " "$1"
 13         for _i in $(seq ${MAX_PING_TRIES}); do
 14                 printf "."
 15                 if ns1_exec ping -c 1 -W 1 "$1" >/dev/null 2>&1; then
 16                         echo " OK"
 17                         return
 18                 fi
 19                 sleep 1
 20         done
 21         echo 1>&2 "ERROR: Timeout waiting for test IP to become available."
 22         exit 1
 23 }
 24 
 25 get_prog_id()
 26 {
 27         awk '/ id / {sub(/.* id /, "", $0); print($1)}'
 28 }
 29 
 30 ns1_exec()
 31 {
 32         ip netns exec ${NS1} "$@"
 33 }
 34 
 35 setup()
 36 {
 37         ip netns add ${NS1}
 38         ns1_exec ip link set lo up
 39 
 40         ns1_exec sysctl -w net.ipv4.tcp_syncookies=2
 41         ns1_exec sysctl -w net.ipv4.tcp_window_scaling=0
 42         ns1_exec sysctl -w net.ipv4.tcp_timestamps=0
 43         ns1_exec sysctl -w net.ipv4.tcp_sack=0
 44 
 45         wait_for_ip 127.0.0.1
 46         wait_for_ip ::1
 47 }
 48 
 49 cleanup()
 50 {
 51         ip netns del ns1 2>/dev/null || :
 52 }
 53 
 54 main()
 55 {
 56         trap cleanup EXIT 2 3 6 15
 57         setup
 58 
 59         printf "Testing clsact..."
 60         ns1_exec tc qdisc add dev "${TEST_IF}" clsact
 61         ns1_exec tc filter add dev "${TEST_IF}" ingress \
 62                 bpf obj "${BPF_PROG_OBJ}" sec "${CLSACT_SECTION}" da
 63 
 64         BPF_PROG_ID=$(ns1_exec tc filter show dev "${TEST_IF}" ingress | \
 65                       get_prog_id)
 66         ns1_exec "${PROG}" "${BPF_PROG_ID}"
 67         ns1_exec tc qdisc del dev "${TEST_IF}" clsact
 68 
 69         printf "Testing XDP..."
 70         ns1_exec ip link set "${TEST_IF}" xdp \
 71                 object "${BPF_PROG_OBJ}" section "${XDP_SECTION}"
 72         BPF_PROG_ID=$(ns1_exec ip link show "${TEST_IF}" | get_prog_id)
 73         ns1_exec "${PROG}" "${BPF_PROG_ID}"
 74 }
 75 
 76 DIR=$(dirname $0)
 77 TEST_IF=lo
 78 MAX_PING_TRIES=5
 79 BPF_PROG_OBJ="${DIR}/test_tcp_check_syncookie_kern.bpf.o"
 80 CLSACT_SECTION="tc"
 81 XDP_SECTION="xdp"
 82 BPF_PROG_ID=0
 83 PROG="${DIR}/test_tcp_check_syncookie_user"
 84 
 85 main

~ [ 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