|
3 | 3 |
|
4 | 4 | ALL_TESTS="gact_drop_and_ok_test mirred_egress_redirect_test \
|
5 | 5 | mirred_egress_mirror_test matchall_mirred_egress_mirror_test \
|
6 |
| - gact_trap_test mirred_egress_to_ingress_test" |
| 6 | + gact_trap_test mirred_egress_to_ingress_test \ |
| 7 | + mirred_egress_to_ingress_tcp_test" |
7 | 8 | NUM_NETIFS=4
|
8 | 9 | source tc_common.sh
|
9 | 10 | source lib.sh
|
@@ -198,6 +199,52 @@ mirred_egress_to_ingress_test()
|
198 | 199 | log_test "mirred_egress_to_ingress ($tcflags)"
|
199 | 200 | }
|
200 | 201 |
|
| 202 | +mirred_egress_to_ingress_tcp_test() |
| 203 | +{ |
| 204 | + local tmpfile=$(mktemp) tmpfile1=$(mktemp) |
| 205 | + |
| 206 | + RET=0 |
| 207 | + dd conv=sparse status=none if=/dev/zero bs=1M count=2 of=$tmpfile |
| 208 | + tc filter add dev $h1 protocol ip pref 100 handle 100 egress flower \ |
| 209 | + $tcflags ip_proto tcp src_ip 192.0.2.1 dst_ip 192.0.2.2 \ |
| 210 | + action ct commit nat src addr 192.0.2.2 pipe \ |
| 211 | + action ct clear pipe \ |
| 212 | + action ct commit nat dst addr 192.0.2.1 pipe \ |
| 213 | + action ct clear pipe \ |
| 214 | + action skbedit ptype host pipe \ |
| 215 | + action mirred ingress redirect dev $h1 |
| 216 | + tc filter add dev $h1 protocol ip pref 101 handle 101 egress flower \ |
| 217 | + $tcflags ip_proto icmp \ |
| 218 | + action mirred ingress redirect dev $h1 |
| 219 | + tc filter add dev $h1 protocol ip pref 102 handle 102 ingress flower \ |
| 220 | + ip_proto icmp \ |
| 221 | + action drop |
| 222 | + |
| 223 | + ip vrf exec v$h1 nc --recv-only -w10 -l -p 12345 -o $tmpfile1 & |
| 224 | + local rpid=$! |
| 225 | + ip vrf exec v$h1 nc -w1 --send-only 192.0.2.2 12345 <$tmpfile |
| 226 | + wait -n $rpid |
| 227 | + cmp -s $tmpfile $tmpfile1 |
| 228 | + check_err $? "server output check failed" |
| 229 | + |
| 230 | + $MZ $h1 -c 10 -p 64 -a $h1mac -b $h1mac -A 192.0.2.1 -B 192.0.2.1 \ |
| 231 | + -t icmp "ping,id=42,seq=5" -q |
| 232 | + tc_check_packets "dev $h1 egress" 101 10 |
| 233 | + check_err $? "didn't mirred redirect ICMP" |
| 234 | + tc_check_packets "dev $h1 ingress" 102 10 |
| 235 | + check_err $? "didn't drop mirred ICMP" |
| 236 | + local overlimits=$(tc_rule_stats_get ${h1} 101 egress .overlimits) |
| 237 | + test ${overlimits} = 10 |
| 238 | + check_err $? "wrong overlimits, expected 10 got ${overlimits}" |
| 239 | + |
| 240 | + tc filter del dev $h1 egress protocol ip pref 100 handle 100 flower |
| 241 | + tc filter del dev $h1 egress protocol ip pref 101 handle 101 flower |
| 242 | + tc filter del dev $h1 ingress protocol ip pref 102 handle 102 flower |
| 243 | + |
| 244 | + rm -f $tmpfile $tmpfile1 |
| 245 | + log_test "mirred_egress_to_ingress_tcp ($tcflags)" |
| 246 | +} |
| 247 | + |
201 | 248 | setup_prepare()
|
202 | 249 | {
|
203 | 250 | h1=${NETIFS[p1]}
|
|
0 commit comments