ofp-actions: Prefer OFPAT11_DEC_TTL to NXAST_DEC_TTL for OpenFlow 1.1+.
[sliver-openvswitch.git] / lib / ofp-actions.c
index b774a61..ae20f8e 100644 (file)
@@ -1425,6 +1425,19 @@ ofpact_output_to_openflow11(const struct ofpact_output *output,
     oao->max_len = htons(output->max_len);
 }
 
+static void
+ofpact_dec_ttl_to_openflow11(const struct ofpact_cnt_ids *dec_ttl,
+                             struct ofpbuf *out)
+{
+    if (dec_ttl->n_controllers == 1 && dec_ttl->cnt_ids[0] == 0
+        && (!dec_ttl->ofpact.compat ||
+            dec_ttl->ofpact.compat == OFPUTIL_OFPAT11_DEC_NW_TTL)) {
+        ofputil_put_OFPAT11_DEC_NW_TTL(out);
+    } else {
+        ofpact_dec_ttl_to_nxast(dec_ttl, out);
+    }
+}
+
 static void
 ofpact_to_openflow11(const struct ofpact *a, struct ofpbuf *out)
 {
@@ -1486,11 +1499,7 @@ ofpact_to_openflow11(const struct ofpact *a, struct ofpbuf *out)
         break;
 
     case OFPACT_DEC_TTL:
-        if (a->compat == OFPUTIL_OFPAT11_DEC_NW_TTL) {
-            ofputil_put_OFPAT11_DEC_NW_TTL(out);
-        } else {
-            ofpact_to_nxast(a, out);
-        }
+        ofpact_dec_ttl_to_openflow11(ofpact_get_DEC_TTL(a), out);
         break;
 
     case OFPACT_CLEAR_ACTIONS: