1#!/bin/sh 2 3# Kselftest framework requirement - SKIP code is 4. 4readonly KSFT_SKIP=4 5 6cleanup() 7{ 8 if [ "$?" = "0" ]; then 9 echo "selftests: test_xdp_meta [PASS]"; 10 else 11 echo "selftests: test_xdp_meta [FAILED]"; 12 fi 13 14 set +e 15 ip link del veth1 2> /dev/null 16 ip netns del ns1 2> /dev/null 17 ip netns del ns2 2> /dev/null 18} 19 20ip link set dev lo xdp off 2>/dev/null > /dev/null 21if [ $? -ne 0 ];then 22 echo "selftests: [SKIP] Could not run test without the ip xdp support" 23 exit $KSFT_SKIP 24fi 25set -e 26 27ip netns add ns1 28ip netns add ns2 29 30trap cleanup 0 2 3 6 9 31 32ip link add veth1 type veth peer name veth2 33 34ip link set veth1 netns ns1 35ip link set veth2 netns ns2 36 37ip netns exec ns1 ip addr add 10.1.1.11/24 dev veth1 38ip netns exec ns2 ip addr add 10.1.1.22/24 dev veth2 39 40ip netns exec ns1 tc qdisc add dev veth1 clsact 41ip netns exec ns2 tc qdisc add dev veth2 clsact 42 43ip netns exec ns1 tc filter add dev veth1 ingress bpf da obj test_xdp_meta.o sec t 44ip netns exec ns2 tc filter add dev veth2 ingress bpf da obj test_xdp_meta.o sec t 45 46ip netns exec ns1 ip link set dev veth1 xdp obj test_xdp_meta.o sec x 47ip netns exec ns2 ip link set dev veth2 xdp obj test_xdp_meta.o sec x 48 49ip netns exec ns1 ip link set dev veth1 up 50ip netns exec ns2 ip link set dev veth2 up 51 52ip netns exec ns1 ping -c 1 10.1.1.22 53ip netns exec ns2 ping -c 1 10.1.1.11 54 55exit 0 56