Skip to content

Commit ad11340

Browse files
jpirkodavem330
authored andcommitted
selftests: Add loopback test
Add selftest for loopback feature Signed-off-by: Jiri Pirko <[email protected]> Signed-off-by: Ido Schimmel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 8e44c0c commit ad11340

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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

0 commit comments

Comments
 (0)