| .. | .. |
|---|
| 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" |
|---|
| 6 | + gact_trap_test mirred_egress_to_ingress_tcp_test" |
|---|
| 7 | 7 | NUM_NETIFS=4 |
|---|
| 8 | 8 | source tc_common.sh |
|---|
| 9 | 9 | source lib.sh |
|---|
| .. | .. |
|---|
| 153 | 153 | log_test "trap ($tcflags)" |
|---|
| 154 | 154 | } |
|---|
| 155 | 155 | |
|---|
| 156 | +mirred_egress_to_ingress_tcp_test() |
|---|
| 157 | +{ |
|---|
| 158 | + local tmpfile=$(mktemp) tmpfile1=$(mktemp) |
|---|
| 159 | + |
|---|
| 160 | + RET=0 |
|---|
| 161 | + dd conv=sparse status=none if=/dev/zero bs=1M count=2 of=$tmpfile |
|---|
| 162 | + tc filter add dev $h1 protocol ip pref 100 handle 100 egress flower \ |
|---|
| 163 | + $tcflags ip_proto tcp src_ip 192.0.2.1 dst_ip 192.0.2.2 \ |
|---|
| 164 | + action ct commit nat src addr 192.0.2.2 pipe \ |
|---|
| 165 | + action ct clear pipe \ |
|---|
| 166 | + action ct commit nat dst addr 192.0.2.1 pipe \ |
|---|
| 167 | + action ct clear pipe \ |
|---|
| 168 | + action skbedit ptype host pipe \ |
|---|
| 169 | + action mirred ingress redirect dev $h1 |
|---|
| 170 | + tc filter add dev $h1 protocol ip pref 101 handle 101 egress flower \ |
|---|
| 171 | + $tcflags ip_proto icmp \ |
|---|
| 172 | + action mirred ingress redirect dev $h1 |
|---|
| 173 | + tc filter add dev $h1 protocol ip pref 102 handle 102 ingress flower \ |
|---|
| 174 | + ip_proto icmp \ |
|---|
| 175 | + action drop |
|---|
| 176 | + |
|---|
| 177 | + ip vrf exec v$h1 nc --recv-only -w10 -l -p 12345 -o $tmpfile1 & |
|---|
| 178 | + local rpid=$! |
|---|
| 179 | + ip vrf exec v$h1 nc -w1 --send-only 192.0.2.2 12345 <$tmpfile |
|---|
| 180 | + wait -n $rpid |
|---|
| 181 | + cmp -s $tmpfile $tmpfile1 |
|---|
| 182 | + check_err $? "server output check failed" |
|---|
| 183 | + |
|---|
| 184 | + $MZ $h1 -c 10 -p 64 -a $h1mac -b $h1mac -A 192.0.2.1 -B 192.0.2.1 \ |
|---|
| 185 | + -t icmp "ping,id=42,seq=5" -q |
|---|
| 186 | + tc_check_packets "dev $h1 egress" 101 10 |
|---|
| 187 | + check_err $? "didn't mirred redirect ICMP" |
|---|
| 188 | + tc_check_packets "dev $h1 ingress" 102 10 |
|---|
| 189 | + check_err $? "didn't drop mirred ICMP" |
|---|
| 190 | + local overlimits=$(tc_rule_stats_get ${h1} 101 egress .overlimits) |
|---|
| 191 | + test ${overlimits} = 10 |
|---|
| 192 | + check_err $? "wrong overlimits, expected 10 got ${overlimits}" |
|---|
| 193 | + |
|---|
| 194 | + tc filter del dev $h1 egress protocol ip pref 100 handle 100 flower |
|---|
| 195 | + tc filter del dev $h1 egress protocol ip pref 101 handle 101 flower |
|---|
| 196 | + tc filter del dev $h1 ingress protocol ip pref 102 handle 102 flower |
|---|
| 197 | + |
|---|
| 198 | + rm -f $tmpfile $tmpfile1 |
|---|
| 199 | + log_test "mirred_egress_to_ingress_tcp ($tcflags)" |
|---|
| 200 | +} |
|---|
| 201 | + |
|---|
| 156 | 202 | setup_prepare() |
|---|
| 157 | 203 | { |
|---|
| 158 | 204 | h1=${NETIFS[p1]} |
|---|