selftests: openvswitch: don't hardcode the drop reason subsys
authorJakub Kicinski <kuba@kernel.org>
Tue, 4 Mar 2025 18:06:15 +0000 (10:06 -0800)
committerJakub Kicinski <kuba@kernel.org>
Fri, 7 Mar 2025 00:45:43 +0000 (16:45 -0800)
WiFi removed one of their subsys entries from drop reasons, in
commit 286e69677065 ("wifi: mac80211: Drop cooked monitor support")
SKB_DROP_REASON_SUBSYS_OPENVSWITCH is now 2 not 3.
The drop reasons are not uAPI, read the correct value
from debug info.

We need to enable vmlinux BTF, otherwise pahole needs
a few GB of memory to decode the enum name.

Acked-by: Stanislav Fomichev <sdf@fomichev.me>
Acked-by: Aaron Conole <aconole@redhat.com>
Link: https://patch.msgid.link/20250304180615.945945-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
tools/testing/selftests/net/config
tools/testing/selftests/net/openvswitch/openvswitch.sh

index a86f3e752ce2fa66d49425e854f1cd6e4a403952..b0d0eda829d08def833db63eebad6ef4feb28122 100644 (file)
@@ -18,6 +18,8 @@ CONFIG_DUMMY=y
 CONFIG_BRIDGE_VLAN_FILTERING=y
 CONFIG_BRIDGE=y
 CONFIG_CRYPTO_CHACHA20POLY1305=m
+CONFIG_DEBUG_INFO_BTF=y
+CONFIG_DEBUG_INFO_BTF_MODULES=n
 CONFIG_VLAN_8021Q=y
 CONFIG_GENEVE=m
 CONFIG_IFB=y
index 960e1ab4dd04b15300e1699ff50dc40fa6aaa23a..3c8d3455d8e7f173bf36252f7d391e599a1fa33e 100755 (executable)
@@ -330,6 +330,11 @@ test_psample() {
 # - drop packets and verify the right drop reason is reported
 test_drop_reason() {
        which perf >/dev/null 2>&1 || return $ksft_skip
+       which pahole >/dev/null 2>&1 || return $ksft_skip
+
+       ovs_drop_subsys=$(pahole -C skb_drop_reason_subsys |
+                             awk '/OPENVSWITCH/ { print $3; }' |
+                             tr -d ,)
 
        sbx_add "test_drop_reason" || return $?
 
@@ -373,7 +378,7 @@ test_drop_reason() {
                "in_port(2),eth(),eth_type(0x0800),ipv4(src=172.31.110.20,proto=1),icmp()" 'drop'
 
        ovs_drop_record_and_run "test_drop_reason" ip netns exec client ping -c 2 172.31.110.20
-       ovs_drop_reason_count 0x30001 # OVS_DROP_FLOW_ACTION
+       ovs_drop_reason_count 0x${ovs_drop_subsys}0001 # OVS_DROP_FLOW_ACTION
        if [[ "$?" -ne "2" ]]; then
                info "Did not detect expected drops: $?"
                return 1
@@ -390,7 +395,7 @@ test_drop_reason() {
 
        ovs_drop_record_and_run \
             "test_drop_reason" ip netns exec client nc -i 1 -zuv 172.31.110.20 6000
-       ovs_drop_reason_count 0x30004 # OVS_DROP_EXPLICIT_ACTION_ERROR
+       ovs_drop_reason_count 0x${ovs_drop_subsys}0004 # OVS_DROP_EXPLICIT_ACTION_ERROR
        if [[ "$?" -ne "1" ]]; then
                info "Did not detect expected explicit error drops: $?"
                return 1
@@ -398,7 +403,7 @@ test_drop_reason() {
 
        ovs_drop_record_and_run \
             "test_drop_reason" ip netns exec client nc -i 1 -zuv 172.31.110.20 7000
-       ovs_drop_reason_count 0x30003 # OVS_DROP_EXPLICIT_ACTION
+       ovs_drop_reason_count 0x${ovs_drop_subsys}0003 # OVS_DROP_EXPLICIT_ACTION
        if [[ "$?" -ne "1" ]]; then
                info "Did not detect expected explicit drops: $?"
                return 1