ofp-actions: Translate OF1.1+ mod_nw_ttl action to OF1.0 properly.
authorBen Pfaff <blp@ovn.org>
Wed, 13 Jul 2016 23:41:00 +0000 (16:41 -0700)
committerBen Pfaff <blp@ovn.org>
Thu, 14 Jul 2016 16:15:29 +0000 (09:15 -0700)
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
NEWS
lib/ofp-actions.c
tests/ofp-actions.at

diff --git a/NEWS b/NEWS
index 15fa165..6496dc1 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -22,8 +22,8 @@ Post-v2.5.0
    - Improved OpenFlow version compatibility for actions:
      * New OpenFlow extension to support the "group" action in OpenFlow 1.0.
      * OpenFlow 1.0 "enqueue" action now properly translated to OpenFlow 1.1+.
-     * OpenFlow 1.1 "mod_nw_ecn" action now properly translated to
-       OpenFlow 1.0.
+     * OpenFlow 1.1 "mod_nw_ecn" and OpenFlow 1.1+ "mod_nw_ttl" actions now
+       properly translated to OpenFlow 1.0.
    - ovs-ofctl:
      * queue-get-config command now allows a queue ID to be specified.
      * '--bundle' option can now be used with OpenFlow 1.3.
index 232e728..aa681c0 100644 (file)
@@ -1970,7 +1970,9 @@ encode_SET_IP_TTL(const struct ofpact_ip_ttl *ttl,
     if (ofp_version >= OFP11_VERSION) {
         put_OFPAT11_SET_NW_TTL(out, ttl->ttl);
     } else {
-        /* XXX */
+        struct mf_subfield dst = { .field = mf_from_id(MFF_IP_TTL),
+                                   .ofs = 0, .n_bits = 8 };
+        put_reg_load(out, &dst, ttl->ttl);
     }
 }
 
index b177893..5e2474f 100644 (file)
@@ -772,6 +772,23 @@ OFPST_FLOW reply (OF1.3):
 OVS_VSWITCHD_STOP
 AT_CLEANUP
 
+AT_SETUP([mod_nw_ttl action for OF1.0])
+AT_KEYWORDS([ofp-actions])
+OVS_VSWITCHD_START
+dnl OpenFlow 1.1+ have a mod_nw_ttl action.  For OpenFlow 1.0, we translate
+dnl it to an Open vSwitch extension.
+AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 'ip,actions=mod_nw_ttl:123'])
+AT_CHECK([ovs-ofctl -O OpenFlow10 dump-flows br0 | ofctl_strip], [0], [dnl
+NXST_FLOW reply:
+ ip actions=load:0x7b->NXM_NX_IP_TTL[[]]
+])
+AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip], [0], [dnl
+OFPST_FLOW reply (OF1.1):
+ ip actions=mod_nw_ttl:123
+])
+OVS_VSWITCHD_STOP
+AT_CLEANUP
+
 AT_SETUP([mod_nw_ecn action translation])
 AT_KEYWORDS([ofp-actions])
 OVS_VSWITCHD_START
@@ -808,3 +825,4 @@ OFPST_FLOW reply (OF1.1):
 ])
 OVS_VSWITCHD_STOP
 AT_CLEANUP
+