Skip to content

Commit 4242029

Browse files
amorenozdavem330
authored andcommitted
selftests: openvswitch: add explicit drop testcase
Test explicit drops generate the right drop reason. Also, verify that the kernel rejects flows with actions following an explicit drop. Acked-by: Aaron Conole <[email protected]> Signed-off-by: Adrian Moreno <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent aab1272 commit 4242029

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

tools/testing/selftests/net/openvswitch/openvswitch.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,31 @@ test_drop_reason() {
217217
return 1
218218
fi
219219

220+
# Drop UDP 6000 traffic with an explicit action and an error code.
221+
ovs_add_flow "test_drop_reason" dropreason \
222+
"in_port(1),eth(),eth_type(0x0800),ipv4(src=172.31.110.10,proto=17),udp(dst=6000)" \
223+
'drop(42)'
224+
# Drop UDP 7000 traffic with an explicit action with no error code.
225+
ovs_add_flow "test_drop_reason" dropreason \
226+
"in_port(1),eth(),eth_type(0x0800),ipv4(src=172.31.110.10,proto=17),udp(dst=7000)" \
227+
'drop(0)'
228+
229+
ovs_drop_record_and_run \
230+
"test_drop_reason" ip netns exec client nc -i 1 -zuv 172.31.110.20 6000
231+
ovs_drop_reason_count 0x30004 # OVS_DROP_EXPLICIT_ACTION_ERROR
232+
if [[ "$?" -ne "1" ]]; then
233+
info "Did not detect expected explicit error drops: $?"
234+
return 1
235+
fi
236+
237+
ovs_drop_record_and_run \
238+
"test_drop_reason" ip netns exec client nc -i 1 -zuv 172.31.110.20 7000
239+
ovs_drop_reason_count 0x30003 # OVS_DROP_EXPLICIT_ACTION
240+
if [[ "$?" -ne "1" ]]; then
241+
info "Did not detect expected explicit drops: $?"
242+
return 1
243+
fi
244+
220245
return 0
221246
}
222247

@@ -458,6 +483,16 @@ test_netlink_checks () {
458483
wc -l) == 2 ] || \
459484
return 1
460485

486+
ERR_MSG="Flow actions may not be safe on all matching packets"
487+
PRE_TEST=$(dmesg | grep -c "${ERR_MSG}")
488+
ovs_add_flow "test_netlink_checks" nv0 \
489+
'in_port(1),eth(),eth_type(0x0806),arp()' 'drop(0),2' \
490+
&> /dev/null && return 1
491+
POST_TEST=$(dmesg | grep -c "${ERR_MSG}")
492+
if [ "$PRE_TEST" == "$POST_TEST" ]; then
493+
info "failed - error not generated"
494+
return 1
495+
fi
461496
return 0
462497
}
463498

0 commit comments

Comments
 (0)