[ovs-dev] [PATCH 07/38] ofp-util: Allow decoding of Open Flow 1.2 Flow Statistics Request Messages

Simon Horman horms at verge.net.au
Tue Aug 21 01:53:53 UTC 2012


On Fri, Aug 10, 2012 at 09:43:11AM -0700, Ben Pfaff wrote:
> On Thu, Aug 09, 2012 at 05:49:28PM +0900, Simon Horman wrote:
> > Allow decoding of Open Flow 1.1 and 1.2 flow and aggregate flow statistics
> > request messages.
> > 
> > Signed-off-by: Simon Horman <horms at verge.net.au>
> 
> I guess that this should create a new function to handle the new
> OF1.[12] message type, instead of shoehorning it into the existing
> OF1.0 function.

Done. For reference the result is as follows.

commit 13b1146d2e8fd84be6b0d25be4392743522735e9
Author: Simon Horman <horms at verge.net.au>
Date:   Tue Jun 19 09:58:13 2012 +0900

    ofp-util: Allow decoding of Open Flow 1.2 Flow Statistics Request Messages
    
    Allow decoding of Open Flow 1.1 and 1.2 flow and aggregate flow statistics
    request messages.
    
    Signed-off-by: Simon Horman <horms at verge.net.au>
    
    ---
    
    v12
    * Break Open FLow 1.1+ logic out into a separate function
      and leave Open Flow 1.0 logic function untouched other than
      renaming it.
    
    v11
    * No change
    
    v10
    * Manual rebase
    
    v9
    * No change
    
    v8
    * Manual rebase
    * Add ofp-print test
    
    v7
    * Omitted
    
    v6
    * No change
    
    v5
    * Manual rebase
    
    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

diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index ee86a87..68f5356 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -1396,9 +1396,9 @@ 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,
-                                  bool aggregate)
+ofputil_decode_ofpst10_flow_request(struct ofputil_flow_stats_request *fsr,
+                                    const struct ofp10_flow_stats_request *ofsr,
+                                    bool aggregate)
 {
     fsr->aggregate = aggregate;
     ofputil_cls_rule_from_ofp10_match(&ofsr->match, 0, &fsr->match);
@@ -1410,6 +1410,33 @@ ofputil_decode_ofpst_flow_request(struct ofputil_flow_stats_request *fsr,
 }
 
 static enum ofperr
+ofputil_decode_ofpst11_flow_request(struct ofputil_flow_stats_request *fsr,
+                                    struct ofpbuf *b, bool aggregate)
+{
+    const struct ofp11_flow_stats_request *ofsr;
+    enum ofperr error;
+
+    ofsr = ofpbuf_pull(b, sizeof *ofsr);
+    fsr->aggregate = aggregate;
+    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_ofp11_match(b, 0, &fsr->match, NULL);
+    if (error) {
+        return error;
+    }
+
+    return 0;
+}
+
+static enum ofperr
 ofputil_decode_nxst_flow_request(struct ofputil_flow_stats_request *fsr,
                                  struct ofpbuf *b, bool aggregate)
 {
@@ -1447,10 +1474,13 @@ ofputil_decode_flow_stats_request(struct ofputil_flow_stats_request *fsr,
     raw = ofpraw_pull_assert(&b);
     switch ((int) raw) {
     case OFPRAW_OFPST10_FLOW_REQUEST:
-        return ofputil_decode_ofpst_flow_request(fsr, b.data, false);
+        return ofputil_decode_ofpst10_flow_request(fsr, b.data, false);
 
     case OFPRAW_OFPST_AGGREGATE_REQUEST:
-        return ofputil_decode_ofpst_flow_request(fsr, b.data, true);
+        return ofputil_decode_ofpst10_flow_request(fsr, b.data, true);
+
+    case OFPRAW_OFPST11_FLOW_REQUEST:
+        return ofputil_decode_ofpst11_flow_request(fsr, &b, false);
 
     case OFPRAW_NXST_FLOW_REQUEST:
         return ofputil_decode_nxst_flow_request(fsr, &b, false);
diff --git a/tests/ofp-print.at b/tests/ofp-print.at
index 376f5b8..e01419f 100644
--- a/tests/ofp-print.at
+++ b/tests/ofp-print.at
@@ -645,7 +645,7 @@ DP Description: None
 ])
 AT_CLEANUP
 
-AT_SETUP([OFPST_FLOW request])
+AT_SETUP([OFPST_FLOW request - OF1.0])
 AT_KEYWORDS([ofp-print OFPT_STATS_REQUEST])
 AT_CHECK([ovs-ofctl ofp-print "\
 01 10 00 38 00 00 00 04 00 01 00 00 00 38 20 ff \
@@ -657,6 +657,18 @@ OFPST_FLOW request (xid=0x4): @&t@
 ])
 AT_CLEANUP
 
+AT_SETUP([OFPST_FLOW request - OF1.2])
+AT_KEYWORDS([ofp-print OFPT_STATS_REQUEST])
+AT_CHECK([ovs-ofctl ofp-print "\
+03 12 00 38 00 00 00 02 00 01 00 00 00 00 00 00 \
+ff 00 00 00 ff ff ff ff ff ff ff ff 00 00 00 00 \
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \
+00 01 00 04 00 00 00 00 \
+"], [0], [dnl
+OFPST_FLOW request (OF1.2) (xid=0x2): @&t@
+])
+AT_CLEANUP
+
 AT_SETUP([OFPST_FLOW reply - OF1.0])
 AT_KEYWORDS([ofp-print OFPT_STATS_REPLY])
 AT_CHECK([ovs-ofctl ofp-print "\



More information about the dev mailing list