dpif-netdev: Batch megaflow lookup.
[cascardo/ovs.git] / lib / ofp-actions.c
index a644e6e..9849771 100644 (file)
@@ -225,7 +225,7 @@ dec_ttl_from_openflow(struct ofpbuf *out, enum ofputil_action_code compat)
     ids->ofpact.compat = compat;
     ids->n_controllers = 1;
     ofpbuf_put(out, &id, sizeof id);
-    ids = out->l2;
+    ids = out->frame;
     ofpact_update_len(out, &ids->ofpact);
     return error;
 }
@@ -258,7 +258,7 @@ dec_ttl_cnt_ids_from_openflow(const struct nx_action_cnt_ids *nac_ids,
     for (i = 0; i < ids->n_controllers; i++) {
         uint16_t id = ntohs(((ovs_be16 *)(nac_ids + 1))[i]);
         ofpbuf_put(out, &id, sizeof id);
-        ids = out->l2;
+        ids = out->frame;
     }
 
     ofpact_update_len(out, &ids->ofpact);
@@ -492,9 +492,6 @@ ofpact_from_nxast(const union ofp_action *a, enum ofputil_action_code code,
         break;
 
     case OFPUTIL_NXAST_POP_MPLS:
-        if (eth_type_mpls(a->pop_mpls.ethertype)) {
-            return OFPERR_OFPBAC_BAD_ARGUMENT;
-        }
         ofpact_put_POP_MPLS(out)->ethertype = a->pop_mpls.ethertype;
         break;
 
@@ -825,14 +822,15 @@ set_field_from_openflow(const struct ofp12_action_set_field *oasf,
 
 static void
 set_field_to_openflow12(const struct ofpact_set_field *sf,
-                        struct ofpbuf *openflow)
+                        struct ofpbuf *openflow,
+                        enum ofp_version version)
 {
     uint16_t padded_value_len = ROUND_UP(sf->field->n_bytes, 8);
     struct ofp12_action_set_field *oasf;
     char *value;
 
     oasf = ofputil_put_OFPAT12_SET_FIELD(openflow);
-    oasf->dst = htonl(sf->field->oxm_header);
+    oasf->dst = htonl(mf_oxm_header(sf->field->id, version));
     oasf->len = htons(sizeof *oasf + padded_value_len);
 
     value = ofpbuf_put_zeros(openflow, padded_value_len);
@@ -1077,10 +1075,10 @@ static void
 set_field_to_openflow(const struct ofpact_set_field *sf,
                       struct ofpbuf *openflow)
 {
-    struct ofp_header *oh = (struct ofp_header *)openflow->l2;
+    struct ofp_header *oh = (struct ofp_header *)openflow->frame;
 
     if (oh->version >= OFP12_VERSION) {
-        set_field_to_openflow12(sf, openflow);
+        set_field_to_openflow12(sf, openflow, oh->version);
     } else if (oh->version == OFP11_VERSION) {
         set_field_to_openflow11(sf, openflow);
     } else if (oh->version == OFP10_VERSION) {
@@ -1259,9 +1257,6 @@ ofpact_from_openflow11(const union ofp_action *a, enum ofp_version version,
         break;
 
     case OFPUTIL_OFPAT11_POP_MPLS:
-        if (eth_type_mpls(a->ofp11_pop_mpls.ethertype)) {
-            return OFPERR_OFPBAC_BAD_ARGUMENT;
-        }
         ofpact_put_POP_MPLS(out)->ethertype = a->ofp11_pop_mpls.ethertype;
         break;
 
@@ -1723,7 +1718,7 @@ decode_openflow11_instructions(const struct ofp11_instruction insts[],
         }
 
         if (out[type]) {
-            return OFPERR_ONFBIC_DUP_INSTRUCTION;
+            return OFPERR_OFPBIC_DUP_INST;
         }
         out[type] = inst;
     }
@@ -2589,6 +2584,8 @@ ofpact_to_openflow10(const struct ofpact *a, struct ofpbuf *out)
          * follow this action. */
         break;
 
+    case OFPACT_SET_IP_ECN:
+    case OFPACT_SET_IP_TTL:
     case OFPACT_CLEAR_ACTIONS:
     case OFPACT_WRITE_ACTIONS:
     case OFPACT_GOTO_TABLE:
@@ -2611,8 +2608,6 @@ ofpact_to_openflow10(const struct ofpact *a, struct ofpbuf *out)
     case OFPACT_STACK_PUSH:
     case OFPACT_STACK_POP:
     case OFPACT_DEC_TTL:
-    case OFPACT_SET_IP_ECN:
-    case OFPACT_SET_IP_TTL:
     case OFPACT_SET_MPLS_LABEL:
     case OFPACT_SET_MPLS_TC:
     case OFPACT_SET_MPLS_TTL:
@@ -3608,7 +3603,7 @@ ofpact_put(struct ofpbuf *ofpacts, enum ofpact_type type, size_t len)
     struct ofpact *ofpact;
 
     ofpact_pad(ofpacts);
-    ofpact = ofpacts->l2 = ofpbuf_put_uninit(ofpacts, len);
+    ofpact = ofpacts->frame = ofpbuf_put_uninit(ofpacts, len);
     ofpact_init(ofpact, type, len);
     return ofpact;
 }
@@ -3631,7 +3626,7 @@ ofpact_init(struct ofpact *ofpact, enum ofpact_type type, size_t len)
 void
 ofpact_update_len(struct ofpbuf *ofpacts, struct ofpact *ofpact)
 {
-    ovs_assert(ofpact == ofpacts->l2);
+    ovs_assert(ofpact == ofpacts->frame);
     ofpact->len = (char *) ofpbuf_tail(ofpacts) - (char *) ofpact;
 }