2 # SPDX-License-Identifier: GPL-2.0
4 ALL_TESTS
="gact_drop_and_ok_test mirred_egress_redirect_test \
5 mirred_egress_mirror_test gact_trap_test"
14 simple_if_init
$h1 192.0.2.1/24
19 simple_if_fini
$h1 192.0.2.1/24
24 simple_if_init
$h2 192.0.2.2/24
25 tc qdisc add dev
$h2 clsact
30 tc qdisc del dev
$h2 clsact
31 simple_if_fini
$h2 192.0.2.2/24
36 simple_if_init
$swp1 192.0.2.2/24
37 tc qdisc add dev
$swp1 clsact
39 simple_if_init
$swp2 192.0.2.1/24
44 simple_if_fini
$swp2 192.0.2.1/24
46 tc qdisc del dev
$swp1 clsact
47 simple_if_fini
$swp1 192.0.2.2/24
56 tc filter add dev
$h2 ingress protocol ip pref
1 handle
101 flower \
57 $tcflags dst_ip
192.0.2.2 action drop
59 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
62 tc_check_packets
"dev $h2 ingress" 101 1
63 check_fail $?
"Matched without redirect rule inserted"
65 tc filter add dev
$swp1 ingress protocol ip pref
1 handle
101 flower \
66 $tcflags dst_ip
192.0.2.2 action mirred egress
$action \
69 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
72 tc_check_packets
"dev $h2 ingress" 101 1
73 check_err $?
"Did not match incoming $action packet"
75 tc filter del dev
$swp1 ingress protocol ip pref
1 handle
101 flower
76 tc filter del dev
$h2 ingress protocol ip pref
1 handle
101 flower
78 log_test
"mirred egress $action ($tcflags)"
81 gact_drop_and_ok_test
()
85 tc filter add dev
$swp1 ingress protocol ip pref
2 handle
102 flower \
86 $tcflags dst_ip
192.0.2.2 action drop
88 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
91 tc_check_packets
"dev $swp1 ingress" 102 1
92 check_err $?
"Packet was not dropped"
94 tc filter add dev
$swp1 ingress protocol ip pref
1 handle
101 flower \
95 $tcflags dst_ip
192.0.2.2 action ok
97 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
100 tc_check_packets
"dev $swp1 ingress" 101 1
101 check_err $?
"Did not see passed packet"
103 tc_check_packets
"dev $swp1 ingress" 102 2
104 check_fail $?
"Packet was dropped and it should not reach here"
106 tc filter del dev
$swp1 ingress protocol ip pref
2 handle
102 flower
107 tc filter del dev
$swp1 ingress protocol ip pref
1 handle
101 flower
109 log_test
"gact drop and ok ($tcflags)"
116 if [[ "$tcflags" != "skip_sw" ]]; then
120 tc filter add dev
$swp1 ingress protocol ip pref
1 handle
101 flower \
121 skip_hw dst_ip
192.0.2.2 action drop
122 tc filter add dev
$swp1 ingress protocol ip pref
3 handle
103 flower \
123 $tcflags dst_ip
192.0.2.2 action mirred egress redirect \
126 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
129 tc_check_packets
"dev $swp1 ingress" 101 1
130 check_fail $?
"Saw packet without trap rule inserted"
132 tc filter add dev
$swp1 ingress protocol ip pref
2 handle
102 flower \
133 $tcflags dst_ip
192.0.2.2 action
trap
135 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
138 tc_check_packets
"dev $swp1 ingress" 102 1
139 check_err $?
"Packet was not trapped"
141 tc_check_packets
"dev $swp1 ingress" 101 1
142 check_err $?
"Did not see trapped packet"
144 tc filter del dev
$swp1 ingress protocol ip pref
3 handle
103 flower
145 tc filter del dev
$swp1 ingress protocol ip pref
2 handle
102 flower
146 tc filter del dev
$swp1 ingress protocol ip pref
1 handle
101 flower
148 log_test
"trap ($tcflags)"
162 swp1origmac
=$
(mac_get
$swp1)
163 swp2origmac
=$
(mac_get
$swp2)
164 ip link
set $swp1 address
$h2mac
165 ip link
set $swp2 address
$h1mac
184 ip link
set $swp2 address
$swp2origmac
185 ip link
set $swp1 address
$swp1origmac
188 mirred_egress_redirect_test
()
190 mirred_egress_test
"redirect"
193 mirred_egress_mirror_test
()
195 mirred_egress_test
"mirror"
206 if [[ $?
-ne 0 ]]; then
207 log_info
"Could not test offloaded functionality"