File tree Expand file tree Collapse file tree 1 file changed +94
-0
lines changed
tools/testing/selftests/net/forwarding Expand file tree Collapse file tree 1 file changed +94
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ # SPDX-License-Identifier: GPL-2.0
3+
4+ ALL_TESTS=" loopback_test"
5+ NUM_NETIFS=2
6+ source tc_common.sh
7+ source lib.sh
8+
9+ h1_create ()
10+ {
11+ simple_if_init $h1 192.0.2.1/24
12+ tc qdisc add dev $h1 clsact
13+ }
14+
15+ h1_destroy ()
16+ {
17+ tc qdisc del dev $h1 clsact
18+ simple_if_fini $h1 192.0.2.1/24
19+ }
20+
21+ h2_create ()
22+ {
23+ simple_if_init $h2
24+ }
25+
26+ h2_destroy ()
27+ {
28+ simple_if_fini $h2
29+ }
30+
31+ loopback_test ()
32+ {
33+ RET=0
34+
35+ tc filter add dev $h1 ingress protocol arp pref 1 handle 101 flower \
36+ skip_hw arp_op reply arp_tip 192.0.2.1 action drop
37+
38+ $MZ $h1 -c 1 -t arp -q
39+
40+ tc_check_packets " dev $h1 ingress" 101 1
41+ check_fail $? " Matched on a filter without loopback setup"
42+
43+ ethtool -K $h1 loopback on
44+ check_err $? " Failed to enable loopback"
45+
46+ setup_wait_dev $h1
47+
48+ $MZ $h1 -c 1 -t arp -q
49+
50+ tc_check_packets " dev $h1 ingress" 101 1
51+ check_err $? " Did not match on filter with loopback"
52+
53+ ethtool -K $h1 loopback off
54+ check_err $? " Failed to disable loopback"
55+
56+ $MZ $h1 -c 1 -t arp -q
57+
58+ tc_check_packets " dev $h1 ingress" 101 2
59+ check_fail $? " Matched on a filter after loopback was removed"
60+
61+ tc filter del dev $h1 ingress protocol arp pref 1 handle 101 flower
62+
63+ log_test " loopback"
64+ }
65+
66+ setup_prepare ()
67+ {
68+ h1=${NETIFS[p1]}
69+ h2=${NETIFS[p2]}
70+
71+ vrf_prepare
72+
73+ h1_create
74+ h2_create
75+ }
76+
77+ cleanup ()
78+ {
79+ pre_cleanup
80+
81+ h2_destroy
82+ h1_destroy
83+
84+ vrf_cleanup
85+ }
86+
87+ trap cleanup EXIT
88+
89+ setup_prepare
90+ setup_wait
91+
92+ tests_run
93+
94+ exit $EXIT_STATUS
You can’t perform that action at this time.
0 commit comments