[ovs-dev] [PATCH 17/32] ofputil: Support encoding OF1.4 flow monitor requests
Simon Horman
horms at verge.net.au
Mon Jun 9 03:54:13 UTC 2014
Signed-off-by: Simon Horman <horms at verge.net.au>
---
lib/ofp-util.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++--
lib/ofp-util.h | 3 ++-
utilities/ovs-ofctl.c | 6 +++---
3 files changed, 52 insertions(+), 6 deletions(-)
diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index 9493370..7f1adcd 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -5360,8 +5360,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;
@@ -5384,6 +5384,51 @@ 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 OFP11_VERSION:
+ case OFP12_VERSION:
+ case OFP13_VERSION:
+ /* XXX: Use OF extension! */
+ 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);
+ 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 ccaf0ad..c41d8c9 100644
--- a/lib/ofp-util.h
+++ b/lib/ofp-util.h
@@ -850,7 +850,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 ea72be0..506b649 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
More information about the dev
mailing list