Signed-off-by: Simon Horman <ho...@verge.net.au> ---
v3 * Initial post --- lib/ofp-util.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/lib/ofp-util.c b/lib/ofp-util.c index 1fcd012..20b288d 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -951,6 +951,7 @@ static const struct ofputil_msg_type ofputil_msg_types[] = { } OFPST12_REPLY(OFPST_DESC, OFPST_DESC, sizeof(struct ofp_desc_stats), 0), + OFPST12_REPLY(OFPST10_FLOW, OFPST_FLOW, 0, 1), #undef OFPST12_REPLY #define NXT(SUBTYPE, MIN_SIZE, EXTRA_MULTIPLE) \ @@ -2189,9 +2190,10 @@ ofputil_decode_flow_stats_reply(struct ofputil_flow_stats *fs, struct ofpbuf *ofpacts) { const struct ofputil_msg_type *type; + const struct ofp_header *oh = msg->l2 ? msg->l2 : msg->data; int code; - ofputil_decode_msg_type(msg->l2 ? msg->l2 : msg->data, &type); + ofputil_decode_msg_type(oh, &type); code = ofputil_msg_type_code(type); if (!msg->l2) { msg->l2 = msg->data; @@ -2200,7 +2202,50 @@ ofputil_decode_flow_stats_reply(struct ofputil_flow_stats *fs, if (!msg->size) { return EOF; - } else if (code == OFPUTIL_OFPST10_FLOW_REPLY) { + } else if (code == OFPUTIL_OFPST10_FLOW_REPLY && + oh->version == OFP12_VERSION) { + struct ofp11_stats_msg *osm; + const struct ofp11_flow_stats *ofs; + size_t length; + + ofpbuf_pull(msg, sizeof osm->pad); + + ofs = ofpbuf_try_pull(msg, sizeof *ofs); + if (!ofs) { + VLOG_WARN_RL(&bad_ofmsg_rl, "OFPST_FLOW reply has %zu leftover " + "bytes at end", msg->size); + return EINVAL; + } + + length = ntohs(ofs->length); + if (length < sizeof *ofs) { + VLOG_WARN_RL(&bad_ofmsg_rl, "OFPST_FLOW reply claims invalid " + "length %zu", length); + return EINVAL; + } + + if (ofputil_pull_ofp12_match(msg, ntohs(ofs->priority), &fs->rule, + NULL, NULL)) { + return EINVAL; + } + + if (ofpacts_pull_openflow11_instructions(msg, length - sizeof *ofs, + ofpacts)) { + return EINVAL; + } + + fs->table_id = ofs->table_id; + fs->duration_sec = ntohl(ofs->duration_sec); + fs->duration_nsec = ntohl(ofs->duration_nsec); + fs->idle_timeout = ntohs(ofs->idle_timeout); + fs->hard_timeout = ntohs(ofs->hard_timeout); + fs->idle_age = -1; + fs->hard_age = -1; + fs->cookie = ofs->cookie; + fs->packet_count = ntohll(ofs->packet_count); + fs->byte_count = ntohll(ofs->byte_count); + } else if (code == OFPUTIL_OFPST10_FLOW_REPLY && + oh->version == OFP10_VERSION) { const struct ofp10_flow_stats *ofs; size_t length; -- 1.7.10.2.484.gcd07cc5 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev