[ovs-dev] [PATCH v3 1/4] ofp-msg: Add helpers for allowing multipart requests

Simon Horman horms at verge.net.au
Mon Jun 16 02:33:12 UTC 2014


Add helpers for allowing requests and use them in handle_openflow__().

This is a in preparation for supporting multipart requests
on a per message type basis.

Signed-off-by: Simon Horman <horms at verge.net.au>
---
 lib/ofp-msgs.c    | 34 ++++++++++++++++++++++++++++++++++
 lib/ofp-msgs.h    |  2 ++
 ofproto/ofproto.c |  9 ++++-----
 3 files changed, 40 insertions(+), 5 deletions(-)

diff --git a/lib/ofp-msgs.c b/lib/ofp-msgs.c
index 602f8b4..29f9770 100644
--- a/lib/ofp-msgs.c
+++ b/lib/ofp-msgs.c
@@ -884,6 +884,40 @@ ofpmsg_is_stat_request(const struct ofp_header *oh)
 {
     return ofp_is_stat_request(oh->version, oh->type);
 }
+
+/* Return if it's a multpart request message
+ * with more parts to follow */
+bool
+ofpmsg_is_mp_request(const struct ofp_header *oh)
+{
+    bool retval;
+
+    switch (oh->version) {
+    case OFP10_VERSION:
+    case OFP11_VERSION:
+    case OFP12_VERSION:
+        retval = false;
+        break;
+    case OFP13_VERSION:
+    case OFP14_VERSION:
+    case OFP15_VERSION:
+        retval = ofpmsg_is_stat_request(oh);
+        break;
+    default:
+        OVS_NOT_REACHED();
+    }
+
+    return retval;
+}
+
+/* Return if type of a multipart request message
+ * that may be buffered and processed as multiple messages. */
+bool
+ofpmsg_may_buffer_mp_request(enum ofptype type OVS_UNUSED)
+{
+    /* Currently no types are allowed to be buffered. */
+    return false;
+}
 
 static ovs_be16 *ofpmp_flags__(const struct ofp_header *);
 
diff --git a/lib/ofp-msgs.h b/lib/ofp-msgs.h
index 1642f1f..137e1e0 100644
--- a/lib/ofp-msgs.h
+++ b/lib/ofp-msgs.h
@@ -671,6 +671,8 @@ bool ofpmsg_is_stat_request(const struct ofp_header *);
  * that is, only a multipart reply may have more than one part.  OpenFlow 1.3
  * adds one multipart request.  This code does not yet support multipart
  * requests. */
+bool ofpmsg_is_mp_request(const struct ofp_header *oh);
+bool ofpmsg_may_buffer_mp_request(enum ofptype type);
 
 /* Encoding multipart replies.
  *
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index a9a9d91..f8d2690 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -5927,11 +5927,10 @@ handle_openflow__(struct ofconn *ofconn, const struct ofpbuf *msg)
     if (error) {
         return error;
     }
-    if (oh->version >= OFP13_VERSION && ofpmsg_is_stat_request(oh)
-        && ofpmp_more(oh)) {
-        /* We have no buffer implementation for multipart requests.
-         * Report overflow for requests which consists of multiple
-         * messages. */
+    if (ofpmsg_is_mp_request(oh) && ofpmp_more(oh)
+        && !ofpmsg_may_buffer_mp_request(type)) {
+        /* Report overflow for requests which consist of multiple message
+         * for which multiple message handling is not available. */
         return OFPERR_OFPBRC_MULTIPART_BUFFER_OVERFLOW;
     }
 
-- 
2.0.0.rc2




More information about the dev mailing list