Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3
4ALL_TESTS="unreachable_chain_test gact_goto_chain_test"
5NUM_NETIFS=2
6source tc_common.sh
7source lib.sh
8
9tcflags="skip_hw"
10
11h1_create()
12{
13 simple_if_init $h1 192.0.2.1/24
14}
15
16h1_destroy()
17{
18 simple_if_fini $h1 192.0.2.1/24
19}
20
21h2_create()
22{
23 simple_if_init $h2 192.0.2.2/24
24 tc qdisc add dev $h2 clsact
25}
26
27h2_destroy()
28{
29 tc qdisc del dev $h2 clsact
30 simple_if_fini $h2 192.0.2.2/24
31}
32
33unreachable_chain_test()
34{
35 RET=0
36
37 tc filter add dev $h2 ingress chain 1 protocol ip pref 1 handle 1101 \
38 flower $tcflags dst_mac $h2mac action drop
39
40 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
41 -t ip -q
42
43 tc_check_packets "dev $h2 ingress" 1101 1
44 check_fail $? "matched on filter in unreachable chain"
45
46 tc filter del dev $h2 ingress chain 1 protocol ip pref 1 handle 1101 \
47 flower
48
49 log_test "unreachable chain ($tcflags)"
50}
51
52gact_goto_chain_test()
53{
54 RET=0
55
56 tc filter add dev $h2 ingress chain 1 protocol ip pref 1 handle 1101 \
57 flower $tcflags dst_mac $h2mac action drop
58 tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \
59 $tcflags dst_mac $h2mac action drop
60 tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \
61 $tcflags dst_mac $h2mac action goto chain 1
62
63 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
64 -t ip -q
65
66 tc_check_packets "dev $h2 ingress" 102 1
67 check_fail $? "Matched on a wrong filter"
68
69 tc_check_packets "dev $h2 ingress" 101 1
70 check_err $? "Did not match on correct filter with goto chain action"
71
72 tc_check_packets "dev $h2 ingress" 1101 1
73 check_err $? "Did not match on correct filter in chain 1"
74
75 tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower
76 tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower
77 tc filter del dev $h2 ingress chain 1 protocol ip pref 1 handle 1101 \
78 flower
79
80 log_test "gact goto chain ($tcflags)"
81}
82
83setup_prepare()
84{
85 h1=${NETIFS[p1]}
86 h2=${NETIFS[p2]}
87 h1mac=$(mac_get $h1)
88 h2mac=$(mac_get $h2)
89
90 vrf_prepare
91
92 h1_create
93 h2_create
94}
95
96cleanup()
97{
98 pre_cleanup
99
100 h2_destroy
101 h1_destroy
102
103 vrf_cleanup
104}
105
106trap cleanup EXIT
107
108setup_prepare
109setup_wait
110
111tests_run
112
113tc_offload_check
114if [[ $? -ne 0 ]]; then
115 log_info "Could not test offloaded functionality"
116else
117 tcflags="skip_sw"
118 tests_run
119fi
120
121exit $EXIT_STATUS