ofproto: As of Open Flow 1.1 switch_features has no capabilities field
authorSimon Horman <horms@verge.net.au>
Mon, 30 Jul 2012 02:03:00 +0000 (11:03 +0900)
committerBen Pfaff <blp@nicira.com>
Tue, 31 Jul 2012 04:41:45 +0000 (21:41 -0700)
In Open Flow 1.0 switch_features has a capabilities field.
However, in Open Flow 1.1, 1.2 and 1.3 this field is reserved.
Thus it should not be read on decode and it seems most appropriate
to set as zero on encode.

This patch takes the approach of setting the features field to
all available features for Open Flow 1.1+. I am unsure if it would
be sufficient to just set it to zero.

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/ofp-print.c
lib/ofp-util.c
tests/ofp-print.at

index dc9fb6de1f26ac1228cb5c5929765923c9db1673..832e008efb3bf73bdd786ad8f1b6d7eab54343d3 100644 (file)
@@ -507,10 +507,19 @@ ofp_print_switch_features(struct ds *string, const struct ofp_header *oh)
                         ofputil_capabilities_to_name, ' ');
     ds_put_char(string, '\n');
 
-    ds_put_cstr(string, "actions: ");
-    ofp_print_bit_names(string, features.actions,
-                        ofputil_action_bitmap_to_name, ' ');
-    ds_put_char(string, '\n');
+    switch ((enum ofp_version)oh->version) {
+    case OFP10_VERSION:
+        ds_put_cstr(string, "actions: ");
+        ofp_print_bit_names(string, features.actions,
+                            ofputil_action_bitmap_to_name, ' ');
+        ds_put_char(string, '\n');
+        break;
+    case OFP11_VERSION:
+    case OFP12_VERSION:
+        break;
+    default:
+        NOT_REACHED();
+    }
 
     ofp_print_phy_ports(string, oh->version, &b);
 }
index a943b4ecaafca3ed903602c56df3b299575a92b5..3c3513c4f3d8fefec7e10151f6bb3d32485bfc55 100644 (file)
@@ -2418,7 +2418,16 @@ ofputil_decode_switch_features(const struct ofp_header *oh,
         if (osf->capabilities & htonl(OFPC11_GROUP_STATS)) {
             features->capabilities |= OFPUTIL_C_GROUP_STATS;
         }
-        features->actions = decode_action_bits(osf->actions, of11_action_bits);
+        switch ((enum ofp_version)oh->version) {
+        case OFP11_VERSION:
+        case OFP12_VERSION:
+            features->actions = decode_action_bits(htonl(UINT32_MAX),
+                                                   of11_action_bits);
+            break;
+        case OFP10_VERSION:
+        default:
+            NOT_REACHED();
+        }
     } else {
         return OFPERR_OFPBRC_BAD_VERSION;
     }
@@ -2517,7 +2526,6 @@ ofputil_encode_switch_features(const struct ofputil_switch_features *features,
         if (features->capabilities & OFPUTIL_C_GROUP_STATS) {
             osf->capabilities |= htonl(OFPC11_GROUP_STATS);
         }
-        osf->actions = encode_action_bits(features->actions, of11_action_bits);
         break;
     default:
         NOT_REACHED();
index 35faaff9fd320850cb4532344eaae3ad8836f119..21466247a5297b147f04b30d6936979e2984c68f 100644 (file)
@@ -202,7 +202,6 @@ ff ff ff fe 00 00 00 00 50 54 00 00 00 01 00 00 \
 OFPT_FEATURES_REPLY (OF1.1) (xid=0x1): dpid:0000505400000001
 n_tables:2, n_buffers:256
 capabilities: FLOW_STATS TABLE_STATS PORT_STATS ARP_MATCH_IP
-actions: OUTPUT SET_VLAN_VID SET_VLAN_PCP SET_DL_SRC SET_DL_DST SET_NW_SRC SET_NW_DST SET_NW_ECN SET_NW_TOS SET_TP_SRC SET_TP_DST COPY_TTL_OUT COPY_TTL_IN SET_MPLS_LABEL SET_MPLS_TC SET_MPLS_TTL
  3(eth0): addr:50:54:00:00:00:01
      config:     0
      state:      0