Don't use error categories as if they were actually errors.
authorJarno Rajahalme <jarno.rajahalme@nsn.com>
Fri, 30 Nov 2012 21:45:08 +0000 (13:45 -0800)
committerBen Pfaff <blp@nicira.com>
Tue, 4 Dec 2012 16:25:55 +0000 (08:25 -0800)
The OFPERR_* naming scheme is confusing, because it mixes categories with
specific errors.  Categories can't be encoded for sending to controllers,
so this is a problem.  This commit fixes up the cases where categories
were used as errors, replacing them by real errors types.

Signed-off-by: Jarno Rajahalme <jarno.rajahalme@nsn.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/ofp-actions.c
lib/ofp-errors.h
lib/ofp-util.c
tests/ofp-actions.at

index 9c458a9..b758c7c 100644 (file)
@@ -718,7 +718,7 @@ ofpact_from_openflow11(const union ofp_action *a, struct ofpbuf *out)
         if (((const struct ofp11_action_push *)a)->ethertype !=
             htons(ETH_TYPE_VLAN_8021Q)) {
             /* TODO:XXX 802.1AD(QinQ) isn't supported at the moment */
-            return OFPERR_OFPET_BAD_ACTION;
+            return OFPERR_OFPBAC_BAD_ARGUMENT;
         }
         ofpact_put_PUSH_VLAN(out);
         break;
@@ -917,7 +917,9 @@ decode_openflow11_instructions(const struct ofp11_instruction insts[],
         }
 
         if (out[type]) {
-            return OFPERR_OFPIT_BAD_INSTRUCTION;
+            return OFPERR_OFPBAC_UNSUPPORTED_ORDER; /* No specific code for
+                                                     * a duplicate instruction
+                                                     * exist */
         }
         out[type] = inst;
     }
@@ -1157,7 +1159,6 @@ ofpacts_verify(const struct ofpact ofpacts[], size_t ofpacts_len)
         if (om) {
             if (a->type == OFPACT_WRITE_METADATA) {
                 VLOG_WARN("duplicate write_metadata instruction specified");
-                /* should be OFPERR_OFPET_BAD_ACTION? */
                 return OFPERR_OFPBAC_UNSUPPORTED_ORDER;
             } else {
                 VLOG_WARN("write_metadata instruction must be specified after "
index e9fedb9..5c3df20 100644 (file)
@@ -161,6 +161,11 @@ enum ofperr {
      * the id of any existing monitor. */
     OFPERR_NXBRC_FM_BAD_ID,
 
+    /* NX1.0+(1,520).  The 'event' in an NXST_FLOW_MONITOR reply does not
+     * specify one of the NXFME_ABBREV, NXFME_ADD, NXFME_DELETE, or
+     * NXFME_MODIFY. */
+    OFPERR_NXBRC_FM_BAD_EVENT,
+
 /* ## ---------------- ## */
 /* ## OFPET_BAD_ACTION ## */
 /* ## ---------------- ## */
index 320bfde..11b6192 100644 (file)
@@ -3681,7 +3681,7 @@ ofputil_decode_flow_update(struct ofputil_flow_update *update,
         VLOG_WARN_RL(&bad_ofmsg_rl,
                      "NXST_FLOW_MONITOR reply has bad event %"PRIu16,
                      ntohs(nfuh->event));
-        return OFPERR_OFPET_BAD_REQUEST;
+        return OFPERR_NXBRC_FM_BAD_EVENT;
     }
 
 bad_len:
index f30fa06..30fcf51 100644 (file)
@@ -341,7 +341,7 @@ dnl Check that an empty Apply-Actions instruction gets dropped.
 0004 0008 00000000
 
 dnl Duplicate instruction type:
-# bad OF1.1 instructions: OFPIT_BAD_INSTRUCTION
+# bad OF1.1 instructions: OFPBAC_UNSUPPORTED_ORDER
 0004 0008 00000000 0004 0008 00000000
 
 dnl Instructions not multiple of 8 in length.
@@ -379,7 +379,7 @@ dnl Write-Metadata too long.
 0002 0020 00000000 fedcba9876543210 ffffffffffffffff 0000000000000000
 
 dnl Write-Metadata duplicated.
-# bad OF1.1 instructions: OFPIT_BAD_INSTRUCTION
+# bad OF1.1 instructions: OFPBAC_UNSUPPORTED_ORDER
 0002 0018 00000000 fedcba9876543210 ff00ff00ff00ff00 0002 0018 00000000 fedcba9876543210 ff00ff00ff00ff00
 
 dnl Write-Metadata in wrong position.