Allow decoding of Open Flow 1.1 and 1.2 flow and aggregate flow statistics
request messages.

Signed-off-by: Simon Horman <ho...@verge.net.au>

---

v4
* Use OFPG11_ANY in place of OFPG_ANY.
  The value is the same, but it seems to make sense to
  use the Open Flow 1.1 constant when working with Open Flow 1.1.
* Do not handle Open Flow 1.1, the parsing is slightly different
  and not supplied by this patch.
* Use sizeof(struct ofp11_flow_stats_request) as the minimum size of the
  message, previously sizeof(struct ofp10_flow_stats_request) was
  incorrectly used.
* Indicate that the message may be larger than the minimum size.
* Handle OFPUTIL_OFPST11_FLOW_REQUEST and OFPUTIL_OFPST11_AGGREGATE_REQUEST in
  ofputil_decode_flow_stats_request().
* Add entry for Open Flow 1.2 aggregate request to ofputil_msg_types[]

v3
* Initial post
---
 lib/ofp-util.c | 46 +++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 39 insertions(+), 7 deletions(-)

diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index da88447..e8e2bea 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -899,6 +899,10 @@ static const struct ofputil_msg_type ofputil_msg_types[] = 
{
         EXTRA_MULTIPLE                                          \
     }
     OFPST12_REQUEST(OFPST_DESC, OFPST_DESC, 0, 0),
+    OFPST12_REQUEST(OFPST11_FLOW, OFPST_FLOW,
+                    sizeof(struct ofp11_flow_stats_request), 1),
+    OFPST12_REQUEST(OFPST11_AGGREGATE, OFPST_AGGREGATE,
+                    sizeof(struct ofp11_flow_stats_request), 1),
     OFPST12_REQUEST(OFPST_TABLE, OFPST_TABLE, 0, 0),
     OFPST12_REQUEST(OFPST_PORT_DESC, OFPST_PORT_DESC, 0, 0),
 #undef OFPST12_REQUEST
@@ -1983,14 +1987,40 @@ ofputil_flow_mod_usable_protocols(const struct 
ofputil_flow_mod *fms,
 
 static enum ofperr
 ofputil_decode_ofpst_flow_request(struct ofputil_flow_stats_request *fsr,
-                                  const struct ofp10_flow_stats_request *ofsr,
+                                  uint8_t ofp_version, struct ofpbuf *b,
                                   bool aggregate)
 {
     fsr->aggregate = aggregate;
-    ofputil_cls_rule_from_ofp10_match(&ofsr->match, 0, &fsr->match);
-    fsr->out_port = ntohs(ofsr->out_port);
-    fsr->table_id = ofsr->table_id;
-    fsr->cookie = fsr->cookie_mask = htonll(0);
+
+    if (ofp_version == OFP12_VERSION) {
+        const struct ofp11_flow_stats_request *ofsr;
+        enum ofperr error;
+
+        ofsr = ofpbuf_pull(b, sizeof *ofsr);
+        fsr->table_id = ofsr->table_id;
+        error = ofputil_port_from_ofp11(ofsr->out_port, &fsr->out_port);
+        if (error) {
+            return error;
+        }
+        if (ofsr->out_group != htonl(OFPG11_ANY)) {
+            return OFPERR_NXFMFC_GROUPS_NOT_SUPPORTED;
+        }
+        fsr->cookie = ofsr->cookie;
+        fsr->cookie_mask = ofsr->cookie_mask;
+        error = ofputil_pull_ofp12_match(b, 0, &fsr->match, NULL, NULL);
+        if (error) {
+            return error;
+        }
+    } else if (ofp_version == OFP10_VERSION) {
+        const struct ofp10_flow_stats_request *ofsr = b->data;
+
+        ofputil_cls_rule_from_ofp10_match(&ofsr->match, 0, &fsr->match);
+        fsr->out_port = ntohs(ofsr->out_port);
+        fsr->table_id = ofsr->table_id;
+        fsr->cookie = fsr->cookie_mask = htonll(0);
+    } else {
+        NOT_REACHED();
+    }
 
     return 0;
 }
@@ -2037,10 +2067,12 @@ ofputil_decode_flow_stats_request(struct 
ofputil_flow_stats_request *fsr,
     code = ofputil_msg_type_code(type);
     switch (code) {
     case OFPUTIL_OFPST10_FLOW_REQUEST:
-        return ofputil_decode_ofpst_flow_request(fsr, b.data, false);
+    case OFPUTIL_OFPST11_FLOW_REQUEST:
+        return ofputil_decode_ofpst_flow_request(fsr, oh->version, &b, false);
 
     case OFPUTIL_OFPST10_AGGREGATE_REQUEST:
-        return ofputil_decode_ofpst_flow_request(fsr, b.data, true);
+    case OFPUTIL_OFPST11_AGGREGATE_REQUEST:
+        return ofputil_decode_ofpst_flow_request(fsr, oh->version, &b, true);
 
     case OFPUTIL_NXST_FLOW_REQUEST:
         return ofputil_decode_nxst_flow_request(fsr, &b, false);
-- 
1.7.10.2.484.gcd07cc5

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to