ds_put_format(s, "byte_count=%"PRIu64"", gs.bucket_stats[bucket_i].byte_count);
}
}
+
+ free(gs.bucket_stats);
}
}
}
/* 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
size_t length;
size_t i;
+ gs->bucket_stats = NULL;
error = (msg->l2
? ofpraw_decode(&raw, msg->l2)
: ofpraw_pull(&raw, 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);
uint32_t duration_sec; /* UINT32_MAX if unknown. */
uint32_t duration_nsec;
uint32_t n_buckets;
- struct bucket_counter bucket_stats[16];
+ struct bucket_counter *bucket_stats;
};
/* Group features reply, independent of protocol. */
long long int now = time_msec();
int error;
+ ogs.bucket_stats = xmalloc(group->n_buckets * sizeof *ogs.bucket_stats);
+
error = (ofproto->ofproto_class->group_get_stats
? ofproto->ofproto_class->group_get_stats(group, &ogs)
: EOPNOTSUPP);
calc_duration(group->created, now, &ogs.duration_sec, &ogs.duration_nsec);
ofputil_append_group_stats(replies, &ogs);
+
+ free(ogs.bucket_stats);
}
static enum ofperr