[ovs-dev] [PATCH 40/45] ofp-msgs: Split OFPRAW_OFPST_PORT_{REQUEST, REPLY}

Simon Horman horms at verge.net.au
Mon Jul 30 02:03:38 UTC 2012


Split OFPRAW_OFPST_PORT_{REQUEST,REPLY} into OpenFlow 1.0 and 1.1+
versions.

This allows decoding of Open Flow 1.1 and 1.2 Port Stats Request and
Reply messages.

This prepares for encoding Open Flow 1.1 and 1.2 Port Stats Request and
Reply messages.

Signed-off-by: Simon Horman <horms at verge.net.au>

---

v8
* Initial post
---
 lib/ofp-msgs.h        | 14 ++++++++++----
 tests/ofp-print.at    | 22 +++++++++++++++++++++-
 utilities/ovs-ofctl.c | 15 +++++++++++++--
 3 files changed, 44 insertions(+), 7 deletions(-)

diff --git a/lib/ofp-msgs.h b/lib/ofp-msgs.h
index 7ef7c5a..35d8ca7 100644
--- a/lib/ofp-msgs.h
+++ b/lib/ofp-msgs.h
@@ -216,10 +216,14 @@ enum ofpraw {
     OFPRAW_OFPST12_TABLE_REPLY,
 
     /* OFPST 1.0 (4): struct ofp10_port_stats_request. */
-    OFPRAW_OFPST_PORT_REQUEST,
+    OFPRAW_OFPST10_PORT_REQUEST,
+    /* OFPST 1.1+ (4): struct ofp11_port_stats_request. */
+    OFPRAW_OFPST11_PORT_REQUEST,
 
     /* OFPST 1.0 (4): struct ofp10_port_stats[]. */
-    OFPRAW_OFPST_PORT_REPLY,
+    OFPRAW_OFPST10_PORT_REPLY,
+    /* OFPST 1.1+ (4): struct ofp11_port_stats[]. */
+    OFPRAW_OFPST11_PORT_REPLY,
 
     /* OFPST 1.0 (5): struct ofp10_queue_stats_request. */
     OFPRAW_OFPST_QUEUE_REQUEST,
@@ -382,8 +386,10 @@ enum ofptype {
     OFPTYPE_TABLE_STATS_REPLY,       /* OFPRAW_OFPST10_TABLE_REPLY.
                                       * OFPRAW_OFPST11_TABLE_REPLY.
                                       * OFPRAW_OFPST12_TABLE_REPLY. */
-    OFPTYPE_PORT_STATS_REQUEST,      /* OFPRAW_OFPST_PORT_REQUEST. */
-    OFPTYPE_PORT_STATS_REPLY,        /* OFPRAW_OFPST_PORT_REPLY. */
+    OFPTYPE_PORT_STATS_REQUEST,      /* OFPRAW_OFPST10_PORT_REQUEST.
+                                      * OFPRAW_OFPST11_PORT_REQUEST. */
+    OFPTYPE_PORT_STATS_REPLY,        /* OFPRAW_OFPST10_PORT_REPLY.
+                                      * OFPRAW_OFPST11_PORT_REPLY. */
     OFPTYPE_QUEUE_STATS_REQUEST,     /* OFPRAW_OFPST_QUEUE_REQUEST. */
     OFPTYPE_QUEUE_STATS_REPLY,       /* OFPRAW_OFPST_QUEUE_REPLY. */
     OFPTYPE_PORT_DESC_STATS_REQUEST, /* OFPRAW_OFPST_PORT_DESC_REQUEST. */
diff --git a/tests/ofp-print.at b/tests/ofp-print.at
index b15704e..10152e7 100644
--- a/tests/ofp-print.at
+++ b/tests/ofp-print.at
@@ -4931,7 +4931,7 @@ OFPST_TABLE reply (OF1.2) (xid=0x2): 255 tables
 ])
 AT_CLEANUP
 
-AT_SETUP([OFPST_PORT request])
+AT_SETUP([OFPST_PORT request - 1.0])
 AT_KEYWORDS([ofp-print OFPT_STATS_REQUEST])
 AT_CHECK([ovs-ofctl ofp-print "\
 01 10 00 14 00 00 00 01 00 04 00 00 ff ff 00 00 \
@@ -4941,6 +4941,26 @@ OFPST_PORT request (xid=0x1): port_no=65535
 ])
 AT_CLEANUP
 
+AT_SETUP([OFPST_PORT request - 1.1])
+AT_KEYWORDS([ofp-print OFPT_STATS_REQUEST])
+AT_CHECK([ovs-ofctl ofp-print "\
+02 12 00 18 00 00 00 02 00 04 00 00 00 00 00 00 \
+ff ff 00 00 00 00 00 00 \
+"], [0], [dnl
+OFPST_PORT request (OF1.1) (xid=0x2): port_no=65535
+])
+AT_CLEANUP
+
+AT_SETUP([OFPST_PORT request - 1.2])
+AT_KEYWORDS([ofp-print OFPT_STATS_REQUEST])
+AT_CHECK([ovs-ofctl ofp-print "\
+03 12 00 18 00 00 00 02 00 04 00 00 00 00 00 00 \
+ff ff 00 00 00 00 00 00 \
+"], [0], [dnl
+OFPST_PORT request (OF1.2) (xid=0x2): port_no=65535
+])
+AT_CLEANUP
+
 AT_SETUP([OFPST_PORT reply])
 AT_KEYWORDS([ofp-print OFPT_STATS_REPLY])
 AT_CHECK([ovs-ofctl ofp-print "\
diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c
index ebbd5a1..d4e455d 100644
--- a/utilities/ovs-ofctl.c
+++ b/utilities/ovs-ofctl.c
@@ -1417,10 +1417,21 @@ ofctl_dump_ports(int argc, char *argv[])
     struct ofpbuf *request;
     struct vconn *vconn;
     uint16_t port;
+    enum ofpraw raw;
 
     open_vconn(argv[1], &vconn);
-    request = ofpraw_alloc(OFPRAW_OFPST_PORT_REQUEST,
-                           vconn_get_version(vconn), 0);
+    switch (vconn_get_version(vconn)) {
+    case OFP10_VERSION:
+        raw = OFPRAW_OFPST10_PORT_REQUEST;
+        break;
+    case OFP11_VERSION:
+    case OFP12_VERSION:
+        raw = OFPRAW_OFPST11_PORT_REQUEST;
+        break;
+    default:
+        NOT_REACHED();
+    }
+    request = ofpraw_alloc(raw, vconn_get_version(vconn), 0);
     req = ofpbuf_put_zeros(request, sizeof *req);
     port = argc > 2 ? str_to_port_no(argv[1], argv[2]) : OFPP_NONE;
     req->port_no = htons(port);
-- 
1.7.10.2.484.gcd07cc5




More information about the dev mailing list