2 # SPDX-License-Identifier: GPL-2.0
4 # This test sends traffic from H1 to H2. Either on ingress of $swp1, or on
5 # egress of $swp2, the traffic is acted upon by a pedit action. An ingress
6 # filter installed on $h2 verifies that the packet looks like expected.
8 # +----------------------+ +----------------------+
11 # | | 192.0.2.1/28 | | 192.0.2.2/28 | |
12 # +----|-----------------+ +----------------|-----+
14 # +----|----------------------------------------------------------------|-----+
16 # | +-|----------------------------------------------------------------|-+ |
17 # | | + $swp1 BR $swp2 + | |
18 # | +--------------------------------------------------------------------+ |
19 # +---------------------------------------------------------------------------+
36 simple_if_init
$h1 192.0.2.1/28 2001:db8
:1::1/64
41 simple_if_fini
$h1 192.0.2.1/28 2001:db8
:1::1/64
46 simple_if_init
$h2 192.0.2.2/28 2001:db8
:1::2/64
47 tc qdisc add dev
$h2 clsact
52 tc qdisc del dev
$h2 clsact
53 simple_if_fini
$h2 192.0.2.2/28 2001:db8
:1::2/64
58 ip link add name br1 up
type bridge vlan_filtering
1
59 ip link
set dev
$swp1 master br1
60 ip link
set dev
$swp1 up
61 ip link
set dev
$swp2 master br1
62 ip link
set dev
$swp2 up
64 tc qdisc add dev
$swp1 clsact
65 tc qdisc add dev
$swp2 clsact
70 tc qdisc del dev
$swp2 clsact
71 tc qdisc del dev
$swp1 clsact
73 ip link
set dev
$swp2 down
74 ip link
set dev
$swp2 nomaster
75 ip link
set dev
$swp1 down
76 ip link
set dev
$swp1 nomaster
108 ping_test
$h1 192.0.2.2
113 ping6_test
$h1 2001:db8
:1::2
118 local pedit_locus
=$1; shift
119 local pedit_action
=$1; shift
120 local match_prot
=$1; shift
121 local match_flower
=$1; shift
122 local mz_flags
=$1; shift
124 tc filter add
$pedit_locus handle
101 pref
1 \
125 flower action pedit ex munge
$pedit_action
126 tc filter add dev
$h2 ingress handle
101 pref
1 prot
$match_prot \
127 flower skip_hw
$match_flower action pass
131 $MZ $mz_flags $h1 -c 10 -d 20msec
-p 100 -a own
-b $h2mac -q -t ip
134 pkts
=$
(busywait
"$TC_HIT_TIMEOUT" until_counter_is
">= 10" \
135 tc_rule_handle_stats_get
"dev $h2 ingress" 101)
136 check_err $?
"Expected to get 10 packets, but got $pkts."
138 pkts
=$
(tc_rule_handle_stats_get
"$pedit_locus" 101)
140 check_err $?
"Expected to get 10 packets on pedit rule, but got $pkts."
142 log_test
"$pedit_locus pedit $pedit_action"
144 tc filter del dev
$h2 ingress pref
1
145 tc filter del
$pedit_locus pref
1
150 local locus
=$1; shift
151 local pedit_addr
=$1; shift
152 local flower_addr
=$1; shift
154 do_test_pedit_ip
"$locus" "$pedit_addr set 2001:db8:2::1" ipv6 \
155 "$flower_addr 2001:db8:2::1" \
156 "-6 -A 2001:db8:1::1 -B 2001:db8:1::2"
161 local locus
=$1; shift
162 local pedit_addr
=$1; shift
163 local flower_addr
=$1; shift
165 do_test_pedit_ip
"$locus" "$pedit_addr set 198.51.100.1" ip \
166 "$flower_addr 198.51.100.1" \
167 "-A 192.0.2.1 -B 192.0.2.2"
172 do_test_pedit_ip4
"dev $swp1 ingress" "ip src" src_ip
173 do_test_pedit_ip4
"dev $swp2 egress" "ip src" src_ip
178 do_test_pedit_ip4
"dev $swp1 ingress" "ip dst" dst_ip
179 do_test_pedit_ip4
"dev $swp2 egress" "ip dst" dst_ip
184 do_test_pedit_ip6
"dev $swp1 ingress" "ip6 src" src_ip
185 do_test_pedit_ip6
"dev $swp2 egress" "ip6 src" src_ip
190 do_test_pedit_ip6
"dev $swp1 ingress" "ip6 dst" dst_ip
191 do_test_pedit_ip6
"dev $swp2 egress" "ip6 dst" dst_ip