summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2011-05-26 09:34:05 -0700
committerBen Pfaff <blp@nicira.com>2011-06-14 11:21:49 -0700
commit03cd34939e0f90fab30daf74034de0fbd1af17ec (patch)
treeb5de2abcf56d7e03e2ebb6e45c593a858b19f878
parent28c8bad14f17fea722632e6483e61c80a1b9a8e0 (diff)
downloadopenvswitch-03cd34939e0f90fab30daf74034de0fbd1af17ec.tar.gz
openflow: Remove 'body' member from struct ofp_stats_msg.
This member does not actually help with anything.
-rw-r--r--include/openflow/openflow.h1
-rw-r--r--lib/ofp-util.c17
-rw-r--r--utilities/ovs-ofctl.c5
3 files changed, 10 insertions, 13 deletions
diff --git a/include/openflow/openflow.h b/include/openflow/openflow.h
index 9213be640..5329f20ac 100644
--- a/include/openflow/openflow.h
+++ b/include/openflow/openflow.h
@@ -738,7 +738,6 @@ struct ofp_stats_msg {
ovs_be16 type; /* One of the OFPST_* constants. */
ovs_be16 flags; /* Requests: always 0.
* Replies: 0 or OFPSF_REPLY_MORE. */
- uint8_t body[0]; /* Body of the request. */
};
OFP_ASSERT(sizeof(struct ofp_stats_msg) == 12);
diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index 2c6afbe01..e96ace941 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -413,7 +413,7 @@ check_nxstats_msg(const struct ofp_header *oh)
const struct ofp_stats_msg *osm = (const struct ofp_stats_msg *) oh;
ovs_be32 vendor;
- memcpy(&vendor, osm->body, sizeof vendor);
+ memcpy(&vendor, osm + 1, sizeof vendor);
if (vendor != htonl(NX_VENDOR_ID)) {
VLOG_WARN_RL(&bad_ofmsg_rl, "received vendor stats message for "
"unknown vendor %"PRIx32, ntohl(vendor));
@@ -1524,15 +1524,14 @@ update_openflow_length(struct ofpbuf *buffer)
}
/* Creates an ofp_stats_msg with the given 'type' and 'body_len' bytes of space
- * allocated for the 'body' member. Returns the first byte of the 'body'
- * member. */
+ * allocated following the ofp_stats_msg header. */
void *
ofputil_make_stats_request(size_t body_len, uint16_t type,
struct ofpbuf **bufferp)
{
struct ofp_stats_msg *request;
- request = make_openflow(offsetof(struct ofp_stats_msg, body)
- + body_len, OFPT_STATS_REQUEST, bufferp);
+ request = make_openflow(sizeof *request + body_len, OFPT_STATS_REQUEST,
+ bufferp);
request->type = htons(type);
request->flags = htons(0);
return request + 1;
@@ -1554,7 +1553,7 @@ ofputil_make_nxstats_request(size_t openflow_len, uint32_t subtype,
return nsm;
}
-/* Returns the first byte of the body of the ofp_stats_msg in 'oh'. */
+/* Returns the first byte past the ofp_stats_msg header in 'oh'. */
const void *
ofputil_stats_body(const struct ofp_header *oh)
{
@@ -1562,7 +1561,7 @@ ofputil_stats_body(const struct ofp_header *oh)
return (const struct ofp_stats_msg *) oh + 1;
}
-/* Returns the length of the body of the ofp_stats_msg in 'oh'. */
+/* Returns the number of bytes past the ofp_stats_msg header in 'oh'. */
size_t
ofputil_stats_body_len(const struct ofp_header *oh)
{
@@ -1570,7 +1569,7 @@ ofputil_stats_body_len(const struct ofp_header *oh)
return ntohs(oh->length) - sizeof(struct ofp_stats_msg);
}
-/* Returns the first byte of the body of the nicira_stats_msg in 'oh'. */
+/* Returns the first byte past the nicira_stats_msg header in 'oh'. */
const void *
ofputil_nxstats_body(const struct ofp_header *oh)
{
@@ -1578,7 +1577,7 @@ ofputil_nxstats_body(const struct ofp_header *oh)
return ((const struct nicira_stats_msg *) oh) + 1;
}
-/* Returns the length of the body of the nicira_stats_msg in 'oh'. */
+/* Returns the number of bytes past the nicira_stats_msg header in 'oh'. */
size_t
ofputil_nxstats_body_len(const struct ofp_header *oh)
{
diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c
index 751176942..473385d37 100644
--- a/utilities/ovs-ofctl.c
+++ b/utilities/ovs-ofctl.c
@@ -263,11 +263,10 @@ static void *
alloc_stats_request(size_t body_len, uint16_t type, struct ofpbuf **bufferp)
{
struct ofp_stats_msg *rq;
- rq = make_openflow((offsetof(struct ofp_stats_msg, body)
- + body_len), OFPT_STATS_REQUEST, bufferp);
+ rq = make_openflow(sizeof *rq + body_len, OFPT_STATS_REQUEST, bufferp);
rq->type = htons(type);
rq->flags = htons(0);
- return rq->body;
+ return rq + 1;
}
static void