2 # SPDX-License-Identifier: GPL-2.0
4 ALL_TESTS
="match_indev_egress_test"
11 simple_if_init
$h1 192.0.1.1/24
13 ip route add
192.0.2.0/24 vrf v
$h1 nexthop via
192.0.1.2
14 ip route add
192.0.3.0/24 vrf v
$h1 nexthop via
192.0.1.2
19 ip route del
192.0.3.0/24 vrf v
$h1
20 ip route del
192.0.2.0/24 vrf v
$h1
22 simple_if_fini
$h1 192.0.1.1/24
27 simple_if_init
$h2 192.0.2.1/24
29 ip route add
192.0.1.0/24 vrf v
$h2 nexthop via
192.0.2.2
30 ip route add
192.0.3.0/24 vrf v
$h2 nexthop via
192.0.2.2
35 ip route del
192.0.3.0/24 vrf v
$h2
36 ip route del
192.0.1.0/24 vrf v
$h2
38 simple_if_fini
$h2 192.0.2.1/24
43 simple_if_init
$h3 192.0.3.1/24
45 ip route add
192.0.1.0/24 vrf v
$h3 nexthop via
192.0.3.2
46 ip route add
192.0.2.0/24 vrf v
$h3 nexthop via
192.0.3.2
51 ip route del
192.0.2.0/24 vrf v
$h3
52 ip route del
192.0.1.0/24 vrf v
$h3
54 simple_if_fini
$h3 192.0.3.1/24
60 ip link
set dev
$rp1 up
61 ip link
set dev
$rp2 up
62 ip link
set dev
$rp3 up
64 tc qdisc add dev
$rp3 clsact
66 ip address add
192.0.1.2/24 dev
$rp1
67 ip address add
192.0.2.2/24 dev
$rp2
68 ip address add
192.0.3.2/24 dev
$rp3
73 ip address del
192.0.3.2/24 dev
$rp3
74 ip address del
192.0.2.2/24 dev
$rp2
75 ip address del
192.0.1.2/24 dev
$rp1
77 tc qdisc del dev
$rp3 clsact
79 ip link
set dev
$rp3 down
80 ip link
set dev
$rp2 down
81 ip link
set dev
$rp1 down
84 match_indev_egress_test
()
88 tc filter add dev
$rp3 egress protocol ip pref
1 handle
101 flower \
89 $tcflags indev
$rp1 dst_ip
192.0.3.1 action drop
90 tc filter add dev
$rp3 egress protocol ip pref
2 handle
102 flower \
91 $tcflags indev
$rp2 dst_ip
192.0.3.1 action drop
93 $MZ $h1 -c 1 -p 64 -a $h1mac -b $rp1mac -A 192.0.1.1 -B 192.0.3.1 \
96 tc_check_packets
"dev $rp3 egress" 102 1
97 check_fail $?
"Matched on a wrong filter"
99 tc_check_packets
"dev $rp3 egress" 101 1
100 check_err $?
"Did not match on correct filter"
102 $MZ $h2 -c 1 -p 64 -a $h2mac -b $rp2mac -A 192.0.2.1 -B 192.0.3.1 \
105 tc_check_packets
"dev $rp3 egress" 101 2
106 check_fail $?
"Matched on a wrong filter"
108 tc_check_packets
"dev $rp3 egress" 102 1
109 check_err $?
"Did not match on correct filter"
111 tc filter del dev
$rp3 egress protocol ip pref
2 handle
102 flower
112 tc filter del dev
$rp3 egress protocol ip pref
1 handle
101 flower
114 log_test
"indev egress match ($tcflags)"
129 rp1mac
=$
(mac_get
$rp1)
131 rp2mac
=$
(mac_get
$rp2)
165 if [[ $?
-ne 0 ]]; then
166 log_info
"Could not test offloaded functionality"