Signed-off-by: Simon Horman <ho...@verge.net.au> ---
v3 * Initial post --- lib/ofp-util.c | 26 ++++++++++++++++++++++++-- lib/ofp-util.h | 3 ++- ofproto/ofproto.c | 2 +- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/lib/ofp-util.c b/lib/ofp-util.c index 10aac6a..1fcd012 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -2304,14 +2304,36 @@ unknown_to_zero(uint64_t count) * those already present in the list of ofpbufs in 'replies'. 'replies' should * have been initialized with ofputil_start_stats_reply(). */ void -ofputil_append_flow_stats_reply(const struct ofputil_flow_stats *fs, +ofputil_append_flow_stats_reply(uint8_t ofp_version, + const struct ofputil_flow_stats *fs, struct list *replies) { struct ofpbuf *reply = ofpbuf_from_list(list_back(replies)); const struct ofp10_stats_msg *osm = reply->data; size_t start_ofs = reply->size; - if (osm->type == htons(OFPST_FLOW)) { + if (osm->type == htons(OFPST_FLOW) && ofp_version == OFP12_VERSION) { + struct ofp11_stats_msg *osm; + struct ofp11_flow_stats *ofs; + + ofpbuf_put_zeros(reply, sizeof osm->pad); + + ofs = ofpbuf_put_uninit(reply, sizeof *ofs); + ofs->table_id = fs->table_id; + ofs->pad = 0; + ofs->duration_sec = htonl(fs->duration_sec); + ofs->duration_nsec = htonl(fs->duration_nsec); + ofs->priority = htons(fs->rule.priority); + ofs->idle_timeout = htons(fs->idle_timeout); + ofs->hard_timeout = htons(fs->hard_timeout); + memset(ofs->pad2, 0, sizeof ofs->pad2); + ofs->cookie = fs->cookie; + ofs->packet_count = htonll(unknown_to_zero(fs->packet_count)); + ofs->byte_count = htonll(unknown_to_zero(fs->byte_count)); + ofpacts_to_openflow11(fs->ofpacts, reply, OFPIT11_APPLY_ACTIONS); + ofs = ofpbuf_at_assert(reply, start_ofs, sizeof *ofs); + ofs->length = htons(reply->size - start_ofs); + } else if (osm->type == htons(OFPST_FLOW) && ofp_version == OFP10_VERSION) { struct ofp10_flow_stats *ofs; ofs = ofpbuf_put_uninit(reply, sizeof *ofs); diff --git a/lib/ofp-util.h b/lib/ofp-util.h index 0ea3ebe..f35dd19 100644 --- a/lib/ofp-util.h +++ b/lib/ofp-util.h @@ -304,7 +304,8 @@ int ofputil_decode_flow_stats_reply(struct ofputil_flow_stats *, struct ofpbuf *msg, bool flow_age_extension, struct ofpbuf *ofpacts); -void ofputil_append_flow_stats_reply(const struct ofputil_flow_stats *, +void ofputil_append_flow_stats_reply(uint8_t ofp_version, + const struct ofputil_flow_stats *, struct list *replies); /* Aggregate stats reply, independent of protocol. */ diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index f037a34..600e04a 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -2442,7 +2442,7 @@ handle_flow_stats_request(struct ofconn *ofconn, ofproto->ofproto_class->rule_get_stats(rule, &fs.packet_count, &fs.byte_count); fs.ofpacts = rule->ofpacts; - ofputil_append_flow_stats_reply(&fs, &replies); + ofputil_append_flow_stats_reply(request->version, &fs, &replies); } ofconn_send_replies(ofconn, &replies); -- 1.7.10.2.484.gcd07cc5 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev