2 # Create 2 namespaces with two veth peers, and
3 # forward packets in-between using generic XDP
5 # NS1(veth11) NS2(veth22)
8 # (veth1, ------ (veth2,
23 ip link add veth1 index 111 type veth peer name veth11 netns ns1
24 ip link add veth2 index 222 type veth peer name veth22 netns ns2
28 ip -n ns1 link set dev veth11 up
29 ip -n ns2 link set dev veth22 up
31 ip -n ns1 addr add 10.1.1.11/24 dev veth11
32 ip -n ns2 addr add 10.1.1.22/24 dev veth22
37 ip link del veth1 2> /dev/null
38 ip link del veth2 2> /dev/null
39 ip netns del ns1 2> /dev/null
40 ip netns del ns2 2> /dev/null
49 ip link set dev veth1 $xdpmode off &> /dev/null
51 echo "selftests: test_xdp_redirect $xdpmode [SKIP]"
55 ip -n ns1 link set veth11 $xdpmode obj xdp_dummy.o sec xdp_dummy &> /dev/null
56 ip -n ns2 link set veth22 $xdpmode obj xdp_dummy.o sec xdp_dummy &> /dev/null
57 ip link set dev veth1 $xdpmode obj test_xdp_redirect.o sec redirect_to_222 &> /dev/null
58 ip link set dev veth2 $xdpmode obj test_xdp_redirect.o sec redirect_to_111 &> /dev/null
60 if ip netns exec ns1 ping -c 1 10.1.1.22 &> /dev/null &&
61 ip netns exec ns2 ping -c 1 10.1.1.11 &> /dev/null; then
62 echo "selftests: test_xdp_redirect $xdpmode [PASS]";
65 echo "selftests: test_xdp_redirect $xdpmode [FAILED]";
74 test_xdp_redirect xdpgeneric
75 test_xdp_redirect xdpdrv