[ovs-dev] [PATCH 05/63] ofp-util: Make put_openflow_xid() aware of different OpenFlow versions.

Simon Horman horms at verge.net.au
Wed Jun 27 08:19:41 UTC 2012


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

---

v5
* No change

v4
* Initial post
---
 lib/ofp-util.c | 26 +++++++++++++++-----------
 lib/ofp-util.h |  4 ++--
 2 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index 953eaf0..c09dbba 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -2928,8 +2928,9 @@ ofputil_encode_port_status(const struct ofputil_port_status *ps,
     struct ofpbuf *b;
 
     b = ofpbuf_new(sizeof *ops + sizeof(struct ofp11_port));
-    ops = put_openflow_xid(sizeof *ops, OFPT_PORT_STATUS, htonl(0), b);
-    ops->header.version = ofputil_protocol_to_ofp_version(protocol);
+    ops = put_openflow_xid(sizeof *ops,
+                           ofputil_protocol_to_ofp_version(protocol),
+                           OFPT_PORT_STATUS, htonl(0), b);
     ops->reason = ps->reason;
     ofputil_put_phy_port(ops->header.version, &ps->desc, b);
     update_openflow_length(b);
@@ -3073,7 +3074,8 @@ void *
 make_openflow(size_t openflow_len, uint8_t type, struct ofpbuf **bufferp)
 {
     *bufferp = ofpbuf_new(openflow_len);
-    return put_openflow_xid(openflow_len, type, alloc_xid(), *bufferp);
+    return put_openflow_xid(openflow_len, OFP10_VERSION, type,
+                            alloc_xid(), *bufferp);
 }
 
 /* Similar to make_openflow() but creates a Nicira vendor extension message
@@ -3102,7 +3104,7 @@ make_openflow_xid(size_t openflow_len, uint8_t type, ovs_be32 xid,
                   struct ofpbuf **bufferp)
 {
     *bufferp = ofpbuf_new(openflow_len);
-    return put_openflow_xid(openflow_len, type, xid, *bufferp);
+    return put_openflow_xid(openflow_len, OFP10_VERSION, type, xid, *bufferp);
 }
 
 /* Similar to make_openflow_xid() but creates a Nicira vendor extension message
@@ -3127,7 +3129,8 @@ make_nxmsg_xid(size_t openflow_len, uint32_t subtype, ovs_be32 xid,
 void *
 put_openflow(size_t openflow_len, uint8_t type, struct ofpbuf *buffer)
 {
-    return put_openflow_xid(openflow_len, type, alloc_xid(), buffer);
+    return put_openflow_xid(openflow_len, OFP10_VERSION, type,
+                            alloc_xid(), buffer);
 }
 
 /* Appends 'openflow_len' bytes to 'buffer', starting with an OpenFlow header
@@ -3140,8 +3143,8 @@ put_openflow(size_t openflow_len, uint8_t type, struct ofpbuf *buffer)
  *
  * Returns the header. */
 void *
-put_openflow_xid(size_t openflow_len, uint8_t type, ovs_be32 xid,
-                 struct ofpbuf *buffer)
+put_openflow_xid(size_t openflow_len, uint8_t version,
+                 uint8_t type, ovs_be32 xid, struct ofpbuf *buffer)
 {
     struct ofp_header *oh;
 
@@ -3149,7 +3152,7 @@ put_openflow_xid(size_t openflow_len, uint8_t type, ovs_be32 xid,
     assert(openflow_len <= UINT16_MAX);
 
     oh = ofpbuf_put_uninit(buffer, openflow_len);
-    oh->version = OFP10_VERSION;
+    oh->version = version;
     oh->type = type;
     oh->length = htons(openflow_len);
     oh->xid = xid;
@@ -3173,7 +3176,8 @@ put_nxmsg_xid(size_t openflow_len, uint32_t subtype, ovs_be32 xid,
 {
     struct nicira_header *nxh;
 
-    nxh = put_openflow_xid(openflow_len, OFPT_VENDOR, xid, buffer);
+    nxh = put_openflow_xid(openflow_len, OFP10_VERSION, OFPT_VENDOR,
+                           xid, buffer);
     nxh->vendor = htonl(NX_VENDOR_ID);
     nxh->subtype = htonl(subtype);
     return nxh;
@@ -3196,14 +3200,14 @@ put_stats__(ovs_be32 xid, uint8_t ofp_type,
     if (ofpst_type == htons(OFPST_VENDOR)) {
         struct nicira10_stats_msg *nsm;
 
-        nsm = put_openflow_xid(sizeof *nsm, ofp_type, xid, msg);
+        nsm = put_openflow_xid(sizeof *nsm, OFP10_VERSION, ofp_type, xid, msg);
         nsm->vsm.osm.type = ofpst_type;
         nsm->vsm.vendor = htonl(NX_VENDOR_ID);
         nsm->subtype = nxst_subtype;
     } else {
         struct ofp10_stats_msg *osm;
 
-        osm = put_openflow_xid(sizeof *osm, ofp_type, xid, msg);
+        osm = put_openflow_xid(sizeof *osm, OFP10_VERSION, ofp_type, xid, msg);
         osm->type = ofpst_type;
     }
 }
diff --git a/lib/ofp-util.h b/lib/ofp-util.h
index 8f38c54..fb3fede 100644
--- a/lib/ofp-util.h
+++ b/lib/ofp-util.h
@@ -526,8 +526,8 @@ void *make_nxmsg_xid(size_t openflow_len, uint32_t subtype, ovs_be32 xid,
                      struct ofpbuf **);
 
 void *put_openflow(size_t openflow_len, uint8_t type, struct ofpbuf *);
-void *put_openflow_xid(size_t openflow_len, uint8_t type, ovs_be32 xid,
-                       struct ofpbuf *);
+void *put_openflow_xid(size_t openflow_len, uint8_t version,
+                       uint8_t type, ovs_be32 xid, struct ofpbuf *);
 
 void *put_nxmsg(size_t openflow_len, uint32_t subtype, struct ofpbuf *);
 void *put_nxmsg_xid(size_t openflow_len, uint32_t subtype, ovs_be32 xid,
-- 
1.7.10.2.484.gcd07cc5




More information about the dev mailing list