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

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

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ 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.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #!/bin/bash
  2 # SPDX-License-Identifier: GPL-2.0
  3 
  4 # This test runs a simple ingress tc setup between two veth pairs,
  5 # and chains a single egress rule to test ingress chaining to egress.
  6 #
  7 # Kselftest framework requirement - SKIP code is 4.
  8 ksft_skip=4
  9 
 10 if [ "$(id -u)" -ne 0 ];then
 11         echo "SKIP: Need root privileges"
 12         exit $ksft_skip
 13 fi
 14 
 15 needed_mods="act_mirred cls_flower sch_ingress"
 16 for mod in $needed_mods; do
 17         modinfo $mod &>/dev/null || { echo "SKIP: Need act_mirred module"; exit $ksft_skip; }
 18 done
 19 
 20 ns="ns$((RANDOM%899+100))"
 21 veth1="veth1$((RANDOM%899+100))"
 22 veth2="veth2$((RANDOM%899+100))"
 23 peer1="peer1$((RANDOM%899+100))"
 24 peer2="peer2$((RANDOM%899+100))"
 25 ip_peer1=198.51.100.5
 26 ip_peer2=198.51.100.6
 27 
 28 function fail() {
 29         echo "FAIL: $@" >> /dev/stderr
 30         exit 1
 31 }
 32 
 33 function cleanup() {
 34         killall -q -9 udpgso_bench_rx
 35         ip link del $veth1 &> /dev/null
 36         ip link del $veth2 &> /dev/null
 37         ip netns del $ns &> /dev/null
 38 }
 39 trap cleanup EXIT
 40 
 41 function config() {
 42         echo "Setup veth pairs [$veth1, $peer1], and veth pair [$veth2, $peer2]"
 43         ip link add $veth1 type veth peer name $peer1
 44         ip link add $veth2 type veth peer name $peer2
 45         ip addr add $ip_peer1/24 dev $peer1
 46         ip link set $peer1 up
 47         ip netns add $ns
 48         ip link set dev $peer2 netns $ns
 49         ip netns exec $ns ip addr add $ip_peer2/24 dev $peer2
 50         ip netns exec $ns ip link set $peer2 up
 51         ip link set $veth1 up
 52         ip link set $veth2 up
 53 
 54         echo "Add tc filter ingress->egress forwarding $veth1 <-> $veth2"
 55         tc qdisc add dev $veth2 ingress
 56         tc qdisc add dev $veth1 ingress
 57         tc filter add dev $veth2 ingress prio 1 proto all flower \
 58                 action mirred egress redirect dev $veth1
 59         tc filter add dev $veth1 ingress prio 1 proto all flower \
 60                 action mirred egress redirect dev $veth2
 61 
 62         echo "Add tc filter egress->ingress forwarding $peer1 -> $veth1, bypassing the veth pipe"
 63         tc qdisc add dev $peer1 clsact
 64         tc filter add dev $peer1 egress prio 20 proto ip flower \
 65                 action mirred ingress redirect dev $veth1
 66 }
 67 
 68 function test_run() {
 69         echo "Run tcp traffic"
 70         ./udpgso_bench_rx -t &
 71         sleep 1
 72         ip netns exec $ns timeout -k 2 10 ./udpgso_bench_tx -t -l 2 -4 -D $ip_peer1 || fail "traffic failed"
 73         echo "Test passed"
 74 }
 75 
 76 config
 77 test_run
 78 trap - EXIT
 79 cleanup

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