The "Network Function - vtap mode" system test waits for the
network_function_active column in the NB database to name the
expected network function, then immediately pings and requires
all 10 ICMP packets to be mirrored to the tap port.  The column
is updated by northd before ovn-controller claims the tap port
and installs the new mirror flows, so the first ping can race
past br-int during that window and fail the packet count.

Wait for the datapath to be ready before sending traffic: after
each active-NF wait, sync until ovn-controller has processed the
SB update, then wait until the NF mirror flows are actually
installed.  The mirror flows are matched by the tap port's
tunnel key loaded into reg15 inside the clone action, scoped to
the tables backing the NF pipeline stages; this avoids false
positives from the table 89 delivery flow, which exists as soon
as the tap port is bound.  The match tolerates both the
set_field and the NXM load renderings of the clone action.

Flake seen during CI run
https://github.com/ovsrobot/ovn/actions/runs/44173482162

Fixes: 8c45b31f1eee ("northd, tests: Network Function vtap mode logical flow 
changes.")
Assisted-by: GLM 5.3, OpenCode
Signed-off-by: Jacob Tanenbaum <[email protected]>
---
 tests/system-ovn.at | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/tests/system-ovn.at b/tests/system-ovn.at
index 28914a93f..77a1a9534 100644
--- a/tests/system-ovn.at
+++ b/tests/system-ovn.at
@@ -20982,6 +20982,26 @@ nf_up() {
     ovs-vsctl set interface ovs-$port external-ids:iface-id="$port"
 }
 
+# Wait until the NF vtap mirror flows for the given tap port are installed.
+# Depending on the OVS version, the action is rendered as
+# "clone(set_field:0x<key>->reg15,...)" or as
+# "clone(load:0x<key>->NXM_NX_REG15[],...)", so match either form. The helper
+# only waits for the new tap's flows to appear; during failover the previous
+# tap's mirror flows may linger briefly, which is harmless for the >= 10
+# captured-lines check on the new tap.
+wait_nf_vtap_mirror_flows_installed() {
+    local tap=$1
+    local key=$(printf '0x%x' \
+        "$(ovn-sbctl --bare --columns=tunnel_key list port_binding "$tap")")
+    local ls_in_table=$(ovn-debug lflow-stage-to-oftable 
ls_in_network_function)
+    local ls_out_table=$(ovn-debug lflow-stage-to-oftable 
ls_out_network_function)
+    OVS_WAIT_UNTIL([
+        { ovs-ofctl dump-flows br-int table=$ls_in_table; \
+          ovs-ofctl dump-flows br-int table=$ls_out_table; } |
+        grep -qi "clone(.*$key->.*reg15"
+    ])
+}
+
 # Returns 0 if the given address contains ':', i.e. is an IPv6 address.
 is_v6_addr() {
     test "${1#*:}" != "$1"
@@ -21009,6 +21029,8 @@ validate_nf_vtap_with_traffic() {
     # Wait for the health check to mark nf0 as the active NF.
     wait_column "$nf0_uuid" nb:network_function_group \
         network_function_active name=nfg0
+    check ovn-nbctl --wait=hv sync
+    wait_nf_vtap_mirror_flows_installed nf-vtap
 
     NETNS_START_TCPDUMP([nf], [-nvvv -i nf-vtap $pcap_filter], 
[tcpdump-nf-vtap])
 
@@ -21034,6 +21056,8 @@ validate_nf_vtap_with_traffic() {
     # Wait for the health check to fail over to nf1.
     wait_column "$nf1_uuid" nb:network_function_group \
         network_function_active name=nfg0
+    check ovn-nbctl --wait=hv sync
+    wait_nf_vtap_mirror_flows_installed nf-vtap2
 
     NETNS_START_TCPDUMP([nf], [-nvvv -i nf-vtap2 $pcap_filter], 
[tcpdump-nf-vtap])
 
@@ -21059,6 +21083,8 @@ validate_nf_vtap_with_traffic() {
     # Wait for the health check to fall back to nf0.
     wait_column "$nf0_uuid" nb:network_function_group \
         network_function_active name=nfg0
+    check ovn-nbctl --wait=hv sync
+    wait_nf_vtap_mirror_flows_installed nf-vtap
 
     NETNS_START_TCPDUMP([nf], [-nvvv -i nf-vtap $pcap_filter], 
[tcpdump-nf-vtap])
 
-- 
2.56.1

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to