ovs-ofctl: By default, do not set flow format for OpenFlow 1.1+
authorSimon Horman <horms@verge.net.au>
Mon, 19 Nov 2012 05:59:34 +0000 (14:59 +0900)
committerBen Pfaff <blp@nicira.com>
Thu, 29 Nov 2012 16:08:17 +0000 (08:08 -0800)
Only set the default format for ovs-ofctl monitor if
OpenFlow 1.0 is the prevailing version. IMHO that is
the only case where it makes sense.

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
utilities/ovs-ofctl.c

index 80a202f..df2c6aa 100644 (file)
@@ -1419,19 +1419,32 @@ ofctl_monitor(int argc, char *argv[])
     if (preferred_packet_in_format >= 0) {
         set_packet_in_format(vconn, preferred_packet_in_format);
     } else {
-        struct ofpbuf *spif, *reply;
-
-        spif = ofputil_make_set_packet_in_format(vconn_get_version(vconn),
-                                                 NXPIF_NXM);
-        run(vconn_transact_noreply(vconn, spif, &reply),
-            "talking to %s", vconn_get_name(vconn));
-        if (reply) {
-            char *s = ofp_to_string(reply->data, reply->size, 2);
-            VLOG_DBG("%s: failed to set packet in format to nxm, controller"
-                     " replied: %s. Falling back to the switch default.",
-                     vconn_get_name(vconn), s);
-            free(s);
-            ofpbuf_delete(reply);
+        enum ofp_version version = vconn_get_version(vconn);
+
+        switch (version) {
+        case OFP10_VERSION: {
+            struct ofpbuf *spif, *reply;
+
+            spif = ofputil_make_set_packet_in_format(vconn_get_version(vconn),
+                                                     NXPIF_NXM);
+            run(vconn_transact_noreply(vconn, spif, &reply),
+                "talking to %s", vconn_get_name(vconn));
+            if (reply) {
+                char *s = ofp_to_string(reply->data, reply->size, 2);
+                VLOG_DBG("%s: failed to set packet in format to nxm, controller"
+                        " replied: %s. Falling back to the switch default.",
+                        vconn_get_name(vconn), s);
+                free(s);
+                ofpbuf_delete(reply);
+            }
+            break;
+        }
+        case OFP11_VERSION:
+        case OFP12_VERSION:
+        case OFP13_VERSION:
+            break;
+        default:
+            NOT_REACHED();
         }
     }