Signed-off-by: Simon Horman <ho...@verge.net.au> --- v2 * Re-arrange case statement to group unsupported versions with default --- lib/ofp-util.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- lib/ofp-util.h | 3 ++- utilities/ovs-ofctl.c | 6 +++--- 3 files changed, 51 insertions(+), 6 deletions(-)
diff --git a/lib/ofp-util.c b/lib/ofp-util.c index dd0c1ef..2c3bb0e 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -5361,8 +5361,8 @@ ofputil_decode_flow_monitor_request(struct ofputil_flow_monitor_request *rq, return error; } -void -ofputil_append_flow_monitor_request( +static void +ofputil_append_nx_flow_monitor_request( const struct ofputil_flow_monitor_request *rq, struct ofpbuf *msg) { struct nx_flow_monitor_request *nfmr; @@ -5385,6 +5385,50 @@ ofputil_append_flow_monitor_request( nfmr->table_id = rq->table_id; } +static void +ofputil_append_of14_flow_monitor_request( + const struct ofputil_flow_monitor_request *rq, enum ofp_version version, + struct ofpbuf *msg) +{ + struct ofp14_flow_monitor_request *ofpfmr; + size_t start_ofs; + + if (!ofpbuf_size(msg)) { + ofpraw_put(OFPRAW_OFPST14_FLOW_MONITOR_REQUEST, version, msg); + } + + start_ofs = ofpbuf_size(msg); + ofpbuf_put_zeros(msg, sizeof *ofpfmr); + oxm_put_match(msg, &rq->match, version); + + ofpfmr = ofpbuf_at_assert(msg, start_ofs, sizeof *ofpfmr); + ofpfmr->monitor_id = htonl(rq->id); + ofpfmr->flags = htons(rq->flags); + ofpfmr->out_port = ofputil_port_to_ofp11(rq->out_port); + ofpfmr->out_group = htonl(rq->out_group); + ofpfmr->table_id = rq->table_id; + ofpfmr->command = rq->command; +} + +void +ofputil_append_flow_monitor_request( + const struct ofputil_flow_monitor_request *rq, enum ofp_version version, + struct ofpbuf *msg) +{ + switch (version) { + case OFP10_VERSION: + return ofputil_append_nx_flow_monitor_request(rq, msg); + case OFP14_VERSION: + case OFP15_VERSION: + return ofputil_append_of14_flow_monitor_request(rq, version, msg); + case OFP11_VERSION: + case OFP12_VERSION: + case OFP13_VERSION: /* XXX: Use OF extension! */ + default: + OVS_NOT_REACHED(); + } +} + /* Converts an NXST_FLOW_MONITOR reply (also known as a flow update) in 'msg' * into an abstract ofputil_flow_update in 'update'. The caller must have * initialized update->match to point to space allocated for a match. diff --git a/lib/ofp-util.h b/lib/ofp-util.h index 24a6093..899f38d 100644 --- a/lib/ofp-util.h +++ b/lib/ofp-util.h @@ -853,7 +853,8 @@ enum nx_flow_monitor_flags nx_from_ofp14_flow_monitor_flags( int ofputil_decode_flow_monitor_request(struct ofputil_flow_monitor_request *, struct ofpbuf *msg); void ofputil_append_flow_monitor_request( - const struct ofputil_flow_monitor_request *, struct ofpbuf *msg); + const struct ofputil_flow_monitor_request *, enum ofp_version version, + struct ofpbuf *msg); /* Abstract nx_flow_update. */ struct ofputil_flow_update { diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c index 93f1382..24dc781 100644 --- a/utilities/ovs-ofctl.c +++ b/utilities/ovs-ofctl.c @@ -1526,9 +1526,11 @@ ofctl_monitor(int argc, char *argv[]) { struct vconn *vconn; int i; + enum ofp_version version; enum ofputil_protocol usable_protocols; open_vconn(argv[1], &vconn); + version = vconn_get_version(vconn); for (i = 2; i < argc; i++) { const char *arg = argv[i]; @@ -1552,7 +1554,7 @@ ofctl_monitor(int argc, char *argv[]) } msg = ofpbuf_new(0); - ofputil_append_flow_monitor_request(&fmr, msg); + ofputil_append_flow_monitor_request(&fmr, version, msg); dump_stats_transaction(vconn, msg); fflush(stdout); } else { @@ -1563,8 +1565,6 @@ ofctl_monitor(int argc, char *argv[]) if (preferred_packet_in_format >= 0) { set_packet_in_format(vconn, preferred_packet_in_format); } else { - enum ofp_version version = vconn_get_version(vconn); - switch (version) { case OFP10_VERSION: { struct ofpbuf *spif, *reply; -- 2.0.0.rc2 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev