Tests including routing rule checks were failing on systems with non-standard routing rules, causing issues when trying to run them on some deployments. These failures occurred because tests performed exact output matching on the full output of 'ovs-appctl ovs/route/rule/show', which includes both user-added and system-cached rules.
When the system has additional routing rules that meet certain criteria (FR_ACT_TO_TBL action without unsupported selectors like fwmark, dport, sport, iif, ipproto, or tun_id), OVS caches them, as expected, causing them to appear in the "Cached:" section of the output. Tests that expect exact output fail when encountering these legitimate, albeit unexpected, cached rules. The following affected tests were modified to verify only the expected behavior rather than requiring exact output matches: - system-route.at (ovs-route - unsupported rules): Captures full initial cache state before adding test rules, verifies that the cache state remains unchanged after adding unsupported rules (keeping the intent of the test). - ovs-router.at: For standard rule existence checks, changed from exact match to verifying each expected rule exists independently. For user rule verification, added filtering to show only "User:" rules, ignoring "Cached:" system rules entirely. 3. tunnel-push-pop.at (tunnel configuration with routing rules): Added filter to output to show only "User:" rules when verifying routing rule configuration. Signed-off-by: Matteo Perin <[email protected]> --- tests/ovs-router.at | 114 ++++++++------------------------------- tests/system-route.at | 51 +++++++----------- tests/tunnel-push-pop.at | 5 +- 3 files changed, 43 insertions(+), 127 deletions(-) diff --git a/tests/ovs-router.at b/tests/ovs-router.at index b5282fd19..3358b0eee 100644 --- a/tests/ovs-router.at +++ b/tests/ovs-router.at @@ -247,64 +247,19 @@ OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=dummy]) AT_CHECK([ovs-appctl netdev-dummy/ip4addr br0 192.0.2.1/24], [0], [OK ]) -dnl Check standard rules exist. -AT_CHECK([ovs-appctl ovs/route/rule/show], [0], [dnl -Cached: 0: from all lookup local -Cached: 32766: from all lookup main -Cached: 32767: from all lookup default -]) -AT_CHECK([ovs-appctl ovs/route/rule/show -6], [0], [dnl -Cached: 0: from all lookup local -Cached: 32766: from all lookup main -]) - -dnl Check JSON output for standard rules. -AT_CHECK([ovs-appctl --format=json --pretty ovs/route/rule/show], [0], [dnl -[[ - { - "from": "all", - "invert": false, - "ipv4": true, - "lookup": 255, - "priority": 0, - "src-prefix": 0, - "user": false}, - { - "from": "all", - "invert": false, - "ipv4": true, - "lookup": 254, - "priority": 32766, - "src-prefix": 0, - "user": false}, - { - "from": "all", - "invert": false, - "ipv4": true, - "lookup": 253, - "priority": 32767, - "src-prefix": 0, - "user": false}]] -]) -AT_CHECK([ovs-appctl --format=json --pretty ovs/route/rule/show -6], [0], [dnl -[[ - { - "from": "all", - "invert": false, - "ipv4": false, - "lookup": 255, - "priority": 0, - "src-prefix": 0, - "user": false}, - { - "from": "all", - "invert": false, - "ipv4": false, - "lookup": 254, - "priority": 32766, - "src-prefix": 0, - "user": false}]] -]) +dnl Check standard rules exist (allow additional cached rules from system). +AT_CHECK([ovs-appctl ovs/route/rule/show | grep -q "Cached: 0: from all lookup local"]) +AT_CHECK([ovs-appctl ovs/route/rule/show | grep -q "Cached: 32766: from all lookup main"]) +AT_CHECK([ovs-appctl ovs/route/rule/show | grep -q "Cached: 32767: from all lookup default"]) +AT_CHECK([ovs-appctl ovs/route/rule/show -6 | grep -q "Cached: 0: from all lookup local"]) +AT_CHECK([ovs-appctl ovs/route/rule/show -6 | grep -q "Cached: 32766: from all lookup main"]) + +dnl Check JSON output contains standard rules (allow additional system rules). +AT_CHECK([ovs-appctl --format=json ovs/route/rule/show | grep -q '"priority":0']) +AT_CHECK([ovs-appctl --format=json ovs/route/rule/show | grep -q '"priority":32766']) +AT_CHECK([ovs-appctl --format=json ovs/route/rule/show | grep -q '"priority":32767']) +AT_CHECK([ovs-appctl --format=json ovs/route/rule/show -6 | grep -q '"priority":0']) +AT_CHECK([ovs-appctl --format=json ovs/route/rule/show -6 | grep -q '"priority":32766']) OVS_VSWITCHD_STOP AT_CLEANUP @@ -330,47 +285,35 @@ AT_CHECK([ovs-appctl ovs/route/rule/add from=192.0.2.10/32 table=11], [0], [OK ]) AT_CHECK([ovs-appctl ovs/route/rule/add from=192.0.2.20/32 table=12], [0], [OK ]) -AT_CHECK([ovs-appctl ovs/route/rule/show], [0], [dnl -Cached: 0: from all lookup local +AT_CHECK([ovs-appctl ovs/route/rule/show | grep "^User:" | sort], [0], [dnl User: 32764: from 192.0.2.20 lookup 12 User: 32765: from 192.0.2.10 lookup 11 -Cached: 32766: from all lookup main -Cached: 32767: from all lookup default ]) AT_CHECK([ovs-appctl ovs/route/rule/add from=192.0.2.10/32 table=11], [0], [OK ]) AT_CHECK([ovs-appctl ovs/route/rule/add from=192.0.2.10/32 table=11], [0], [OK ]) -AT_CHECK([ovs-appctl ovs/route/rule/show], [0], [dnl -Cached: 0: from all lookup local +AT_CHECK([ovs-appctl ovs/route/rule/show | grep "^User:" | sort], [0], [dnl User: 32762: from 192.0.2.10 lookup 11 User: 32763: from 192.0.2.10 lookup 11 User: 32764: from 192.0.2.20 lookup 12 User: 32765: from 192.0.2.10 lookup 11 -Cached: 32766: from all lookup main -Cached: 32767: from all lookup default ]) AT_CHECK([ovs-appctl ovs/route/rule/del from=192.0.2.10/32 table=11], [0], [OK ]) -AT_CHECK([ovs-appctl ovs/route/rule/show], [0], [dnl -Cached: 0: from all lookup local +AT_CHECK([ovs-appctl ovs/route/rule/show | grep "^User:" | sort], [0], [dnl User: 32763: from 192.0.2.10 lookup 11 User: 32764: from 192.0.2.20 lookup 12 User: 32765: from 192.0.2.10 lookup 11 -Cached: 32766: from all lookup main -Cached: 32767: from all lookup default ]) AT_CHECK([ovs-appctl ovs/route/rule/del from=192.0.2.10/32 prio=32765 table=11], [0], [OK ]) -AT_CHECK([ovs-appctl ovs/route/rule/show], [0], [dnl -Cached: 0: from all lookup local +AT_CHECK([ovs-appctl ovs/route/rule/show | grep "^User:" | sort], [0], [dnl User: 32763: from 192.0.2.10 lookup 11 User: 32764: from 192.0.2.20 lookup 12 -Cached: 32766: from all lookup main -Cached: 32767: from all lookup default ]) OVS_VSWITCHD_STOP @@ -435,11 +378,8 @@ dnl Check that IPv4 route in table 11 is matched and the default IPv6 route dnl in table 11 doesn't swallow other IPv4 traffic. AT_CHECK([ovs-appctl ovs/route/rule/add from=10.0.0.11/32 table=11], [0], [OK ]) -AT_CHECK([ovs-appctl ovs/route/rule/show], [0], [dnl -Cached: 0: from all lookup local +AT_CHECK([ovs-appctl ovs/route/rule/show | grep "^User:"], [0], [dnl User: 32765: from 10.0.0.11 lookup 11 -Cached: 32766: from all lookup main -Cached: 32767: from all lookup default ]) AT_CHECK([ovs-appctl ovs/route/lookup 10.0.0.100 src=10.0.0.11], [0], [dnl src 10.0.0.11 @@ -471,16 +411,11 @@ User: ::/0 dev p1 GW 2001:db8:cafe::10 SRC 2001:db8:cafe::11 table 10 ]) AT_CHECK([ovs-appctl ovs/route/rule/add -6 from=all table=10], [0], [OK ]) -AT_CHECK([ovs-appctl ovs/route/rule/show], [0], [dnl -Cached: 0: from all lookup local +AT_CHECK([ovs-appctl ovs/route/rule/show | grep "^User:"], [0], [dnl User: 32765: from 10.0.0.11 lookup 11 -Cached: 32766: from all lookup main -Cached: 32767: from all lookup default ]) -AT_CHECK([ovs-appctl ovs/route/rule/show -6], [0], [dnl -Cached: 0: from all lookup local +AT_CHECK([ovs-appctl ovs/route/rule/show -6 | grep "^User:"], [0], [dnl User: 32764: from all lookup 10 -Cached: 32766: from all lookup main ]) AT_CHECK([ovs-appctl ovs/route/lookup 2004::44 src=2001:db8:cafe::22], [0], [dnl src 2001:db8:cafe::22 @@ -503,18 +438,13 @@ AT_CHECK([ovs-appctl ovs/route/rule/add -6 not from=2001:db8:cafe::100 table=6], ]) AT_CHECK([ovs-appctl ovs/route/rule/add not from=10.0.0.100 table=4], [0], [OK ]) -AT_CHECK([ovs-appctl ovs/route/rule/show], [0], [dnl -Cached: 0: from all lookup local +AT_CHECK([ovs-appctl ovs/route/rule/show | grep "^User:" | sort], [0], [dnl User: 32762: not from 10.0.0.100 lookup 4 User: 32765: from 10.0.0.11 lookup 11 -Cached: 32766: from all lookup main -Cached: 32767: from all lookup default ]) -AT_CHECK([ovs-appctl ovs/route/rule/show -6], [0], [dnl -Cached: 0: from all lookup local +AT_CHECK([ovs-appctl ovs/route/rule/show -6 | grep "^User:" | sort], [0], [dnl User: 32763: not from 2001:db8:cafe::100 lookup 6 User: 32764: from all lookup 10 -Cached: 32766: from all lookup main ]) AT_CHECK([ovs-appctl ovs/route/lookup 2004::44 src=2001:db8:cafe::22], [0], [dnl src 2001:db8:cafe::22 diff --git a/tests/system-route.at b/tests/system-route.at index 0b4b4b7e9..b87ab9db1 100644 --- a/tests/system-route.at +++ b/tests/system-route.at @@ -343,45 +343,34 @@ on_exit 'ip link del p1-route' AT_CHECK([ip tuntap add name p1-route mode tap]) AT_CHECK([ip link set p1-route up]) -dnl Check there are no non-standard rules cached in OVS. -AT_CHECK([ovs-appctl ovs/route/rule/show], [0], [dnl -Cached: 0: from all lookup local -Cached: 32766: from all lookup main -Cached: 32767: from all lookup default -]) -AT_CHECK([ovs-appctl ovs/route/rule/show -6], [0], [dnl -Cached: 0: from all lookup local -Cached: 32766: from all lookup main -]) - -dnl Add unsupported rules to kernel. +dnl Register cleanup for all rules we are going to add. on_exit 'ip rule del priority 100 fwmark 0x16 lookup 42' -AT_CHECK([ip rule add priority 100 fwmark 0x16 lookup 42]) on_exit 'ip rule del priority 101 from 10.0.0.1 dport 22 lookup 42' -AT_CHECK([ip rule add priority 101 from 10.0.0.1 dport 22 lookup 42]) on_exit 'ip rule del priority 102 from 10.0.0.1 sport 22 lookup 42' -AT_CHECK([ip rule add priority 102 from 10.0.0.1 sport 22 lookup 42]) on_exit 'ip rule del priority 103 from 10.0.0.1 tun_id 22 lookup 42' -AT_CHECK([ip rule add priority 103 from 10.0.0.1 tun_id 22 lookup 42]) on_exit 'ip rule del priority 104 iif p1-route lookup 42' -AT_CHECK([ip rule add priority 104 iif p1-route lookup 42]) on_exit 'ip rule del priority 105 ipproto udp lookup 42' -AT_CHECK([ip rule add priority 105 ipproto udp lookup 42]) on_exit 'ip rule del priority 106 from all tun_id 22 lookup 42' -AT_CHECK([ip rule add priority 106 from all tun_id 22 lookup 42]) -dnl Give the main thread a chance to act. -AT_CHECK([ovs-appctl revalidator/wait]) -dnl Check OVS rules cache hasn't changed. -AT_CHECK([ovs-appctl ovs/route/rule/show], [0], [dnl -Cached: 0: from all lookup local -Cached: 32766: from all lookup main -Cached: 32767: from all lookup default -]) -AT_CHECK([ovs-appctl ovs/route/rule/show -6], [0], [dnl -Cached: 0: from all lookup local -Cached: 32766: from all lookup main -]) +dnl Capture initial cache state, add unsupported rules, and verify OVS cache +dnl hasn't changed. This test verifies that unsupported routing rules (with +dnl selectors like fwmark, dport, sport, iif, ipproto, tun_id) are not cached +dnl by OVS, even though the kernel accepts them. +AT_CHECK([ + initial_v4=$(ovs-appctl ovs/route/rule/show) + initial_v6=$(ovs-appctl ovs/route/rule/show -6) + ip rule add priority 100 fwmark 0x16 lookup 42 + ip rule add priority 101 from 10.0.0.1 dport 22 lookup 42 + ip rule add priority 102 from 10.0.0.1 sport 22 lookup 42 + ip rule add priority 103 from 10.0.0.1 tun_id 22 lookup 42 + ip rule add priority 104 iif p1-route lookup 42 + ip rule add priority 105 ipproto udp lookup 42 + ip rule add priority 106 from all tun_id 22 lookup 42 + ovs-appctl revalidator/wait + final_v4=$(ovs-appctl ovs/route/rule/show) + final_v6=$(ovs-appctl ovs/route/rule/show -6) + test "$initial_v4" = "$final_v4" && test "$initial_v6" = "$final_v6" +], [0]) OVS_TRAFFIC_VSWITCHD_STOP AT_CLEANUP diff --git a/tests/tunnel-push-pop.at b/tests/tunnel-push-pop.at index f22a37570..e666d11d4 100644 --- a/tests/tunnel-push-pop.at +++ b/tests/tunnel-push-pop.at @@ -1572,12 +1572,9 @@ AT_CHECK([ovs-appctl ovs/route/rule/add from=1.1.2.80/32 table=10], [0], [OK ]) AT_CHECK([ovs-appctl ovs/route/rule/add from=1.1.2.81/32 table=11], [0], [OK ]) -AT_CHECK([ovs-appctl ovs/route/rule/show], [0], [dnl -Cached: 0: from all lookup local +AT_CHECK([ovs-appctl ovs/route/rule/show | grep "^User:" | sort], [0], [dnl User: 32764: from 1.1.2.81 lookup 11 User: 32765: from 1.1.2.80 lookup 10 -Cached: 32766: from all lookup main -Cached: 32767: from all lookup default ]) AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(int-br),dnl -- 2.43.0 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
