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

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/bpf/test_xdp_features.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 readonly NS="ns1-$(mktemp -u XXXXXX)"
  5 readonly V0_IP4=10.10.0.11
  6 readonly V1_IP4=10.10.0.1
  7 readonly V0_IP6=2001:db8::11
  8 readonly V1_IP6=2001:db8::1
  9 
 10 ret=1
 11 
 12 setup() {
 13         {
 14                 ip netns add ${NS}
 15 
 16                 ip link add v1 type veth peer name v0 netns ${NS}
 17 
 18                 ip link set v1 up
 19                 ip addr add $V1_IP4/24 dev v1
 20                 ip addr add $V1_IP6/64 nodad dev v1
 21                 ip -n ${NS} link set dev v0 up
 22                 ip -n ${NS} addr add $V0_IP4/24 dev v0
 23                 ip -n ${NS} addr add $V0_IP6/64 nodad dev v0
 24 
 25                 # Enable XDP mode and disable checksum offload
 26                 ethtool -K v1 gro on
 27                 ethtool -K v1 tx-checksumming off
 28                 ip netns exec ${NS} ethtool -K v0 gro on
 29                 ip netns exec ${NS} ethtool -K v0 tx-checksumming off
 30         } > /dev/null 2>&1
 31 }
 32 
 33 cleanup() {
 34         ip link del v1 2> /dev/null
 35         ip netns del ${NS} 2> /dev/null
 36         [ "$(pidof xdp_features)" = "" ] || kill $(pidof xdp_features) 2> /dev/null
 37 }
 38 
 39 wait_for_dut_server() {
 40         while sleep 1; do
 41                 ss -tlp | grep -q xdp_features
 42                 [ $? -eq 0 ] && break
 43         done
 44 }
 45 
 46 test_xdp_features() {
 47         setup
 48 
 49         ## XDP_PASS
 50         ./xdp_features -f XDP_PASS -D $V1_IP6 -T $V0_IP6 v1 &
 51         wait_for_dut_server
 52         ip netns exec ${NS} ./xdp_features -t -f XDP_PASS \
 53                                            -D $V1_IP6 -C $V1_IP6 \
 54                                            -T $V0_IP6 v0
 55         [ $? -ne 0 ] && exit
 56 
 57         ## XDP_DROP
 58         ./xdp_features -f XDP_DROP -D ::ffff:$V1_IP4 -T ::ffff:$V0_IP4 v1 &
 59         wait_for_dut_server
 60         ip netns exec ${NS} ./xdp_features -t -f XDP_DROP \
 61                                            -D ::ffff:$V1_IP4 \
 62                                            -C ::ffff:$V1_IP4 \
 63                                            -T ::ffff:$V0_IP4 v0
 64         [ $? -ne 0 ] && exit
 65 
 66         ## XDP_ABORTED
 67         ./xdp_features -f XDP_ABORTED -D $V1_IP6 -T $V0_IP6 v1 &
 68         wait_for_dut_server
 69         ip netns exec ${NS} ./xdp_features -t -f XDP_ABORTED \
 70                                            -D $V1_IP6 -C $V1_IP6 \
 71                                            -T $V0_IP6 v0
 72         [ $? -ne 0 ] && exit
 73 
 74         ## XDP_TX
 75         ./xdp_features -f XDP_TX -D ::ffff:$V1_IP4 -T ::ffff:$V0_IP4 v1 &
 76         wait_for_dut_server
 77         ip netns exec ${NS} ./xdp_features -t -f XDP_TX \
 78                                            -D ::ffff:$V1_IP4 \
 79                                            -C ::ffff:$V1_IP4 \
 80                                            -T ::ffff:$V0_IP4 v0
 81         [ $? -ne 0 ] && exit
 82 
 83         ## XDP_REDIRECT
 84         ./xdp_features -f XDP_REDIRECT -D $V1_IP6 -T $V0_IP6 v1 &
 85         wait_for_dut_server
 86         ip netns exec ${NS} ./xdp_features -t -f XDP_REDIRECT \
 87                                            -D $V1_IP6 -C $V1_IP6 \
 88                                            -T $V0_IP6 v0
 89         [ $? -ne 0 ] && exit
 90 
 91         ## XDP_NDO_XMIT
 92         ./xdp_features -f XDP_NDO_XMIT -D ::ffff:$V1_IP4 -T ::ffff:$V0_IP4 v1 &
 93         wait_for_dut_server
 94         ip netns exec ${NS} ./xdp_features -t -f XDP_NDO_XMIT \
 95                                            -D ::ffff:$V1_IP4 \
 96                                            -C ::ffff:$V1_IP4 \
 97                                            -T ::ffff:$V0_IP4 v0
 98         ret=$?
 99         cleanup
100 }
101 
102 set -e
103 trap cleanup 2 3 6 9
104 
105 test_xdp_features
106 
107 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