Signed-off-by: Simon Horman <ho...@verge.net.au> ---
v10 * No change v9 * No change v8 * Initial post --- lib/ofp-util.c | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/lib/ofp-util.c b/lib/ofp-util.c index 878d307..d5e8bbf 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -1404,14 +1404,33 @@ ofputil_flow_mod_usable_protocols(const struct ofputil_flow_mod *fms, static enum ofperr ofputil_decode_ofpst_flow_request(struct ofputil_flow_stats_request *fsr, - const struct ofp10_flow_stats_request *ofsr, - bool aggregate) + struct ofpbuf *msg, bool aggregate) { + enum ofperr error; + enum ofpraw raw; + + error = (msg->l2 + ? ofpraw_decode(&raw, msg->l2) + : ofpraw_pull(&raw, msg)); + if (error) { + return error; + } + fsr->aggregate = aggregate; - ofputil_cls_rule_from_ofp10_match(&ofsr->match, 0, &fsr->match); - fsr->out_port = ntohs(ofsr->out_port); - fsr->table_id = ofsr->table_id; - fsr->cookie = fsr->cookie_mask = htonll(0); + + if (!msg->size) { + return EOF; + } else if (raw == OFPRAW_OFPST10_FLOW_REQUEST || + raw == OFPRAW_OFPST_AGGREGATE_REQUEST) { + const struct ofp10_flow_stats_request *ofsr = msg->data; + + ofputil_cls_rule_from_ofp10_match(&ofsr->match, 0, &fsr->match); + fsr->out_port = ntohs(ofsr->out_port); + fsr->table_id = ofsr->table_id; + fsr->cookie = fsr->cookie_mask = htonll(0); + } else { + NOT_REACHED(); + } return 0; } @@ -1454,10 +1473,10 @@ ofputil_decode_flow_stats_request(struct ofputil_flow_stats_request *fsr, raw = ofpraw_pull_assert(&b); switch ((int) raw) { case OFPRAW_OFPST10_FLOW_REQUEST: - return ofputil_decode_ofpst_flow_request(fsr, b.data, false); + return ofputil_decode_ofpst_flow_request(fsr, &b, false); case OFPRAW_OFPST_AGGREGATE_REQUEST: - return ofputil_decode_ofpst_flow_request(fsr, b.data, true); + return ofputil_decode_ofpst_flow_request(fsr, &b, true); case OFPRAW_NXST_FLOW_REQUEST: return ofputil_decode_nxst_flow_request(fsr, &b, false); -- 1.7.10.2.484.gcd07cc5 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev