WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / net / forwarding / loopback.sh
blob8f4057310b5b41a2c6b6bf52c448efdfaa4391e5
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 # Kselftest framework requirement - SKIP code is 4.
5 ksft_skip=4
7 ALL_TESTS="loopback_test"
8 NUM_NETIFS=2
9 source tc_common.sh
10 source lib.sh
12 h1_create()
14 simple_if_init $h1 192.0.2.1/24
15 tc qdisc add dev $h1 clsact
18 h1_destroy()
20 tc qdisc del dev $h1 clsact
21 simple_if_fini $h1 192.0.2.1/24
24 h2_create()
26 simple_if_init $h2
29 h2_destroy()
31 simple_if_fini $h2
34 loopback_test()
36 RET=0
38 tc filter add dev $h1 ingress protocol arp pref 1 handle 101 flower \
39 skip_hw arp_op reply arp_tip 192.0.2.1 action drop
41 $MZ $h1 -c 1 -t arp -q
43 tc_check_packets "dev $h1 ingress" 101 1
44 check_fail $? "Matched on a filter without loopback setup"
46 ethtool -K $h1 loopback on
47 check_err $? "Failed to enable loopback"
49 setup_wait_dev $h1
51 $MZ $h1 -c 1 -t arp -q
53 tc_check_packets "dev $h1 ingress" 101 1
54 check_err $? "Did not match on filter with loopback"
56 ethtool -K $h1 loopback off
57 check_err $? "Failed to disable loopback"
59 $MZ $h1 -c 1 -t arp -q
61 tc_check_packets "dev $h1 ingress" 101 2
62 check_fail $? "Matched on a filter after loopback was removed"
64 tc filter del dev $h1 ingress protocol arp pref 1 handle 101 flower
66 log_test "loopback"
69 setup_prepare()
71 h1=${NETIFS[p1]}
72 h2=${NETIFS[p2]}
74 vrf_prepare
76 h1_create
77 h2_create
79 if ethtool -k $h1 | grep loopback | grep -q fixed; then
80 log_test "SKIP: dev $h1 does not support loopback feature"
81 exit $ksft_skip
85 cleanup()
87 pre_cleanup
89 h2_destroy
90 h1_destroy
92 vrf_cleanup
95 trap cleanup EXIT
97 setup_prepare
98 setup_wait
100 tests_run
102 exit $EXIT_STATUS