Signed-off-by: Simon Horman <ho...@verge.net.au> ---
v4 * Use OFPUTIL_OFPST11_AGGREGATE_REPLY as code for Open Flow 1.1 and 1.2 messages. * Don't explicitly pull message header pad, it is now handled by ofputil_make_stats_reply() * Manual rebase v3 * Initial post --- include/openflow/openflow-1.1.h | 10 ++++++++++ lib/ofp-print.c | 18 ++++++++++++------ lib/ofp-util.c | 14 +++++++++++++- 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/include/openflow/openflow-1.1.h b/include/openflow/openflow-1.1.h index dd87247..4cf2d74 100644 --- a/include/openflow/openflow-1.1.h +++ b/include/openflow/openflow-1.1.h @@ -617,6 +617,16 @@ OFP_ASSERT(sizeof(struct ofp11_flow_stats) == 48); /* Body for ofp_stats_request of type OFPST_AGGREGATE. */ /* Identical to ofp11_flow_stats_request */ +/* Reply to OFPST_AGGREGATE request. */ +/* Same elements as ofp10_aggregate_stats_reply but different alignment */ +struct ofp11_aggregate_stats_reply { + ovs_be64 packet_count; /* Number of packets in flows. */ + ovs_be64 byte_count; /* Number of bytes in flows. */ + ovs_be32 flow_count; /* Number of flows. */ + uint8_t pad[4]; /* Align to 64 bits. */ +}; +OFP_ASSERT(sizeof(struct ofp11_aggregate_stats_reply) == 24); + /* Body of reply to OFPST_TABLE request. */ struct ofp11_table_stats { uint8_t table_id; /* Identifier of table. Lower numbered tables diff --git a/lib/ofp-print.c b/lib/ofp-print.c index 8dc4fb3..01d5076 100644 --- a/lib/ofp-print.c +++ b/lib/ofp-print.c @@ -1003,13 +1003,19 @@ ofp_print_flow_stats_reply(struct ds *string, const struct ofp_header *oh) static void ofp_print_ofpst_aggregate_reply(struct ds *string, const struct ofp_header *oh) { - const struct ofp10_aggregate_stats_reply *asr; + struct ofp11_aggregate_stats_reply *asr = ofputil_stats_msg_body(oh); - asr = ofputil_stats_msg_body(oh); - ds_put_format(string, " packet_count=%"PRIu64, - ntohll(get_32aligned_be64(&asr->packet_count))); - ds_put_format(string, " byte_count=%"PRIu64, - ntohll(get_32aligned_be64(&asr->byte_count))); + if (oh->version == OFP10_VERSION) { + const struct ofp10_aggregate_stats_reply *a10sr; + + a10sr = ofputil_stats_msg_body(oh); + asr->packet_count = get_32aligned_be64(&a10sr->packet_count); + asr->byte_count = get_32aligned_be64(&a10sr->byte_count); + asr->flow_count = a10sr->flow_count; + } + + ds_put_format(string, " packet_count=%"PRIu64, ntohll(asr->packet_count)); + ds_put_format(string, " byte_count=%"PRIu64, ntohll(asr->byte_count)); ds_put_format(string, " flow_count=%"PRIu32, ntohl(asr->flow_count)); } diff --git a/lib/ofp-util.c b/lib/ofp-util.c index 7f576dc..83f187f 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -940,6 +940,8 @@ static const struct ofputil_msg_type ofputil_msg_types[] = { } OFPST11_REPLY(OFPST_DESC, OFPST_DESC, sizeof(struct ofp_desc_stats), 0), + OFPST11_REPLY(OFPST11_AGGREGATE, OFPST_AGGREGATE, + sizeof(struct ofp11_aggregate_stats_reply), 0), #undef OFPST11_REPLY #define OFPST12_REPLY(STAT, RAW_STAT, MIN_SIZE, EXTRA_MULTIPLE) \ @@ -952,6 +954,8 @@ static const struct ofputil_msg_type ofputil_msg_types[] = { } OFPST12_REPLY(OFPST_DESC, OFPST_DESC, sizeof(struct ofp_desc_stats), 0), + OFPST12_REPLY(OFPST11_AGGREGATE, OFPST_AGGREGATE, + sizeof(struct ofp11_aggregate_stats_reply), 0), OFPST12_REPLY(OFPST11_FLOW, OFPST_FLOW, 0, 1), #undef OFPST12_REPLY @@ -2448,7 +2452,15 @@ ofputil_encode_aggregate_stats_reply( ofputil_decode_msg_type(request, &type); code = ofputil_msg_type_code(type); - if (code == OFPUTIL_OFPST10_AGGREGATE_REQUEST) { + if (code == OFPUTIL_OFPST11_AGGREGATE_REQUEST) { + struct ofp11_stats_msg *osm; + struct ofp11_aggregate_stats_reply *asr; + + asr = ofputil_make_stats_reply(sizeof *asr, request, &msg); + asr->packet_count = htonll(unknown_to_zero(stats->packet_count)); + asr->byte_count = htonll(unknown_to_zero(stats->byte_count)); + asr->flow_count = htonl(stats->flow_count); + } else if (code == OFPUTIL_OFPST10_AGGREGATE_REQUEST) { struct ofp10_aggregate_stats_reply *asr; asr = ofputil_make_stats_reply(sizeof *asr, request, &msg); -- 1.7.10.2.484.gcd07cc5 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev