mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 06:15:47 +00:00
ovs-ofctl: Handle any number of buckets in group statistics
struct ofputil_group_stats has an arbitrary limit of 16 buckets for which it can record statistics. However the code does not appear to enforce this limit and it seems to me that the code could overflow. This patch aims to remove the arbitrary limit by changing the 'bucket_stats' field of struct ofputil_group_stats from a fixed length array to a pointer whose storage is allocated and freed as necessary. Signed-off-by: Simon Horman <horms@verge.net.au> Signed-off-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
@@ -5480,7 +5480,8 @@ ofputil_decode_group_stats_request(const struct ofp_header *request,
|
||||
}
|
||||
|
||||
/* Converts a group stats reply in 'msg' into an abstract ofputil_group_stats
|
||||
* in 'gs'.
|
||||
* in 'gs'. Assigns freshly allocated memory to gs->bucket_stats for the
|
||||
* caller to eventually free.
|
||||
*
|
||||
* Multiple group stats replies can be packed into a single OpenFlow message.
|
||||
* Calling this function multiple times for a single 'msg' iterates through the
|
||||
@@ -5501,6 +5502,7 @@ ofputil_decode_group_stats_reply(struct ofpbuf *msg,
|
||||
size_t length;
|
||||
size_t i;
|
||||
|
||||
gs->bucket_stats = NULL;
|
||||
error = (msg->l2
|
||||
? ofpraw_decode(&raw, msg->l2)
|
||||
: ofpraw_pull(&raw, msg));
|
||||
@@ -5557,6 +5559,7 @@ ofputil_decode_group_stats_reply(struct ofpbuf *msg,
|
||||
return OFPERR_OFPBRC_BAD_LEN;
|
||||
}
|
||||
|
||||
gs->bucket_stats = xmalloc(gs->n_buckets * sizeof *gs->bucket_stats);
|
||||
for (i = 0; i < gs->n_buckets; i++) {
|
||||
gs->bucket_stats[i].packet_count = ntohll(obc[i].packet_count);
|
||||
gs->bucket_stats[i].byte_count = ntohll(obc[i].byte_count);
|
||||
|
Reference in New Issue
Block a user