ofproto: Report correct error for emergency flow with timeout.
authorBen Pfaff <blp@nicira.com>
Thu, 1 Nov 2012 07:22:41 +0000 (00:22 -0700)
committerBen Pfaff <blp@nicira.com>
Sat, 8 Dec 2012 20:37:14 +0000 (12:37 -0800)
The OpenFlow 1.0 specification says:

    Emergency flow mod messages must have timeout values set to zero.
    Otherwise, the switch must refuse the addition and respond with an
    ofp_error_msg with OFPET_FLOW_MOD_FAILED type and
    OFPFMFC_BAD_EMERG_TIMEOUT code.

but Open vSwitch reported OFPFMFC_TABLE_FULL in this case.  This commit
fixes the problem.

Fixes detailed_contr_sw_messages.EmerFlowTimeout failure in OFTest.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Kyle Mestery <kmestery@cisco.com>
lib/ofp-util.c

index 11b6192..d5333ee 100644 (file)
@@ -1590,11 +1590,13 @@ ofputil_decode_flow_mod(struct ofputil_flow_mod *fm,
         if (fm->flags & OFPFF10_EMERG) {
             /* We do not support the OpenFlow 1.0 emergency flow cache, which
              * is not required in OpenFlow 1.0.1 and removed from OpenFlow 1.1.
-             * There is no good error code, so just state that the flow table
-             * is full.
-             * Moreover, OFPFF10_EMERG overlaps with OFPFF12_RESET_COUNTS,
-             * so this check must be here */
-            return OFPERR_OFPFMFC_TABLE_FULL;
+             *
+             * OpenFlow 1.0 specifies the error code to use when idle_timeout
+             * or hard_timeout is nonzero.  Otherwise, there is no good error
+             * code, so just state that the flow table is full. */
+            return (fm->hard_timeout || fm->idle_timeout
+                    ? OFPERR_OFPFMFC_BAD_EMERG_TIMEOUT
+                    : OFPERR_OFPFMFC_TABLE_FULL);
         }
 
         if (protocol & OFPUTIL_P_TID) {