[ovs-dev] [PATCH] Enable OpenFlow 1.0, 1.1, 1.2, and 1.3 by default.

Ben Pfaff blp at nicira.com
Tue Apr 29 20:56:30 UTC 2014


The Open vSwitch software switch now supports all the required features of
OpenFlow 1.0 through 1.3, with one known trivial exception[*].  Enable them
by default in ovs-vswitchd.

For now, ovs-ofctl only enables OpenFlow 1.0 by default.  This is
because ovs-ofctl implements command such as "add-flow" as raw
OpenFlow requests, but those requests have subtly different semantics
in different OpenFlow versions.  For example:

    - In OpenFlow 1.0, a "mod-flow" operation that does not find any
      existing flow to modify adds a new flow.

    - In OpenFlow 1.1, a "mod-flow" operation that does not find any
      existing flow to modify adds a new flow, but only if the
      mod-flow did not match on the flow cookie.

    - In OpenFlow 1.2 and a later, a "mod-flow" operation never adds a
      new flow.

[*] OpenFlow 1.1 requires support for VLANs introduced by Ethertype 0x88a8.
    Open vSwitch does not support this Ethertype.  OpenFlow 1.2 and 1.3 do
    not require support for this Ethertype.

Signed-off-by: Ben Pfaff <blp at nicira.com>
---
 FAQ                     |   19 +++++++++++--------
 lib/ofp-util.h          |   16 +++++++++-------
 tests/ofproto-macros.at |    2 +-
 tests/test-vconn.c      |   12 ++++++------
 utilities/ovs-ofctl.c   |   19 ++++++++++++++++++-
 5 files changed, 45 insertions(+), 23 deletions(-)

diff --git a/FAQ b/FAQ
index c43b0c8..778cc28 100644
--- a/FAQ
+++ b/FAQ
@@ -1119,19 +1119,22 @@ A: The following table lists the versions of OpenFlow supported by
        2.0                yes    [*]    [*]    [*]    ---
        2.1                yes    [*]    [*]    [*]    ---
        2.2                yes    [*]    [*]    [*]    [%]
+       2.3                yes    yes    yes    yes    [%]
 
        [*] Supported, with one or more missing features.
        [%] Support is unsafe: ovs-vswitchd will abort when certain
            unimplemented features are tested.
 
-   Because of missing features, OpenFlow 1.1, 1.2, and 1.3 must be
-   enabled manually.  The following command enables OpenFlow 1.0, 1.1,
-   1.2, and 1.3 on bridge br0:
+   Open vSwitch 2.3 enables OpenFlow 1.0, 1.1, 1.2, and 1.3 by default
+   in ovs-vswitchd.  In Open vSwitch 1.10 through 2.2, OpenFlow 1.1,
+   1.2, and 1.3 must be enabled manually.  The following command
+   enables OpenFlow 1.0, 1.1, 1.2, and 1.3 on bridge br0:
 
        ovs-vsctl set bridge br0 protocols=OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow13
 
-   Use the -O option to enable support for later versions of OpenFlow
-   in ovs-ofctl.  For example:
+   All current versions of ovs-ofctl enable only OpenFlow 1.0 by
+   default.  Use the -O option to enable support for later versions of
+   OpenFlow in ovs-ofctl.  For example:
 
        ovs-ofctl -O OpenFlow13 dump-flows br0
 
@@ -1143,9 +1146,9 @@ A: The following table lists the versions of OpenFlow supported by
    invoked with a special --enable-of14 command line option.
 
    OPENFLOW-1.1+ in the Open vSwitch source tree tracks support for
-   OpenFlow 1.1 and later features.  When support for a given OpenFlow
-   version is solidly implemented, Open vSwitch will enable that
-   version by default.
+   OpenFlow 1.1 and later features.  When support for OpenFlow 1.4 is
+   solidly implemented, Open vSwitch will enable that version by
+   default.
 
 Q: Does Open vSwitch support MPLS?
 
diff --git a/lib/ofp-util.h b/lib/ofp-util.h
index 245cc4e..7b33329 100644
--- a/lib/ofp-util.h
+++ b/lib/ofp-util.h
@@ -170,13 +170,15 @@ void ofputil_format_version_bitmap_names(struct ds *msg, uint32_t bitmap);
 uint32_t ofputil_protocols_to_version_bitmap(enum ofputil_protocol);
 enum ofputil_protocol ofputil_protocols_from_version_bitmap(uint32_t bitmap);
 
-/* Bitmap of OpenFlow versions that Open vSwitch supports. */
-#define OFPUTIL_SUPPORTED_VERSIONS \
-    ((1u << OFP10_VERSION) | (1u << OFP12_VERSION) | (1u << OFP13_VERSION))
-
-/* Bitmap of OpenFlow versions to enable by default (a subset of
- * OFPUTIL_SUPPORTED_VERSIONS). */
-#define OFPUTIL_DEFAULT_VERSIONS (1u << OFP10_VERSION)
+/* Bitmaps of OpenFlow versions that Open vSwitch supports, and that it enables
+ * by default.  When Open vSwitch has experimental or incomplete support for
+ * newer versions of OpenFlow, those versions should not be supported by
+ * default and thus should be omitted from the latter bitmap. */
+#define OFPUTIL_SUPPORTED_VERSIONS ((1u << OFP10_VERSION) | \
+                                    (1u << OFP11_VERSION) | \
+                                    (1u << OFP12_VERSION) | \
+                                    (1u << OFP13_VERSION))
+#define OFPUTIL_DEFAULT_VERSIONS OFPUTIL_SUPPORTED_VERSIONS
 
 enum ofputil_protocol ofputil_protocols_from_string(const char *s);
 
diff --git a/tests/ofproto-macros.at b/tests/ofproto-macros.at
index a82a9b1..4ca3213 100644
--- a/tests/ofproto-macros.at
+++ b/tests/ofproto-macros.at
@@ -83,7 +83,7 @@ m4_define([OVS_VSWITCHD_START],
 /ofproto|INFO|datapath ID changed to fedcba9876543210/d']])
 
    dnl Add bridges, ports, etc.
-   AT_CHECK([ovs-vsctl -- add-br br0 -- set bridge br0 datapath-type=dummy other-config:datapath-id=fedcba9876543210 other-config:hwaddr=aa:55:aa:55:00:00 protocols=[[OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow13]] fail-mode=secure -- $1 m4_if([$2], [], [], [| ${PERL} $srcdir/uuidfilt.pl])], [0], [$2])
+   AT_CHECK([ovs-vsctl -- add-br br0 -- set bridge br0 datapath-type=dummy other-config:datapath-id=fedcba9876543210 other-config:hwaddr=aa:55:aa:55:00:00 fail-mode=secure -- $1 m4_if([$2], [], [], [| ${PERL} $srcdir/uuidfilt.pl])], [0], [$2])
 ])
 
 m4_divert_push([PREPARE_TESTS])
diff --git a/tests/test-vconn.c b/tests/test-vconn.c
index 8b24bd8..ec66f86 100644
--- a/tests/test-vconn.c
+++ b/tests/test-vconn.c
@@ -231,7 +231,7 @@ test_read_hello(int argc OVS_UNUSED, char *argv[])
        if (retval == sizeof hello) {
            enum ofpraw raw;
 
-           CHECK(hello.version, OFP10_VERSION);
+           CHECK(hello.version, OFP13_VERSION);
            CHECK(ofpraw_decode_partial(&raw, &hello, sizeof hello), 0);
            CHECK(raw, OFPRAW_OFPT_HELLO);
            CHECK(ntohs(hello.length), sizeof hello);
@@ -304,7 +304,7 @@ test_send_hello(const char *type, const void *out, size_t out_size,
            if (retval == sizeof hello) {
                enum ofpraw raw;
 
-               CHECK(hello.version, OFP10_VERSION);
+               CHECK(hello.version, OFP13_VERSION);
                CHECK(ofpraw_decode_partial(&raw, &hello, sizeof hello), 0);
                CHECK(raw, OFPRAW_OFPT_HELLO);
                CHECK(ntohs(hello.length), sizeof hello);
@@ -355,7 +355,7 @@ test_send_plain_hello(int argc OVS_UNUSED, char *argv[])
     const char *type = argv[1];
     struct ofpbuf *hello;
 
-    hello = ofpraw_alloc_xid(OFPRAW_OFPT_HELLO, OFP10_VERSION,
+    hello = ofpraw_alloc_xid(OFPRAW_OFPT_HELLO, OFP13_VERSION,
                              htonl(0x12345678), 0);
     test_send_hello(type, ofpbuf_data(hello), ofpbuf_size(hello), 0);
     ofpbuf_delete(hello);
@@ -371,7 +371,7 @@ test_send_long_hello(int argc OVS_UNUSED, char *argv[])
     struct ofpbuf *hello;
     enum { EXTRA_BYTES = 8 };
 
-    hello = ofpraw_alloc_xid(OFPRAW_OFPT_HELLO, OFP10_VERSION,
+    hello = ofpraw_alloc_xid(OFPRAW_OFPT_HELLO, OFP13_VERSION,
                              htonl(0x12345678), EXTRA_BYTES);
     ofpbuf_put_zeros(hello, EXTRA_BYTES);
     ofpmsg_update_length(hello);
@@ -387,7 +387,7 @@ test_send_echo_hello(int argc OVS_UNUSED, char *argv[])
     const char *type = argv[1];
     struct ofpbuf *echo;
 
-    echo = ofpraw_alloc_xid(OFPRAW_OFPT_ECHO_REQUEST, OFP10_VERSION,
+    echo = ofpraw_alloc_xid(OFPRAW_OFPT_ECHO_REQUEST, OFP13_VERSION,
                              htonl(0x12345678), 0);
     test_send_hello(type, ofpbuf_data(echo), ofpbuf_size(echo), EPROTO);
     ofpbuf_delete(echo);
@@ -413,7 +413,7 @@ test_send_invalid_version_hello(int argc OVS_UNUSED, char *argv[])
     const char *type = argv[1];
     struct ofpbuf *hello;
 
-    hello = ofpraw_alloc_xid(OFPRAW_OFPT_HELLO, OFP10_VERSION,
+    hello = ofpraw_alloc_xid(OFPRAW_OFPT_HELLO, OFP13_VERSION,
                              htonl(0x12345678), 0);
     ((struct ofp_header *) ofpbuf_data(hello))->version = 0;
     test_send_hello(type, ofpbuf_data(hello), ofpbuf_size(hello), EPROTO);
diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c
index 8be8626..d648025 100644
--- a/utilities/ovs-ofctl.c
+++ b/utilities/ovs-ofctl.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -174,6 +174,23 @@ parse_options(int argc, char *argv[])
     uint32_t versions;
     enum ofputil_protocol version_protocols;
 
+    /* For now, ovs-ofctl only enables OpenFlow 1.0 by default.  This is
+     * because ovs-ofctl implements command such as "add-flow" as raw OpenFlow
+     * requests, but those requests have subtly different semantics in
+     * different OpenFlow versions.  For example:
+     *
+     *     - In OpenFlow 1.0, a "mod-flow" operation that does not find any
+     *       existing flow to modify adds a new flow.
+     *
+     *     - In OpenFlow 1.1, a "mod-flow" operation that does not find any
+     *       existing flow to modify adds a new flow, but only if the mod-flow
+     *       did not match on the flow cookie.
+     *
+     *     - In OpenFlow 1.2 and a later, a "mod-flow" operation never adds a
+     *       new flow.
+     */
+    set_allowed_ofp_versions("OpenFlow10");
+
     for (;;) {
         unsigned long int timeout;
         int c;
-- 
1.7.10.4




More information about the dev mailing list