+
+/* Verifies that the 'ofpacts_len' bytes of actions in 'ofpacts' are
+ * in the appropriate order as defined by the OpenFlow spec. */
+enum ofperr
+ofpacts_verify(const struct ofpact ofpacts[], size_t ofpacts_len)
+{
+ const struct ofpact *a;
+ const struct ofpact_metadata *om = NULL;
+
+ OFPACT_FOR_EACH (a, ofpacts, 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 "
+ "other instructions/actions");
+ return OFPERR_OFPBAC_UNSUPPORTED_ORDER;
+ }
+ }
+
+ if (a->type == OFPACT_WRITE_METADATA) {
+ om = (const struct ofpact_metadata *) a;
+ }
+ }
+
+ return 0;
+}