The ofproto provider function behind NXT_CT_FLUSH and NXT_CT_FLUSH_ZONE
returns nothing, and ofproto-dpif drops the result of ct_dpif_flush().
A controller gets the same silence whether the datapath flushed the
entries or not, so it cannot tell that connections it wanted gone are
still there.

Make the provider function return the result of the flush, and reply
with an OpenFlow error when it failed.

No existing error fits.  The OFPBRC_* errors are about a request that
the switch cannot understand, and the only generic one, OFPBRC_UNKNOWN,
exists in OpenFlow 1.5 and later only.  The requests are Nicira
extensions, so give them errors of their own, the way NXT_RESUME has
NXR_NOT_SUPPORTED and NXR_STALE:

  - NXCTF_NOT_SUPPORTED: the datapath cannot do this flush (EOPNOTSUPP),
    or the provider has no conntrack flush at all.  The latter case
    returned the errno value EOPNOTSUPP in place of an OpenFlow error,
    which went out as NXBRC_UNENCODABLE_ERROR.

  - NXCTF_FAILED: any other failure.  Some of the entries may have been
    flushed.

ENOENT is not reported.  A flush that walks a dump does not return it
any more, so it can only mean that the one connection that a full
5-tuple names is not in the datapath: the controller wanted it gone,
and it is.

The datapaths that the testsuite can drive never fail a conntrack
flush, so the tests cover the encoding of the new errors only.  Tested
by hand with the kernel datapath: a flush by zone, by a partial tuple
and by the 5-tuple of a connection that does not exist get no reply,
while the 5-tuple of an IP protocol that netlink-conntrack cannot put
in a delete request (47) gets NXCTF_NOT_SUPPORTED, in OpenFlow 1.0 and
in 1.5.

Suggested-by: Aaron Conole <[email protected]>
Assisted-by: Claude Fable 5.2, Claude Code
Signed-off-by: Bekei Park <[email protected]>
---
v2:
 - New patch.  v1 only mentioned that the error is lost.

 NEWS                             |  4 +++
 include/openvswitch/ofp-errors.h | 14 +++++++++++
 ofproto/ofproto-dpif.c           |  4 +--
 ofproto/ofproto-provider.h       | 10 +++++---
 ofproto/ofproto.c                | 42 +++++++++++++++++++++-----------
 tests/ofp-errors.at              | 35 ++++++++++++++++++++++++++
 6 files changed, 90 insertions(+), 19 deletions(-)

diff --git a/NEWS b/NEWS
index 1caac3c75..73c1645f6 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,10 @@ Post-v4.0.0
    - ovs-vswitchd:
      * Mirror filters now accept masked fields, e.g. "ip,nw_src=10.0.0.0/24"
        in the "filter" column of the Mirror table.
+   - OpenFlow:
+     * A failed NXT_CT_FLUSH or NXT_CT_FLUSH_ZONE request is now reported
+       to the controller, with the new errors NXCTF_NOT_SUPPORTED and
+       NXCTF_FAILED.  Before, the result of the flush was dropped.
 
 
 v4.0.0 - 17 Aug 2026
diff --git a/include/openvswitch/ofp-errors.h b/include/openvswitch/ofp-errors.h
index 8c8511d65..2d88d68d2 100644
--- a/include/openvswitch/ofp-errors.h
+++ b/include/openvswitch/ofp-errors.h
@@ -893,6 +893,20 @@ enum ofperr {
     /* NX1.0-1.1(1,535), NX1.2+(36).  Protocol is not configured on this
      * Open vSwitch instance. */
     OFPERR_NXST_NOT_CONFIGURED,
+
+/* ## ------------ ## */
+/* ## NXT_CT_FLUSH ## */
+/* ## ------------ ## */
+
+    /* NX1.0-1.1(1,538), NX1.2+(45).  This datapath cannot flush the
+     * connection tracking entries that an NXT_CT_FLUSH or NXT_CT_FLUSH_ZONE
+     * request asked for. */
+    OFPERR_NXCTF_NOT_SUPPORTED,
+
+    /* NX1.0-1.1(1,539), NX1.2+(46).  The datapath failed to flush the
+     * connection tracking entries that an NXT_CT_FLUSH or NXT_CT_FLUSH_ZONE
+     * request asked for.  Some of them may have been flushed. */
+    OFPERR_NXCTF_FAILED,
 };
 
 const char *ofperr_domain_get_name(enum ofp_version);
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 412554cdf..0bc7b7909 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -5569,13 +5569,13 @@ type_set_config(const char *type, const struct smap 
*other_config)
     dpif_set_config(backer->dpif, other_config);
 }
 
-static void
+static int
 ct_flush(const struct ofproto *ofproto_, const uint16_t *zone,
          const struct ofp_ct_match *match)
 {
     struct ofproto_dpif *ofproto = ofproto_dpif_cast(ofproto_);
 
-    ct_dpif_flush(ofproto->backer->dpif, zone, match);
+    return ct_dpif_flush(ofproto->backer->dpif, zone, match);
 }
 
 static struct ct_timeout_policy *
diff --git a/ofproto/ofproto-provider.h b/ofproto/ofproto-provider.h
index 7df3f5246..0adca6bd5 100644
--- a/ofproto/ofproto-provider.h
+++ b/ofproto/ofproto-provider.h
@@ -1924,9 +1924,13 @@ struct ofproto_class {
 /* ## ------------------- ## */
     /* Flushes the connection tracking tables. If 'zone' is not NULL,
      * only deletes connections in '*zone'. If 'match' is not NULL,
-     * deletes connections specified by the match. */
-    void (*ct_flush)(const struct ofproto *, const uint16_t *zone,
-                     const struct ofp_ct_match *match);
+     * deletes connections specified by the match.
+     *
+     * Returns 0 if successful, otherwise a positive errno value.  ENOENT
+     * means that the single connection that 'match' identifies does not
+     * exist. */
+    int (*ct_flush)(const struct ofproto *, const uint16_t *zone,
+                    const struct ofp_ct_match *match);
 
     /* Sets conntrack timeout policy specified by 'timeout_policy' to 'zone'
      * in datapath type 'dp_type'. */
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 02f82c519..5249c0910 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -943,6 +943,32 @@ handle_ipfix_flow_stats_request(struct ofconn *ofconn,
     return error;
 }
 
+/* Flushes the connection tracking entries that 'match' selects, in '*zone'
+ * if 'zone' is nonnull, and returns the OpenFlow error that reports the
+ * result to the controller that asked for the flush. */
+static enum ofperr
+ofproto_ct_flush(struct ofproto *ofproto, const uint16_t *zone,
+                 const struct ofp_ct_match *match)
+{
+    if (!ofproto->ofproto_class->ct_flush) {
+        return OFPERR_NXCTF_NOT_SUPPORTED;
+    }
+
+    switch (ofproto->ofproto_class->ct_flush(ofproto, zone, match)) {
+    case 0:
+    case ENOENT:
+        /* The connection that the controller wanted to be gone is not
+         * there, which is not a failure of the flush. */
+        return 0;
+
+    case EOPNOTSUPP:
+        return OFPERR_NXCTF_NOT_SUPPORTED;
+
+    default:
+        return OFPERR_NXCTF_FAILED;
+    }
+}
+
 static enum ofperr
 handle_nxt_ct_flush_zone(struct ofconn *ofconn, const struct ofp_header *oh)
 {
@@ -954,13 +980,8 @@ handle_nxt_ct_flush_zone(struct ofconn *ofconn, const 
struct ofp_header *oh)
     }
 
     uint16_t zone = ntohs(nzi->zone_id);
-    if (ofproto->ofproto_class->ct_flush) {
-        ofproto->ofproto_class->ct_flush(ofproto, &zone, NULL);
-    } else {
-        return EOPNOTSUPP;
-    }
 
-    return 0;
+    return ofproto_ct_flush(ofproto, &zone, NULL);
 }
 
 static enum ofperr
@@ -976,14 +997,7 @@ handle_nxt_ct_flush(struct ofconn *ofconn, const struct 
ofp_header *oh)
         return error;
     }
 
-    if (ofproto->ofproto_class->ct_flush) {
-        ofproto->ofproto_class->ct_flush(ofproto, with_zone ? &zone_id : NULL,
-                                         &match);
-    } else {
-        return EOPNOTSUPP;
-    }
-
-    return 0;
+    return ofproto_ct_flush(ofproto, with_zone ? &zone_id : NULL, &match);
 }
 
 void
diff --git a/tests/ofp-errors.at b/tests/ofp-errors.at
index da3aca3af..96d344e55 100644
--- a/tests/ofp-errors.at
+++ b/tests/ofp-errors.at
@@ -164,6 +164,23 @@ OFPT_ERROR (OF1.2) (xid=0x55555555): NXBRC_MUST_BE_ZERO
 OFPT_ECHO_REQUEST (xid=0x11111111): 0 bytes of payload
 ])
 
+AT_CHECK([ovs-ofctl ofp-print '0101001c55555555 b0c20000 000023200001021a 
0102000811111111'], [0], [dnl
+OFPT_ERROR (xid=0x55555555): NXCTF_NOT_SUPPORTED
+OFPT_ECHO_REQUEST (xid=0x11111111): 0 bytes of payload
+])
+AT_CHECK([ovs-ofctl ofp-print '0601001855555555 ffff002d 00002320 
0102000811111111'], [0], [dnl
+OFPT_ERROR (OF1.5) (xid=0x55555555): NXCTF_NOT_SUPPORTED
+OFPT_ECHO_REQUEST (xid=0x11111111): 0 bytes of payload
+])
+AT_CHECK([ovs-ofctl ofp-print '0101001c55555555 b0c20000 000023200001021b 
0102000811111111'], [0], [dnl
+OFPT_ERROR (xid=0x55555555): NXCTF_FAILED
+OFPT_ECHO_REQUEST (xid=0x11111111): 0 bytes of payload
+])
+AT_CHECK([ovs-ofctl ofp-print '0601001855555555 ffff002e 00002320 
0102000811111111'], [0], [dnl
+OFPT_ERROR (OF1.5) (xid=0x55555555): NXCTF_FAILED
+OFPT_ECHO_REQUEST (xid=0x11111111): 0 bytes of payload
+])
+
 AT_CHECK([ovs-ofctl ofp-print '0301001812345678 ffff0a28 4f4e4600 
0300000812345678'], [0], [dnl
 OFPT_ERROR (OF1.2) (xid=0x12345678): OFPBIC_DUP_INST
 OFPT_HELLO (OF1.2) (xid=0x12345678):
@@ -202,6 +219,24 @@ AT_CHECK(
 00000010  03 00 00 08 12 34 56 78
 ])
 
+# The errors of a failed conntrack flush are Nicira extensions in every
+# OpenFlow version.
+AT_CHECK(
+  [ovs-ofctl encode-error-reply NXCTF_NOT_SUPPORTED 0100000812345678], [0], 
[dnl
+00000000  01 01 00 1c 12 34 56 78-b0 c2 00 00 00 00 23 20
+00000010  00 01 02 1a 01 00 00 08-12 34 56 78
+])
+AT_CHECK(
+  [ovs-ofctl encode-error-reply NXCTF_FAILED 0100000812345678], [0], [dnl
+00000000  01 01 00 1c 12 34 56 78-b0 c2 00 00 00 00 23 20
+00000010  00 01 02 1b 01 00 00 08-12 34 56 78
+])
+AT_CHECK(
+  [ovs-ofctl encode-error-reply NXCTF_FAILED 0600000812345678], [0], [dnl
+00000000  06 01 00 18 12 34 56 78-ff ff 00 2e 00 00 23 20
+00000010  06 00 00 08 12 34 56 78
+])
+
 # Check that OFPERR_OFPBIC_DUP_INST is:
 #    - not encodable in OF1.0 (OF1.0 doesn't have instructions, after all).
 #    - encoded as a Nicira extension in OF1.1.
-- 
2.43.0


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

Reply via email to