vconn: Have check_action() perform all validation
authorJustin Pettit <jpettit@nicira.com>
Fri, 11 Dec 2009 05:15:16 +0000 (21:15 -0800)
committerJustin Pettit <jpettit@nicira.com>
Fri, 11 Dec 2009 05:15:16 +0000 (21:15 -0800)
The function check_action() returned before it could finish its
validation.  The only checks that were missed were length checks, which
were verified earlier.

Thanks to Jean Tourrilhes for pointing out the issue.

lib/vconn.c

index a3ce214..922198a 100644 (file)
@@ -1269,6 +1269,17 @@ check_action(const union ofp_action *a, unsigned int len, int max_ports)
 {
     int error;
 
+    if (!len) {
+        VLOG_DBG_RL(&bad_ofmsg_rl, "action has invalid length 0");
+        return ofp_mkerr(OFPET_BAD_ACTION, OFPBAC_BAD_LEN);
+    }
+
+    if (len % ACTION_ALIGNMENT) {
+        VLOG_DBG_RL(&bad_ofmsg_rl, "action length %u is not a multiple of %d",
+                    len, ACTION_ALIGNMENT);
+        return ofp_mkerr(OFPET_BAD_ACTION, OFPBAC_BAD_LEN);
+    }
+
     switch (ntohs(a->type)) {
     case OFPAT_OUTPUT:
         error = check_action_port(ntohs(a->output.port), max_ports);
@@ -1302,17 +1313,6 @@ check_action(const union ofp_action *a, unsigned int len, int max_ports)
         VLOG_WARN_RL(&bad_ofmsg_rl, "unknown action type %"PRIu16, a->type);
         return ofp_mkerr(OFPET_BAD_ACTION, OFPBAC_BAD_TYPE);
     }
-
-    if (!len) {
-        VLOG_DBG_RL(&bad_ofmsg_rl, "action has invalid length 0");
-        return ofp_mkerr(OFPET_BAD_ACTION, OFPBAC_BAD_LEN);
-    }
-    if (len % ACTION_ALIGNMENT) {
-        VLOG_DBG_RL(&bad_ofmsg_rl, "action length %u is not a multiple of %d",
-                    len, ACTION_ALIGNMENT);
-        return ofp_mkerr(OFPET_BAD_ACTION, OFPBAC_BAD_LEN);
-    }
-    return 0;
 }
 
 int