'usable_protocols' is now getting set to OFPUTIL_P_OF10_ANY on return from 'parse_flow_monitor_request' function. The calling function now checks for the value in this variable against the 'allowed_protocols' variable. Also a check is added for a match field which is not supported in OpenFlow 1.0 and return an error. Modified the man page of ovs-ofctl to reflect Flow Monitor support as OpenFlow 1.0 Nicira extension only.
Signed-off-by: Ashish Varma <ashishvarma....@gmail.com> --- lib/ofp-monitor.c | 8 ++++++++ utilities/ovs-ofctl.8.in | 3 ++- utilities/ovs-ofctl.c | 8 ++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/ofp-monitor.c b/lib/ofp-monitor.c index aeebd7e..d24ffe5 100644 --- a/lib/ofp-monitor.c +++ b/lib/ofp-monitor.c @@ -469,6 +469,8 @@ parse_flow_monitor_request__(struct ofputil_flow_monitor_request *fmr, fmr->table_id = 0xff; match_init_catchall(&fmr->match); + /* A match field may reduce the usable protocols. */ + *usable_protocols = OFPUTIL_P_ANY; while (ofputil_parse_key_value(&string, &name, &value)) { const struct ofp_protocol *p; char *error = NULL; @@ -493,6 +495,10 @@ parse_flow_monitor_request__(struct ofputil_flow_monitor_request *fmr, } else if (mf_from_name(name)) { error = ofp_parse_field(mf_from_name(name), value, port_map, &fmr->match, usable_protocols); + if (!error && !(*usable_protocols & OFPUTIL_P_OF10_ANY)) { + return xasprintf("%s: match field is not supported for " + "flow monitor", name); + } } else { if (!*value) { return xasprintf("%s: field %s missing value", str_, name); @@ -514,6 +520,8 @@ parse_flow_monitor_request__(struct ofputil_flow_monitor_request *fmr, return error; } } + /* Flow Monitor is supported in OpenFlow 1.0 only. */ + *usable_protocols = OFPUTIL_P_OF10_ANY; return NULL; } diff --git a/utilities/ovs-ofctl.8.in b/utilities/ovs-ofctl.8.in index 60b4a1c..cb5c612 100644 --- a/utilities/ovs-ofctl.8.in +++ b/utilities/ovs-ofctl.8.in @@ -578,7 +578,8 @@ monitoring will not show any traffic. .IP "\fBmonitor \fIswitch\fR [\fImiss-len\fR] [\fBinvalid_ttl\fR] [\fBwatch:\fR[\fIspec\fR...]]" Connects to \fIswitch\fR and prints to the console all OpenFlow messages received. Usually, \fIswitch\fR should specify the name of a -bridge in the \fBovs\-vswitchd\fR database. +bridge in the \fBovs\-vswitchd\fR database. This is available only in +OpenFlow 1.0 as Nicira extension. .IP If \fImiss-len\fR is provided, \fBovs\-ofctl\fR sends an OpenFlow ``set configuration'' message at connection setup time that requests diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c index 63620e4..926a4f6 100644 --- a/utilities/ovs-ofctl.c +++ b/utilities/ovs-ofctl.c @@ -2286,6 +2286,14 @@ ofctl_monitor(struct ovs_cmdl_context *ctx) ovs_fatal(0, "%s", error); } + if (!(usable_protocols & allowed_protocols)) { + char *allowed_s = + ofputil_protocols_to_string(allowed_protocols); + char *usable_s = ofputil_protocols_to_string(usable_protocols); + ovs_fatal(0, "none of the usable protocols (%s) are among " + "the allowed protocols (%s)", usable_s, allowed_s); + } + msg = ofpbuf_new(0); ofputil_append_flow_monitor_request(&fmr, msg); dump_transaction(vconn, msg); -- 2.7.4 _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev