@@ -20,6 +20,7 @@ ALL_TESTS="
20
20
test_port_range_ipv4_tcp
21
21
test_port_range_ipv6_udp
22
22
test_port_range_ipv6_tcp
23
+ test_port_range_ipv4_udp_drop
23
24
"
24
25
25
26
NUM_NETIFS=4
@@ -194,6 +195,51 @@ test_port_range_ipv6_tcp()
194
195
__test_port_range $proto $ip_proto $sip $dip $mode " $name "
195
196
}
196
197
198
+ test_port_range_ipv4_udp_drop ()
199
+ {
200
+ local proto=ipv4
201
+ local ip_proto=udp
202
+ local sip=192.0.2.1
203
+ local dip=192.0.2.2
204
+ local mode=" -4"
205
+ local name=" IPv4 UDP Drop"
206
+ local dmac=$( mac_get $h2 )
207
+ local smac=$( mac_get $h1 )
208
+ local sport_min=2000
209
+ local sport_max=3000
210
+ local sport_mid=$(( sport_min + (sport_max - sport_min) / 2 ))
211
+ local dport=5000
212
+
213
+ RET=0
214
+
215
+ tc filter add dev $swp1 ingress protocol $proto handle 101 pref 1 \
216
+ flower src_ip $sip dst_ip $dip ip_proto $ip_proto \
217
+ src_port $sport_min -$sport_max \
218
+ dst_port $dport \
219
+ action drop
220
+
221
+ # Test ports outside range - should pass
222
+ $MZ $mode $h1 -c 1 -q -p 100 -a $smac -b $dmac -A $sip -B $dip \
223
+ -t $ip_proto " sp=$(( sport_min - 1 )) ,dp=$dport "
224
+ $MZ $mode $h1 -c 1 -q -p 100 -a $smac -b $dmac -A $sip -B $dip \
225
+ -t $ip_proto " sp=$(( sport_max + 1 )) ,dp=$dport "
226
+
227
+ # Test ports inside range - should be dropped
228
+ $MZ $mode $h1 -c 1 -q -p 100 -a $smac -b $dmac -A $sip -B $dip \
229
+ -t $ip_proto " sp=$sport_min ,dp=$dport "
230
+ $MZ $mode $h1 -c 1 -q -p 100 -a $smac -b $dmac -A $sip -B $dip \
231
+ -t $ip_proto " sp=$sport_mid ,dp=$dport "
232
+ $MZ $mode $h1 -c 1 -q -p 100 -a $smac -b $dmac -A $sip -B $dip \
233
+ -t $ip_proto " sp=$sport_max ,dp=$dport "
234
+
235
+ tc_check_packets " dev $swp1 ingress" 101 3
236
+ check_err $? " Filter did not drop the expected number of packets"
237
+
238
+ tc filter del dev $swp1 ingress protocol $proto pref 1 handle 101 flower
239
+
240
+ log_test " Port range matching - $name "
241
+ }
242
+
197
243
setup_prepare ()
198
244
{
199
245
h1=${NETIFS[p1]}
0 commit comments